mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 14:54:12 -04:00
Initial brush support.
This commit is contained in:
parent
2b3a64d2e7
commit
91dcb6e8fb
@ -286,7 +286,7 @@ namespace MCGalaxy.Commands {
|
||||
foreach (string key in ckw.Keywords)
|
||||
{
|
||||
if (key == "" || key.IndexOf(word, comp) < 0) continue;
|
||||
if (!list.Contains(ckw.Cmd.name)) list.Add(ckw.Cmd.name);
|
||||
list.Add(ckw.Cmd.name); break;
|
||||
}
|
||||
return list.Count == 0 ? null : list.ToArray();
|
||||
}
|
||||
@ -300,6 +300,7 @@ namespace MCGalaxy.Commands {
|
||||
for (int i = 0; i < words.Length; i++) {
|
||||
if (key == "" || key.IndexOf(words[i], comp) < 0) continue;
|
||||
if (!list.Contains(ckw.Cmd.name)) list.Add(ckw.Cmd.name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list.Count == 0 ? null : list.ToArray();
|
||||
|
@ -50,7 +50,8 @@ namespace MCGalaxy.Commands
|
||||
brush = new RandomBrush(cpos.type, cpos.extType); break;
|
||||
}
|
||||
|
||||
if (brush == null) brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
if (brush == null) brush = GetBrush(p, cpos, 1);
|
||||
if (brush == null) return;
|
||||
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
|
||||
return;
|
||||
if (p.staticCommands)
|
||||
@ -58,13 +59,12 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
protected override SolidType GetType(string msg) {
|
||||
if (msg == "solid") return SolidType.solid;
|
||||
else if (msg == "hollow") return SolidType.hollow;
|
||||
if (msg == "hollow") return SolidType.hollow;
|
||||
else if (msg == "walls") return SolidType.walls;
|
||||
else if (msg == "holes") return SolidType.holes;
|
||||
else if (msg == "wire") return SolidType.wire;
|
||||
else if (msg == "random") return SolidType.random;
|
||||
return SolidType.Invalid;
|
||||
return SolidType.solid;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -29,13 +29,12 @@ namespace MCGalaxy.Commands {
|
||||
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
|
||||
|
||||
protected override SolidType GetType(string msg) {
|
||||
if (msg == "default") return SolidType.solid;
|
||||
else if (msg == "up") return SolidType.up;
|
||||
if (msg == "up") return SolidType.up;
|
||||
else if (msg == "down") return SolidType.down;
|
||||
else if (msg == "layer") return SolidType.layer;
|
||||
else if (msg == "vertical_x") return SolidType.verticalX;
|
||||
else if (msg == "vertical_z") return SolidType.verticalZ;
|
||||
return SolidType.Invalid;
|
||||
return SolidType.solid;
|
||||
}
|
||||
|
||||
protected override string PlaceMessage {
|
||||
@ -75,11 +74,12 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
FillDrawOp drawOp = new FillDrawOp();
|
||||
drawOp.Positions = buffer;
|
||||
Brush brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
Brush brush = GetBrush(p, cpos, 1);
|
||||
if (brush == null) return;
|
||||
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, cpos.x, cpos.y, cpos.z))
|
||||
return;
|
||||
bits.Clear();
|
||||
drawOp.Positions = null;
|
||||
drawOp.Positions = null;
|
||||
|
||||
if (p.staticCommands)
|
||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
|
||||
|
@ -27,9 +27,6 @@ namespace MCGalaxy.Commands {
|
||||
|
||||
public override string name { get { return "line"; } }
|
||||
public override string shortcut { get { return "l"; } }
|
||||
public CmdLine() {}
|
||||
|
||||
protected override int MaxArgs { get { return 3; } }
|
||||
|
||||
protected override SolidType GetType(string msg) {
|
||||
if (msg == "walls") return SolidType.walls;
|
||||
@ -38,11 +35,11 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
protected override void OnUse(Player p, string msg, string[] parts, ref CatchPos cpos) {
|
||||
if (parts.Length == 2 || parts.Length == 3) {
|
||||
if (parts.Length >= 2) {
|
||||
string arg = parts[parts.Length - 1];
|
||||
ushort len;
|
||||
if (!ushort.TryParse(arg, out len)) {
|
||||
if (arg == "walls" || arg == "straight" || arg == "normal") return;
|
||||
if (arg == "walls" || arg == "straight" || arg == "normal") return;
|
||||
Player.SendMessage(p, msg + " is not valid length, assuming maximum length allowed.");
|
||||
} else {
|
||||
cpos.data = len;
|
||||
@ -73,7 +70,8 @@ namespace MCGalaxy.Commands {
|
||||
drawOp.WallsMode = cpos.solid == SolidType.walls;
|
||||
if (cpos.data != null)
|
||||
drawOp.MaxLength = (ushort)cpos.data;
|
||||
Brush brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
Brush brush = GetBrush(p, cpos, cpos.data == null ? 1 : 2);
|
||||
if (brush == null) return;
|
||||
|
||||
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
|
||||
return;
|
||||
|
@ -32,7 +32,8 @@ namespace MCGalaxy.Commands
|
||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||
GetRealBlock(type, extType, p, ref cpos);
|
||||
DrawOp drawOp = null;
|
||||
Brush brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
Brush brush = GetBrush(p, cpos, 1);
|
||||
if (brush == null) return;
|
||||
|
||||
if (y != cpos.y) {
|
||||
Player.SendMessage(p, "The two edges of the pyramid must be on the same level");
|
||||
@ -55,10 +56,9 @@ namespace MCGalaxy.Commands
|
||||
}
|
||||
|
||||
protected override SolidType GetType(string msg) {
|
||||
if (msg == "solid") return SolidType.solid;
|
||||
else if (msg == "hollow") return SolidType.hollow;
|
||||
if (msg == "hollow") return SolidType.hollow;
|
||||
else if (msg == "reverse") return SolidType.reverse;
|
||||
return SolidType.Invalid;
|
||||
return SolidType.solid;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -32,7 +32,8 @@ namespace MCGalaxy.Commands {
|
||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||
GetRealBlock(type, extType, p, ref cpos);
|
||||
DrawOp drawOp = null;
|
||||
Brush brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
Brush brush = GetBrush(p, cpos, 1);
|
||||
if (brush == null) return;
|
||||
|
||||
switch (cpos.solid) {
|
||||
case SolidType.solid:
|
||||
@ -50,10 +51,9 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
protected override SolidType GetType(string msg) {
|
||||
if (msg == "solid") return SolidType.solid;
|
||||
else if (msg == "hollow") return SolidType.hollow;
|
||||
if (msg == "hollow") return SolidType.hollow;
|
||||
else if (msg == "vertical") return SolidType.vertical;
|
||||
return SolidType.Invalid;
|
||||
return SolidType.solid;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -32,7 +32,8 @@ namespace MCGalaxy.Commands {
|
||||
CatchPos cpos = (CatchPos)p.blockchangeObject;
|
||||
GetRealBlock(type, extType, p, ref cpos);
|
||||
DrawOp drawOp = new TorusDrawOp();
|
||||
Brush brush = new SolidBrush(cpos.type, cpos.extType);
|
||||
Brush brush = GetBrush(p, cpos, 0);
|
||||
if (brush == null) return;
|
||||
|
||||
if (!DrawOp.DoDrawOp(drawOp, brush, p, cpos.x, cpos.y, cpos.z, x, y, z))
|
||||
return;
|
||||
@ -45,7 +46,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
Player.SendMessage(p, "/torus [type] - create a radius of blocks.");
|
||||
Player.SendMessage(p, "/torus [block] - create a radius of blocks.");
|
||||
Player.SendMessage(p, "Radius of the tube is calculated based on " +
|
||||
"vertical difference between the two corners.");
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.Commands {
|
||||
@ -30,32 +31,8 @@ namespace MCGalaxy.Commands {
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
parts[i] = parts[i].ToLower();
|
||||
CatchPos cpos = default(CatchPos);
|
||||
|
||||
if (parts.Length > MaxArgs) {
|
||||
Help(p); return;
|
||||
} else if (parts.Length >= 2) {
|
||||
byte type = GetBlock(p, parts[0], out cpos.extType);
|
||||
if (type == Block.Zero) return;
|
||||
SolidType solid = GetType(parts[1]);
|
||||
if (solid == SolidType.Invalid) {
|
||||
Help(p); return;
|
||||
}
|
||||
cpos.solid = solid;
|
||||
cpos.type = type;
|
||||
} else if (message == "") {
|
||||
cpos.solid = SolidType.solid;
|
||||
cpos.type = 0xFF;
|
||||
} else if (parts.Length == 1) {
|
||||
byte type = 0xFF;
|
||||
SolidType solid = GetType(parts[0]);
|
||||
if (solid == SolidType.Invalid) {
|
||||
solid = SolidType.solid;
|
||||
type = GetBlock(p, parts[0], out cpos.extType);
|
||||
if (type == 255) return;
|
||||
}
|
||||
cpos.solid = solid;
|
||||
cpos.type = type;
|
||||
}
|
||||
cpos.message = message;
|
||||
cpos.solid = message == "" ? SolidType.solid : GetType(parts[parts.Length - 1]);
|
||||
OnUse(p, message, parts, ref cpos);
|
||||
p.blockchangeObject = cpos;
|
||||
|
||||
@ -76,8 +53,6 @@ namespace MCGalaxy.Commands {
|
||||
p.blockchangeObject = bp;
|
||||
p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
|
||||
}
|
||||
|
||||
protected virtual int MaxArgs { get { return 2; } }
|
||||
|
||||
protected virtual string PlaceMessage { get { return null; } }
|
||||
|
||||
@ -108,8 +83,21 @@ namespace MCGalaxy.Commands {
|
||||
return type;
|
||||
}
|
||||
|
||||
protected static Brush GetBrush(Player p, CatchPos cpos, int usedFromEnd) {
|
||||
int end = cpos.message.Length - 1;
|
||||
string brushMsg = "";
|
||||
for (int i = 0; i < usedFromEnd; i++) {
|
||||
end = cpos.message.LastIndexOf(' ', end);
|
||||
if (end == -1) break;
|
||||
}
|
||||
|
||||
if (end >= 0) brushMsg = cpos.message.Substring(0, end);
|
||||
var constructor = Brush.Brushes[p.BrushName];
|
||||
BrushArgs args = new BrushArgs(p, brushMsg, cpos.type, cpos.extType);
|
||||
return constructor(args);
|
||||
}
|
||||
|
||||
protected static void GetRealBlock(byte type, byte extType, Player p, ref CatchPos cpos) {
|
||||
if (cpos.type != Block.Zero) return;
|
||||
cpos.type = type < 128 ? p.bindings[type] : type;
|
||||
cpos.extType = extType;
|
||||
}
|
||||
@ -119,6 +107,7 @@ namespace MCGalaxy.Commands {
|
||||
public byte type, extType;
|
||||
public ushort x, y, z;
|
||||
public object data;
|
||||
public string message;
|
||||
}
|
||||
|
||||
protected enum SolidType {
|
||||
@ -126,7 +115,6 @@ namespace MCGalaxy.Commands {
|
||||
holes, wire, random,
|
||||
vertical, reverse, straight,
|
||||
up, down, layer, verticalX, verticalZ,
|
||||
Invalid = -1,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user