mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
And make even more commands use selection methods. if (BlockChange != null) no longer adds an entry to the BlockDB.
This commit is contained in:
parent
6ae7031e26
commit
75108aac21
@ -74,45 +74,34 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HandleOther(Player p, string opt, string[] parts, int allowoffset) {
|
void HandleOther(Player p, string opt, string[] parts, int allowoffset) {
|
||||||
CatchPos cpos = default(CatchPos);
|
CopyArgs cArgs = default(CopyArgs);
|
||||||
p.copyoffset[0] = 0; p.copyoffset[1] = 0; p.copyoffset[2] = 0;
|
p.copyoffset = default(Vec3S32);
|
||||||
cpos.allowoffset = allowoffset;
|
cArgs.allowoffset = allowoffset;
|
||||||
|
|
||||||
if (opt == "cut") {
|
if (opt == "cut") {
|
||||||
cpos.type = 1;
|
cArgs.type = 1;
|
||||||
} else if (opt == "air") {
|
} else if (opt == "air") {
|
||||||
cpos.type = 2;
|
cArgs.type = 2;
|
||||||
} else if (!String.IsNullOrEmpty(opt)) {
|
} else if (!String.IsNullOrEmpty(opt)) {
|
||||||
Help(p); return;
|
Help(p); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.blockchangeObject = cpos;
|
|
||||||
Player.Message(p, "Place two blocks to determine the edges.");
|
Player.Message(p, "Place two blocks to determine the edges.");
|
||||||
p.ClearBlockchange();
|
p.MakeSelection(2, cArgs, DoCopy);
|
||||||
p.Blockchange += PlacedMark1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacedMark1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
bool DoCopy(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
p.copystart = m[0];
|
||||||
CatchPos bp = (CatchPos)p.blockchangeObject;
|
CopyArgs cArgs = (CopyArgs)state;
|
||||||
p.copystart[0] = x; p.copystart[1] = y; p.copystart[2] = z;
|
ushort minX = (ushort)Math.Min(m[0].X, m[1].X), maxX = (ushort)Math.Max(m[0].X, m[1].X);
|
||||||
|
ushort minY = (ushort)Math.Min(m[0].Y, m[1].Y), maxY = (ushort)Math.Max(m[0].Y, m[1].Y);
|
||||||
|
ushort minZ = (ushort)Math.Min(m[0].Z, m[1].Z), maxZ = (ushort)Math.Max(m[0].Z, m[1].Z);
|
||||||
|
|
||||||
bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
|
CopyState cState = new CopyState(minX, minY, minZ, maxX - minX + 1,
|
||||||
p.Blockchange += PlacedMark2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacedMark2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
|
||||||
RevertAndClearState(p, x, y, z);
|
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
|
||||||
ushort minX = (ushort)Math.Min(x, cpos.x), maxX = (ushort)Math.Max(x, cpos.x);
|
|
||||||
ushort minY = (ushort)Math.Min(y, cpos.y), maxY = (ushort)Math.Max(y, cpos.y);
|
|
||||||
ushort minZ = (ushort)Math.Min(z, cpos.z), maxZ = (ushort)Math.Max(z, cpos.z);
|
|
||||||
|
|
||||||
CopyState state = new CopyState(minX, minY, minZ, maxX - minX + 1,
|
|
||||||
maxY - minY + 1, maxZ - minZ + 1);
|
maxY - minY + 1, maxZ - minZ + 1);
|
||||||
state.SetOrigin(cpos.x, cpos.y, cpos.z);
|
cState.SetOrigin(m[0].X, m[0].Y, m[0].Z);
|
||||||
int index = 0; state.UsedBlocks = 0;
|
int index = 0; cState.UsedBlocks = 0;
|
||||||
state.PasteAir = cpos.type == 2;
|
cState.PasteAir = cArgs.type == 2;
|
||||||
|
|
||||||
for (ushort yy = minY; yy <= maxY; ++yy)
|
for (ushort yy = minY; yy <= maxY; ++yy)
|
||||||
for (ushort zz = minZ; zz <= maxZ; ++zz)
|
for (ushort zz = minZ; zz <= maxZ; ++zz)
|
||||||
@ -123,22 +112,22 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
if (b == Block.custom_block)
|
if (b == Block.custom_block)
|
||||||
extB = p.level.GetExtTile(xx, yy, zz);
|
extB = p.level.GetExtTile(xx, yy, zz);
|
||||||
|
|
||||||
if (b != Block.air || state.PasteAir)
|
if (b != Block.air || cState.PasteAir)
|
||||||
state.UsedBlocks++;
|
cState.UsedBlocks++;
|
||||||
state.Blocks[index] = b;
|
cState.Blocks[index] = b;
|
||||||
state.ExtBlocks[index] = extB;
|
cState.ExtBlocks[index] = extB;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.UsedBlocks > p.group.maxBlocks) {
|
if (cState.UsedBlocks > p.group.maxBlocks) {
|
||||||
Player.Message(p, "You tried to copy {0} blocks. You cannot copy more than {1} blocks.",
|
Player.Message(p, "You tried to copy {0} blocks. You cannot copy more than {1} blocks.",
|
||||||
state.UsedBlocks, p.group.maxBlocks);
|
cState.UsedBlocks, p.group.maxBlocks);
|
||||||
state.Blocks = null; state.ExtBlocks = null; state = null;
|
cState.Blocks = null; cState.ExtBlocks = null; cState = null;
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.CopyBuffer = state;
|
p.CopyBuffer = cState;
|
||||||
if (cpos.type == 1) {
|
if (cArgs.type == 1) {
|
||||||
DrawOp op = new CuboidDrawOp();
|
DrawOp op = new CuboidDrawOp();
|
||||||
Brush brush = new SolidBrush(Block.air, 0);
|
Brush brush = new SolidBrush(Block.air, 0);
|
||||||
Vec3S32[] marks = { new Vec3S32(minX, minY, minZ), new Vec3S32(maxX, maxY, maxZ) };
|
Vec3S32[] marks = { new Vec3S32(minX, minY, minZ), new Vec3S32(maxX, maxY, maxZ) };
|
||||||
@ -146,21 +135,20 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string format = "Copied &a{0} %Sblocks." +
|
string format = "Copied &a{0} %Sblocks." +
|
||||||
(state.PasteAir ? "" : " To also copy air blocks, use %T/copy air");
|
(cState.PasteAir ? "" : " To also copy air blocks, use %T/copy air");
|
||||||
Player.Message(p, format, state.UsedBlocks);
|
Player.Message(p, format, cState.UsedBlocks);
|
||||||
if (cpos.allowoffset != -1) {
|
if (cArgs.allowoffset != -1) {
|
||||||
Player.Message(p, "Place a block to determine where to paste from");
|
Player.Message(p, "Place a block to determine where to paste from");
|
||||||
p.Blockchange += Blockchange3;
|
p.Blockchange += Blockchange3;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blockchange3(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
void Blockchange3(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
RevertAndClearState(p, x, y, z);
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
p.copyoffset.X = p.copystart.X - x;
|
||||||
|
p.copyoffset.Y = p.copystart.Y - y;
|
||||||
p.copyoffset[0] = (p.copystart[0] - x);
|
p.copyoffset.Z = p.copystart.Z - z;
|
||||||
p.copyoffset[1] = (p.copystart[1] - y);
|
|
||||||
p.copyoffset[2] = (p.copystart[2] - z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveCopy(Player p, string file) {
|
void SaveCopy(Player p, string file) {
|
||||||
@ -206,7 +194,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
Player.Message(p, "Loaded copy as " + file);
|
Player.Message(p, "Loaded copy as " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { public ushort x, y, z; public int type; public int allowoffset; }
|
struct CopyArgs { public int type, allowoffset; }
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "/copy - Copies the blocks in an area.");
|
Player.Message(p, "/copy - Copies the blocks in an area.");
|
||||||
|
@ -32,7 +32,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
DrawOp op = null;
|
DrawOp op = null;
|
||||||
Func<BrushArgs, Brush> constructor = null;
|
Func<BrushArgs, Brush> constructor = null;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
AdvDrawOp op = null;
|
AdvDrawOp op = null;
|
||||||
switch (cpos.mode) {
|
switch (cpos.mode) {
|
||||||
case DrawMode.cone:
|
case DrawMode.cone:
|
||||||
|
@ -26,39 +26,31 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
CatchPos cpos = default(CatchPos);
|
int dist = 20;
|
||||||
cpos.dist = 20;
|
if (message != "" && !int.TryParse(message, out dist)) { Help(p); return; }
|
||||||
|
|
||||||
if (message != "" && !int.TryParse(message, out cpos.dist)) {
|
|
||||||
Help(p); return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.blockchangeObject = cpos;
|
|
||||||
Player.Message(p, "Destroy the block you wish to drill.");
|
Player.Message(p, "Destroy the block you wish to drill.");
|
||||||
p.ClearBlockchange();
|
p.MakeSelection(1, dist, DoDrill);
|
||||||
p.Blockchange += Blockchange1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
bool DoDrill(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
if (!p.staticCommands) p.ClearBlockchange();
|
ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z;
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
|
||||||
type = p.level.GetTile(x, y, z); extType = 0;
|
type = p.level.GetTile(x, y, z); extType = 0;
|
||||||
if (type == Block.custom_block) extType = p.level.GetExtTile(x, y, z);
|
if (type == Block.custom_block)
|
||||||
p.RevertBlock(x, y, z);
|
extType = p.level.GetExtTile(x, y, z);
|
||||||
|
int dist = (int)state;
|
||||||
|
|
||||||
int diffX = 0, diffZ = 0;
|
int dx = 0, dz = 0;
|
||||||
|
if (p.rot[0] <= 32 || p.rot[0] >= 224) { dz = -1; }
|
||||||
if (p.rot[0] <= 32 || p.rot[0] >= 224) { diffZ = -1; }
|
else if (p.rot[0] <= 96) { dx = 1; }
|
||||||
else if (p.rot[0] <= 96) { diffX = 1; }
|
else if (p.rot[0] <= 160) { dz = 1; }
|
||||||
else if (p.rot[0] <= 160) { diffZ = 1; }
|
else dx = -1;
|
||||||
else diffX = -1;
|
|
||||||
|
|
||||||
List<int> buffer = new List<int>();
|
List<int> buffer = new List<int>();
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
Level lvl = p.level;
|
Level lvl = p.level;
|
||||||
|
|
||||||
if (diffX != 0) {
|
if (dx != 0) {
|
||||||
for (ushort xx = x; depth < cpos.dist; xx += (ushort)diffX)
|
for (ushort xx = x; depth < dist; xx += (ushort)dx)
|
||||||
{
|
{
|
||||||
for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
|
for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
|
||||||
for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
|
for (ushort zz = (ushort)(z - 1); zz <= (ushort)(z + 1); zz++)
|
||||||
@ -68,7 +60,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
depth++;
|
depth++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (ushort zz = z; depth < cpos.dist; zz += (ushort)diffZ)
|
for (ushort zz = z; depth < dist; zz += (ushort)dz)
|
||||||
{
|
{
|
||||||
for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
|
for (ushort yy = (ushort)(y - 1); yy <= (ushort)(y + 1); yy++)
|
||||||
for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
|
for (ushort xx = (ushort)(x - 1); xx <= (ushort)(x + 1); xx++)
|
||||||
@ -82,7 +74,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
if (buffer.Count > p.group.maxBlocks) {
|
if (buffer.Count > p.group.maxBlocks) {
|
||||||
Player.Message(p, "You tried to drill " + buffer.Count + " blocks.");
|
Player.Message(p, "You tried to drill " + buffer.Count + " blocks.");
|
||||||
Player.Message(p, "You cannot drill more than " + p.group.maxBlocks + ".");
|
Player.Message(p, "You cannot drill more than " + p.group.maxBlocks + ".");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in buffer) {
|
foreach (int index in buffer) {
|
||||||
@ -95,10 +87,9 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
if (sameBlock) p.level.UpdateBlock(p, x, y, z, Block.air, 0);
|
if (sameBlock) p.level.UpdateBlock(p, x, y, z, Block.air, 0);
|
||||||
}
|
}
|
||||||
Player.Message(p, "Drilled " + buffer.Count + " blocks.");
|
Player.Message(p, "Drilled " + buffer.Count + " blocks.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { public int dist; }
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/drill [distance]");
|
Player.Message(p, "%T/drill [distance]");
|
||||||
Player.Message(p, "%HDrills a hole, destroying all similar blocks in a 3x3 rectangle ahead of you.");
|
Player.Message(p, "%HDrills a hole, destroying all similar blocks in a 3x3 rectangle ahead of you.");
|
||||||
|
@ -45,7 +45,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
if (oldType == Block.custom_block)
|
if (oldType == Block.custom_block)
|
||||||
oldExtType = p.level.GetExtTile(x, y, z);
|
oldExtType = p.level.GetExtTile(x, y, z);
|
||||||
|
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) {
|
if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) {
|
||||||
Player.Message(p, "Cannot fill with that."); return false;
|
Player.Message(p, "Cannot fill with that."); return false;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
|
|
||||||
if (cpos.mode == DrawMode.straight) {
|
if (cpos.mode == DrawMode.straight) {
|
||||||
int dx = Math.Abs(m[0].X - m[1].X), dy = Math.Abs(m[0].Y - m[1].Y), dz = Math.Abs(m[0].Z - m[1].Z);
|
int dx = Math.Abs(m[0].X - m[1].X), dy = Math.Abs(m[0].Y - m[1].Y), dz = Math.Abs(m[0].Z - m[1].Z);
|
||||||
|
@ -28,50 +28,39 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
public override bool museumUsable { get { return false; } }
|
public override bool museumUsable { get { return false; } }
|
||||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||||
public override CommandAlias[] Aliases {
|
public override CommandAlias[] Aliases {
|
||||||
get { return new[] { new CommandAlias("pn", "not") }; }
|
get { return new[] { new CommandAlias("pastenot", "not"), new CommandAlias("pn", "not") }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (p.CopyBuffer == null) { Player.Message(p, "You haven't copied anything yet"); return; }
|
if (p.CopyBuffer == null) { Player.Message(p, "You haven't copied anything yet"); return; }
|
||||||
|
|
||||||
CatchPos cpos = default(CatchPos);
|
|
||||||
cpos.message = message;
|
|
||||||
p.blockchangeObject = cpos;
|
|
||||||
Player.Message(p, "Place a block in the corner of where you want to paste.");
|
Player.Message(p, "Place a block in the corner of where you want to paste.");
|
||||||
p.ClearBlockchange();
|
p.MakeSelection(1, message, DoPaste);
|
||||||
p.Blockchange += PlacedOrigin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacedOrigin(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
bool DoPaste(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
string message = (string)state;
|
||||||
RevertAndClearState(p, x, y, z);
|
m[0] += p.copyoffset;
|
||||||
int x1 = p.copyoffset[0] + x, y1 = p.copyoffset[1] + y, z1 = p.copyoffset[2] + z;
|
CopyState cState = p.CopyBuffer;
|
||||||
CopyState state = p.CopyBuffer;
|
if (cState.X != cState.OriginX) m[0].X -= (cState.Width - 1);
|
||||||
if (state.X != state.OriginX) x1 -= (state.Width - 1);
|
if (cState.Y != cState.OriginY) m[0].Y -= (cState.Height - 1);
|
||||||
if (state.Y != state.OriginY) y1 -= (state.Height - 1);
|
if (cState.Z != cState.OriginZ) m[0].Z -= (cState.Length - 1);
|
||||||
if (state.Z != state.OriginZ) z1 -= (state.Length - 1);
|
|
||||||
|
|
||||||
DrawOp op;
|
DrawOp op;
|
||||||
if (cpos.message == "") {
|
if (message == "") {
|
||||||
op = new SimplePasteDrawOp();
|
op = new SimplePasteDrawOp();
|
||||||
((SimplePasteDrawOp)op).CopyState = p.CopyBuffer;
|
((SimplePasteDrawOp)op).CopyState = p.CopyBuffer;
|
||||||
} else {
|
} else {
|
||||||
op = new PasteDrawOp();
|
op = new PasteDrawOp();
|
||||||
((PasteDrawOp)op).CopyState = p.CopyBuffer;
|
((PasteDrawOp)op).CopyState = p.CopyBuffer;
|
||||||
string[] args = cpos.message.Split(' ');
|
string[] args = message.Split(' ');
|
||||||
if (args[0].CaselessEq("not"))
|
if (args[0].CaselessEq("not"))
|
||||||
((PasteDrawOp)op).Exclude = ReplaceBrush.GetBlocks(p, 1, args.Length, args);
|
((PasteDrawOp)op).Exclude = ReplaceBrush.GetBlocks(p, 1, args.Length, args);
|
||||||
else
|
else
|
||||||
((PasteDrawOp)op).Include = ReplaceBrush.GetBlocks(p, 0, args.Length, args);
|
((PasteDrawOp)op).Include = ReplaceBrush.GetBlocks(p, 0, args.Length, args);
|
||||||
}
|
}
|
||||||
Vec3S32[] marks = { new Vec3S32(x1, y1, z1) };
|
return DrawOp.DoDrawOp(op, null, p, m);
|
||||||
if (!DrawOp.DoDrawOp(op, null, p, marks))
|
|
||||||
return;
|
|
||||||
if (p.staticCommands) p.Blockchange += PlacedOrigin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { public string message; }
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "/paste - Pastes the stored copy.");
|
Player.Message(p, "/paste - Pastes the stored copy.");
|
||||||
Player.Message(p, "/paste [block] [block2].. - Pastes only the specified blocks from the copy.");
|
Player.Message(p, "/paste [block] [block2].. - Pastes only the specified blocks from the copy.");
|
||||||
|
@ -27,8 +27,8 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
DrawOp drawOp = null;
|
DrawOp op = null;
|
||||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||||
if (brush == null) return false;
|
if (brush == null) return false;
|
||||||
@ -40,13 +40,13 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
switch (cpos.mode) {
|
switch (cpos.mode) {
|
||||||
case DrawMode.solid:
|
case DrawMode.solid:
|
||||||
case DrawMode.normal:
|
case DrawMode.normal:
|
||||||
drawOp = new PyramidSolidDrawOp(); break;
|
op = new PyramidSolidDrawOp(); break;
|
||||||
case DrawMode.hollow:
|
case DrawMode.hollow:
|
||||||
drawOp = new PyramidHollowDrawOp(); break;
|
op = new PyramidHollowDrawOp(); break;
|
||||||
case DrawMode.reverse:
|
case DrawMode.reverse:
|
||||||
drawOp = new PyramidReverseDrawOp(); break;
|
op = new PyramidReverseDrawOp(); break;
|
||||||
}
|
}
|
||||||
return DrawOp.DoDrawOp(drawOp, brush, p, marks);
|
return DrawOp.DoDrawOp(op, brush, p, marks);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawMode ParseMode(string msg) {
|
protected override DrawMode ParseMode(string msg) {
|
||||||
|
@ -41,7 +41,6 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
bool DoReplace(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
type = type < 128 ? p.bindings[type] : type;
|
|
||||||
string[] parts = ((string)state).SplitSpaces(3);
|
string[] parts = ((string)state).SplitSpaces(3);
|
||||||
if (parts.Length < 2) { Help(p); return false; }
|
if (parts.Length < 2) { Help(p); return false; }
|
||||||
|
|
||||||
|
@ -29,37 +29,34 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
public CmdRestartPhysics() { }
|
public CmdRestartPhysics() { }
|
||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
CatchPos cpos = default(CatchPos);
|
PhysicsArgs extraInfo = default(PhysicsArgs);
|
||||||
message = message.ToLower();
|
message = message.ToLower();
|
||||||
if (message != "" && !ParseArgs(p, message, ref cpos)) return;
|
if (message != "" && !ParseArgs(p, message, ref extraInfo)) return;
|
||||||
|
|
||||||
p.blockchangeObject = cpos;
|
|
||||||
Player.Message(p, "Place two blocks to determine the edges.");
|
Player.Message(p, "Place two blocks to determine the edges.");
|
||||||
p.ClearBlockchange();
|
p.MakeSelection(2, extraInfo, DoRestart);
|
||||||
p.Blockchange += PlacedMark1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParseArgs(Player p, string message, ref CatchPos cpos) {
|
bool ParseArgs(Player p, string message, ref PhysicsArgs extraInfo) {
|
||||||
string[] parts = message.Split(' ');
|
string[] parts = message.Split(' ');
|
||||||
if (parts.Length % 2 == 1) {
|
if (parts.Length % 2 == 1) {
|
||||||
Player.Message(p, "Number of parameters must be even");
|
Player.Message(p, "Number of parameters must be even");
|
||||||
Help(p); return false;
|
Help(p); return false;
|
||||||
}
|
}
|
||||||
PhysicsArgs args = default(PhysicsArgs);
|
|
||||||
byte type = 0, value = 0;
|
byte type = 0, value = 0;
|
||||||
|
|
||||||
if (parts.Length >= 2) {
|
if (parts.Length >= 2) {
|
||||||
if (!Parse(p, parts[0], parts[1], ref type, ref value)) return false;
|
if (!Parse(p, parts[0], parts[1], ref type, ref value)) return false;
|
||||||
args.Type1 = type; args.Value1 = value;
|
extraInfo.Type1 = type; extraInfo.Value1 = value;
|
||||||
}
|
}
|
||||||
if (parts.Length >= 4) {
|
if (parts.Length >= 4) {
|
||||||
if (!Parse(p, parts[2], parts[3], ref type, ref value)) return false;
|
if (!Parse(p, parts[2], parts[3], ref type, ref value)) return false;
|
||||||
args.Type2 = type; args.Value2 = value;
|
extraInfo.Type2 = type; extraInfo.Value2 = value;
|
||||||
}
|
}
|
||||||
if (parts.Length >= 6) {
|
if (parts.Length >= 6) {
|
||||||
Player.Message(p, "You can only use up to two types of physics."); return false;
|
Player.Message(p, "You can only use up to two types of physics."); return false;
|
||||||
}
|
}
|
||||||
cpos.extraInfo = args; return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parse(Player p, string name, string arg, ref byte type, ref byte value) {
|
bool Parse(Player p, string name, string arg, ref byte type, ref byte value) {
|
||||||
@ -90,48 +87,37 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacedMark1(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
bool DoRestart(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
PhysicsArgs extraInfo = (PhysicsArgs)state;
|
||||||
CatchPos bp = (CatchPos)p.blockchangeObject;
|
|
||||||
bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
|
|
||||||
p.Blockchange += PlacedMark2;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlacedMark2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
|
||||||
RevertAndClearState(p, x, y, z);
|
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
|
||||||
List<int> buffer = new List<int>();
|
List<int> buffer = new List<int>();
|
||||||
|
|
||||||
for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
|
for (int y = Math.Min(m[0].Y, m[1].Y); y <= Math.Max(m[0].Y, m[1].Y); y++)
|
||||||
for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
|
for (int z = Math.Min(m[0].Z, m[1].Z); z <= Math.Max(m[0].Z, m[1].Z); z++)
|
||||||
for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
|
for (int x = Math.Min(m[0].X, m[1].X); x <= Math.Max(m[0].X, m[1].X); x++)
|
||||||
{
|
{
|
||||||
int index = p.level.PosToInt(xx, yy, zz);
|
int index = p.level.PosToInt((ushort)x, (ushort)y, (ushort)z);
|
||||||
if (index >= 0 && p.level.blocks[index] != Block.air)
|
if (index >= 0 && p.level.blocks[index] != Block.air)
|
||||||
buffer.Add(index);
|
buffer.Add(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpos.extraInfo.Raw == 0) {
|
if (extraInfo.Raw == 0) {
|
||||||
if (buffer.Count > Server.rpNormLimit) {
|
if (buffer.Count > Server.rpNormLimit) {
|
||||||
Player.Message(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
|
Player.Message(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
|
||||||
Player.Message(p, "Tried to restart " + buffer.Count + " blocks.");
|
Player.Message(p, "Tried to restart " + buffer.Count + " blocks.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (buffer.Count > Server.rpLimit) {
|
} else if (buffer.Count > Server.rpLimit) {
|
||||||
Player.Message(p, "Tried to add physics to " + buffer.Count + " blocks.");
|
Player.Message(p, "Tried to add physics to " + buffer.Count + " blocks.");
|
||||||
Player.Message(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
|
Player.Message(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int index in buffer)
|
foreach (int index in buffer)
|
||||||
p.level.AddCheck(index, true, cpos.extraInfo);
|
p.level.AddCheck(index, true, extraInfo);
|
||||||
Player.Message(p, "Activated " + buffer.Count + " blocks.");
|
Player.Message(p, "Activated " + buffer.Count + " blocks.");
|
||||||
if (p.staticCommands)
|
return true;
|
||||||
p.Blockchange += PlacedMark1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { public ushort x, y, z; public PhysicsArgs extraInfo; }
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "/restartphysics ([type] [num]) ([type2] [num2]) - Restarts every physics block in an area");
|
Player.Message(p, "/restartphysics ([type] [num]) ([type2] [num2]) - Restarts every physics block in an area");
|
||||||
Player.Message(p, "[type] will set custom physics for selected blocks");
|
Player.Message(p, "[type] will set custom physics for selected blocks");
|
||||||
|
@ -37,7 +37,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
|
|
||||||
DrawOp op = null;
|
DrawOp op = null;
|
||||||
Func<BrushArgs, Brush> constructor = null;
|
Func<BrushArgs, Brush> constructor = null;
|
||||||
|
@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
DrawOp op = null;
|
DrawOp op = null;
|
||||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||||
Brush brush = GetBrush(p, cpos, brushOffset);
|
Brush brush = GetBrush(p, cpos, brushOffset);
|
||||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] m, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
|
|
||||||
DrawOp drawOp = new TorusDrawOp();
|
DrawOp drawOp = new TorusDrawOp();
|
||||||
Brush brush = GetBrush(p, cpos, 0);
|
Brush brush = GetBrush(p, cpos, 0);
|
||||||
|
@ -44,20 +44,15 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
default: brushMsg = message; break;
|
default: brushMsg = message; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CatchPos cpos = default(CatchPos);
|
DrawArgs dArgs = default(DrawArgs);
|
||||||
cpos.mode = mode;
|
dArgs.mode = mode;
|
||||||
cpos.brushMsg = brushMsg;
|
dArgs.brushMsg = brushMsg;
|
||||||
p.ClearBlockchange();
|
|
||||||
p.blockchangeObject = cpos;
|
|
||||||
p.Blockchange += PlacedBase;
|
|
||||||
Player.Message(p, "Select where you wish your tree to grow");
|
Player.Message(p, "Select where you wish your tree to grow");
|
||||||
|
p.MakeSelection(1, dArgs, DoTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlacedBase(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
bool DoTree(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
RevertAndClearState(p, x, y, z);
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
|
||||||
type = type < 128 ? p.bindings[type] : type;
|
|
||||||
|
|
||||||
TreeDrawOp op = new TreeDrawOp();
|
TreeDrawOp op = new TreeDrawOp();
|
||||||
op.Type = cpos.mode;
|
op.Type = cpos.mode;
|
||||||
op.random = p.random;
|
op.random = p.random;
|
||||||
@ -65,17 +60,12 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
if (cpos.brushMsg != "") {
|
if (cpos.brushMsg != "") {
|
||||||
if (!p.group.CanExecute("brush")) {
|
if (!p.group.CanExecute("brush")) {
|
||||||
Player.Message(p, "You cannot use /brush, so therefore cannot use /tree with a brush."); return;
|
Player.Message(p, "You cannot use /brush, so therefore cannot use /tree with a brush."); return false;
|
||||||
}
|
}
|
||||||
brush = ParseBrush(cpos.brushMsg, p, type, extType);
|
brush = ParseBrush(cpos.brushMsg, p, type, extType);
|
||||||
if (brush == null) return;
|
if (brush == null) return false;
|
||||||
}
|
}
|
||||||
|
return DrawOp.DoDrawOp(op, brush, p, marks);
|
||||||
Vec3S32[] marks = { new Vec3S32(x, y, z) };
|
|
||||||
if (!DrawOp.DoDrawOp(op, brush, p, marks))
|
|
||||||
return;
|
|
||||||
if (p.staticCommands)
|
|
||||||
p.Blockchange += PlacedBase;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Brush ParseBrush(string brushMsg, Player p, byte type, byte extType) {
|
static Brush ParseBrush(string brushMsg, Player p, byte type, byte extType) {
|
||||||
@ -92,7 +82,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
return Brush.Brushes[brushName](args);
|
return Brush.Brushes[brushName](args);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CatchPos { public int mode; public string brushMsg; }
|
struct DrawArgs { public int mode; public string brushMsg; }
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/tree [type] %H- Draws a tree.");
|
Player.Message(p, "%T/tree [type] %H- Draws a tree.");
|
||||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
protected override bool DoDraw(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
DrawArgs cpos = (DrawArgs)state;
|
DrawArgs cpos = (DrawArgs)state;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
cpos.type = type; cpos.extType = extType;
|
||||||
|
|
||||||
Brush brush = GetBrush(p, cpos, 0, null);
|
Brush brush = GetBrush(p, cpos, 0, null);
|
||||||
if (brush == null) return false;
|
if (brush == null) return false;
|
||||||
|
@ -49,7 +49,6 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DoWrite(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
bool DoWrite(Player p, Vec3S32[] marks, object state, byte type, byte extType) {
|
||||||
type = type < 128 ? p.bindings[type] : type;
|
|
||||||
WriteArgs wArgs = (WriteArgs)state;
|
WriteArgs wArgs = (WriteArgs)state;
|
||||||
if (marks[0].X == marks[1].X && marks[0].Z == marks[1].Z) {
|
if (marks[0].X == marks[1].X && marks[0].Z == marks[1].Z) {
|
||||||
Player.Message(p, "No direction was selected"); return false;
|
Player.Message(p, "No direction was selected"); return false;
|
||||||
|
@ -87,11 +87,6 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
return constructor(args);
|
return constructor(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void GetRealBlock(byte type, byte extType, Player p, ref DrawArgs cpos) {
|
|
||||||
cpos.type = type < 128 ? p.bindings[type] : type;
|
|
||||||
cpos.extType = extType;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected struct DrawArgs {
|
protected struct DrawArgs {
|
||||||
public DrawMode mode;
|
public DrawMode mode;
|
||||||
public byte type, extType;
|
public byte type, extType;
|
||||||
|
@ -207,8 +207,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
//Copy
|
//Copy
|
||||||
public CopyState CopyBuffer;
|
public CopyState CopyBuffer;
|
||||||
public int[] copyoffset = new int[3] { 0, 0, 0 };
|
public Vec3S32 copyoffset, copystart;
|
||||||
public ushort[] copystart = new ushort[3] { 0, 0, 0 };
|
|
||||||
|
|
||||||
// GlobalBlock
|
// GlobalBlock
|
||||||
internal int gbStep = 0, gbTargetId = 0;
|
internal int gbStep = 0, gbTargetId = 0;
|
||||||
|
@ -82,14 +82,7 @@ namespace MCGalaxy {
|
|||||||
|
|
||||||
lastClick.X = x; lastClick.Y = y; lastClick.Z = z;
|
lastClick.X = x; lastClick.Y = y; lastClick.Z = z;
|
||||||
if (Blockchange != null) {
|
if (Blockchange != null) {
|
||||||
if ( Blockchange.Method.ToString().IndexOf("AboutBlockchange") == -1 && !level.IsMuseum ) {
|
Blockchange(this, x, y, z, type, extType); return;
|
||||||
bP.flags |= 1;
|
|
||||||
if (level.UseBlockDB)
|
|
||||||
level.blockCache.Add(bP);
|
|
||||||
}
|
|
||||||
|
|
||||||
Blockchange(this, x, y, z, type, extType);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (PlayerBlockChange != null)
|
if (PlayerBlockChange != null)
|
||||||
PlayerBlockChange(this, x, y, z, type, extType);
|
PlayerBlockChange(this, x, y, z, type, extType);
|
||||||
|
@ -606,6 +606,7 @@ Next: continue;
|
|||||||
if (selIndex != selMarks.Length) return;
|
if (selIndex != selMarks.Length) return;
|
||||||
|
|
||||||
Blockchange = null;
|
Blockchange = null;
|
||||||
|
type = type < 128 ? p.bindings[type] : type;
|
||||||
bool canRepeat = selCallback(this, selMarks, selState, type, extType);
|
bool canRepeat = selCallback(this, selMarks, selState, type, extType);
|
||||||
if (canRepeat && staticCommands)
|
if (canRepeat && staticCommands)
|
||||||
MakeSelection(selIndex, selState, selCallback);
|
MakeSelection(selIndex, selState, selCallback);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user