mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 04:32:50 -04:00
Tree draw op now sets appropriate bounds, meaning cloudy brush works properly for /tree.
This commit is contained in:
parent
95fb7603f6
commit
86e45cd165
@ -43,11 +43,7 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
|
||||
public static bool DoDrawOp(DrawOp op, Brush brush, Player p,
|
||||
Vec3S32[] marks, bool checkLimit = true) {
|
||||
op.Origin = marks[0]; op.Min = marks[0]; op.Max = marks[0];
|
||||
for (int i = 1; i < marks.Length; i++) {
|
||||
op.Min = Vec3S32.Min(op.Min, marks[i]);
|
||||
op.Max = Vec3S32.Max(op.Max, marks[i]);
|
||||
}
|
||||
op.SetMarks(marks);
|
||||
op.Level = p == null ? null : p.level;
|
||||
if (op.Level != null && !op.Level.DrawingAllowed) {
|
||||
Player.Message(p, "Drawing commands are turned off on this map.");
|
||||
|
@ -84,6 +84,14 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void SetMarks(Vec3S32[] marks) {
|
||||
Origin = marks[0]; Min = marks[0]; Max = marks[0];
|
||||
for (int i = 1; i < marks.Length; i++) {
|
||||
Min = Vec3S32.Min(Min, marks[i]);
|
||||
Max = Vec3S32.Max(Max, marks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Reset() {
|
||||
//TotalAffected = 0;
|
||||
TotalModified = 0;
|
||||
|
@ -35,24 +35,49 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
|
||||
public Random random;
|
||||
public bool overwrite = false;
|
||||
public int Type;
|
||||
public int Type;
|
||||
public const int T_Tree = 0, T_NotchTree = 1, T_NotchSwamp = 2, T_Cactus = 3;
|
||||
static Brush defBrush = new SolidBrush(Block.leaf, 0);
|
||||
byte height, top, size;
|
||||
|
||||
public override long GetBlocksAffected(Level lvl, Vec3S32[] marks) { return -1; }
|
||||
|
||||
public override void Perform(Vec3S32[] marks, Player p, Level lvl, Brush brush) {
|
||||
if (brush == null) brush = defBrush;
|
||||
Vec3U16 P = Clamp(marks[0]);
|
||||
if (brush == null) brush = defBrush;
|
||||
Vec3U16 P = Clamp(marks[0]);
|
||||
if (Type == T_Tree) AddTree(p, lvl, P.X, P.Y, P.Z, brush);
|
||||
if (Type == T_NotchTree) AddNotchTree(p, lvl, P.X, P.Y, P.Z, brush);
|
||||
if (Type == T_NotchSwamp) AddNotchSwampTree(p, lvl, P.X, P.Y, P.Z, brush);
|
||||
if (Type == T_Cactus) AddCactus(p, lvl, P.X, P.Y, P.Z);
|
||||
}
|
||||
|
||||
public override void SetMarks(Vec3S32[] marks) {
|
||||
base.SetMarks(marks);
|
||||
switch (Type) {
|
||||
case T_Tree:
|
||||
height = (byte)random.Next(5, 8);
|
||||
top = (byte)(height - random.Next(2, 4));
|
||||
size = top; break;
|
||||
case T_NotchTree:
|
||||
height = (byte)random.Next(3, 7);
|
||||
top = (byte)(height - 2);
|
||||
size = 2; break;
|
||||
case T_NotchSwamp:
|
||||
height = (byte)random.Next(4, 8);
|
||||
top = (byte)(height - 2);
|
||||
size = 3; break;
|
||||
case T_Cactus:
|
||||
height = (byte)random.Next(3, 6);
|
||||
top = 0;
|
||||
size = 0; break;
|
||||
}
|
||||
|
||||
Max.Y += height;
|
||||
Min.X -= size; Min.Z -= size;
|
||||
Max.X += size; Max.Z += size;
|
||||
}
|
||||
|
||||
void AddTree(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) {
|
||||
byte height = (byte)random.Next(5, 8);
|
||||
short top = (short)(height - random.Next(2, 4));
|
||||
for (ushort dy = 0; dy < top + height - 1; dy++) {
|
||||
ushort yy = (ushort)(y + dy);
|
||||
if (overwrite || lvl.GetTile(x, yy, z) == Block.air || (yy == y && lvl.GetTile(x, yy, z) == Block.shrub))
|
||||
@ -68,14 +93,12 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
ushort xx = (ushort)(x + dx), yy = (ushort)(y + dy + height), zz = (ushort)(z + dz);
|
||||
|
||||
if ((xx != x || zz != z || dy >= top - 1) && (overwrite || lvl.GetTile(xx, yy, zz) == Block.air))
|
||||
PlaceBlock(p, lvl, xx, yy, zz, brush);
|
||||
PlaceBlock(p, lvl, xx, yy, zz, brush);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddNotchTree(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) {
|
||||
byte height = (byte)random.Next(3, 7);
|
||||
byte top = (byte)(height - 2);
|
||||
for (int dy = 0; dy <= height; dy++) {
|
||||
ushort yy = (ushort)(y + dy);
|
||||
byte tile = lvl.GetTile(x, yy, z);
|
||||
@ -106,8 +129,6 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
}
|
||||
|
||||
void AddNotchSwampTree(Player p, Level lvl, ushort x, ushort y, ushort z, Brush brush) {
|
||||
byte height = (byte)random.Next(4, 8);
|
||||
byte top = (byte)(height - 2);
|
||||
for (int dy = 0; dy <= height; dy++) {
|
||||
ushort yy = (ushort)(y + dy);
|
||||
byte tile = lvl.GetTile(x, yy, z);
|
||||
@ -131,14 +152,13 @@ namespace MCGalaxy.Drawing.Ops {
|
||||
if (random.Next(2) == 0)
|
||||
PlaceBlock(p, lvl, xx, yy, zz, brush);
|
||||
} else {
|
||||
PlaceBlock(p, lvl, xx, yy, zz, brush);
|
||||
PlaceBlock(p, lvl, xx, yy, zz, brush);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddCactus(Player p, Level lvl, ushort x, ushort y, ushort z) {
|
||||
byte height = (byte)random.Next(3, 6);
|
||||
for (ushort dy = 0; dy <= height; dy++) {
|
||||
if (overwrite || lvl.GetTile(z, (ushort)(y + dy), z) == Block.air)
|
||||
PlaceBlock(p, lvl, x, (ushort)(y + dy), z, Block.green, 0);
|
||||
|
@ -148,6 +148,7 @@ namespace MCGalaxy {
|
||||
if (rand.Next(13) == 0 && !TreeDrawOp.TreeCheck(Lvl, x, y, z, treeDist)) {
|
||||
treeDrawer.Type = genParams.UseCactus ? TreeDrawOp.T_Cactus : TreeDrawOp.T_Tree;
|
||||
treeCoords[0].X = x; treeCoords[0].Y = (ushort)(y + 1); treeCoords[0].Z = z;
|
||||
treeDrawer.SetMarks(treeCoords);
|
||||
treeDrawer.Perform(treeCoords, null, Lvl, null);
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,9 @@ namespace MCGalaxy.BlockPhysics {
|
||||
TreeDrawOp op = new TreeDrawOp();
|
||||
op.random = rand;
|
||||
op.method = DrawOp.M_BlockChange;
|
||||
op.Perform(new [] { new Vec3S32(x, y, z) }, null, lvl, null);
|
||||
Vec3S32[] marks = new [] { new Vec3S32(x, y, z) };
|
||||
op.SetMarks(marks);
|
||||
op.Perform(marks, null, lvl, null);
|
||||
C.data.Data = 255;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user