mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Make /torus work like fcraft's one (Thanks SkinnyGamer), closes #133.
This commit is contained in:
parent
5c3cb9d16e
commit
2848d8f89c
@ -42,11 +42,6 @@ namespace MCGalaxy.Commands {
|
|||||||
RevertAndClearState(p, x, y, z);
|
RevertAndClearState(p, x, y, z);
|
||||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
GetRealBlock(type, extType, p, ref cpos);
|
||||||
|
|
||||||
int dx = cpos.x - x, dy = cpos.y - y, dz = cpos.z - z;
|
|
||||||
int radius = (int)Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
|
||||||
Vec3S32[] marks = { new Vec3S32(cpos.x - radius, cpos.y - radius, cpos.z - radius),
|
|
||||||
new Vec3S32(cpos.x + radius, cpos.y + radius, cpos.z + radius) };
|
|
||||||
|
|
||||||
DrawOp op = null;
|
DrawOp op = null;
|
||||||
Func<BrushArgs, Brush> constructor = null;
|
Func<BrushArgs, Brush> constructor = null;
|
||||||
@ -62,6 +57,11 @@ namespace MCGalaxy.Commands {
|
|||||||
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
int brushOffset = cpos.mode == DrawMode.normal ? 0 : 1;
|
||||||
Brush brush = GetBrush(p, cpos, brushOffset, constructor);
|
Brush brush = GetBrush(p, cpos, brushOffset, constructor);
|
||||||
if (brush == null) return;
|
if (brush == null) return;
|
||||||
|
|
||||||
|
int dx = cpos.x - x, dy = cpos.y - y, dz = cpos.z - z;
|
||||||
|
int R = (int)Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
|
Vec3S32[] marks = { new Vec3S32(cpos.x - R, cpos.y - R, cpos.z - R),
|
||||||
|
new Vec3S32(cpos.x + R, cpos.y + R, cpos.z + R) };
|
||||||
|
|
||||||
if (!DrawOp.DoDrawOp(op, brush, p, marks))
|
if (!DrawOp.DoDrawOp(op, brush, p, marks))
|
||||||
return;
|
return;
|
||||||
@ -71,7 +71,8 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/sphere [brush args] <mode>");
|
Player.Message(p, "%T/sphere [brush args] <mode>");
|
||||||
Player.Message(p, "%HCreates a sphere, using the first point as the centre, and the second point as the radius.");
|
Player.Message(p, "%HCreates a sphere, with the first point as the centre, " +
|
||||||
|
"and second being the radius.");
|
||||||
Player.Message(p, " %HFor help about brushes, type %T/help brush%H.");
|
Player.Message(p, " %HFor help about brushes, type %T/help brush%H.");
|
||||||
Player.Message(p, " %HModes: &fsolid/hollow");
|
Player.Message(p, " %HModes: &fsolid/hollow");
|
||||||
}
|
}
|
||||||
|
@ -26,33 +26,40 @@ namespace MCGalaxy.Commands {
|
|||||||
|
|
||||||
public override string name { get { return "torus"; } }
|
public override string name { get { return "torus"; } }
|
||||||
public override string shortcut { get { return "tor"; } }
|
public override string shortcut { get { return "tor"; } }
|
||||||
|
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||||
public override CommandAlias[] Aliases {
|
public override CommandAlias[] Aliases {
|
||||||
get { return new[] { new CommandAlias("donut"), new CommandAlias("bagel") }; }
|
get { return new[] { new CommandAlias("donut"), new CommandAlias("bagel") }; }
|
||||||
}
|
}
|
||||||
|
protected override string PlaceMessage { get { return "Place a block for the centre, then another for the radius."; } }
|
||||||
|
|
||||||
protected override void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
|
protected override void Blockchange2(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;
|
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||||
GetRealBlock(type, extType, p, ref cpos);
|
GetRealBlock(type, extType, p, ref cpos);
|
||||||
|
|
||||||
DrawOp drawOp = new TorusDrawOp();
|
DrawOp drawOp = new TorusDrawOp();
|
||||||
Brush brush = GetBrush(p, cpos, 0);
|
Brush brush = GetBrush(p, cpos, 0);
|
||||||
if (brush == null) return;
|
if (brush == null) return;
|
||||||
|
|
||||||
|
int dx = cpos.x - x, dy = cpos.y - y, dz = cpos.z - z;
|
||||||
|
int horR = (int)Math.Sqrt(dx * dx + dz * dz), verR = Math.Abs(dy);
|
||||||
|
Vec3S32[] marks = { new Vec3S32(cpos.x - horR, cpos.y - verR, cpos.z - horR),
|
||||||
|
new Vec3S32(cpos.x + horR, cpos.y + verR, cpos.z + horR) };
|
||||||
|
|
||||||
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
|
if (!DrawOp.DoDrawOp(drawOp, brush, p, marks))
|
||||||
return;
|
return;
|
||||||
if (p.staticCommands)
|
if (p.staticCommands)
|
||||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DrawMode ParseMode(string msg) {
|
protected override DrawMode ParseMode(string msg) { return DrawMode.normal; }
|
||||||
return DrawMode.normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Help(Player p) {
|
public override void Help(Player p) {
|
||||||
Player.Message(p, "%T/torus [brush args]");
|
Player.Message(p, "%T/torus [brush args]");
|
||||||
Player.Message(p, "%HDraws a torus(circular tube) between two points.");
|
Player.Message(p, "%HDraws a torus(circular tube), with the first point as the centre, " +
|
||||||
|
"and second being the radius.");
|
||||||
Player.Message(p, " %HFor help about brushes, type %T/help brush%H.");
|
Player.Message(p, " %HFor help about brushes, type %T/help brush%H.");
|
||||||
Player.Message(p, " %HNote: radius of tube itself is calculated based on " +
|
Player.Message(p, " %HNote: radius of the tube itself is the vertical difference between the two points.");
|
||||||
"vertical difference between the two corners.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user