diff --git a/Commands/building/CmdDraw.cs b/Commands/building/CmdDraw.cs index 52f7eda9a..950f455b2 100644 --- a/Commands/building/CmdDraw.cs +++ b/Commands/building/CmdDraw.cs @@ -16,6 +16,10 @@ permissions and limitations under the Licenses. */ using System; +using MCGalaxy.Drawing; +using MCGalaxy.Drawing.Brushes; +using MCGalaxy.Drawing.Ops; + namespace MCGalaxy.Commands { public sealed class CmdDraw : Command @@ -120,64 +124,100 @@ namespace MCGalaxy.Commands return true; } - public void BlockchangeCone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeCone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Cone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); + Cone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); } - public void BlockchangeHCone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeHCone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.HCone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); + HCone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); } - public void BlockchangeICone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeICone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Cone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); + Cone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); } - public void BlockchangeHICone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeHICone(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.HCone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); + HCone(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); } - public void BlockchangePyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangePyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Pyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); + Pyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); } - public void BlockchangeHPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeHPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.HPyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); + HPyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, false); } - public void BlockchangeIPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeIPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Pyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); + Pyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); } - public void BlockchangeHIPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeHIPyramid(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.HPyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); + HPyramid(p, x, y, z, p.BcVar[0], p.BcVar[1], type, extType, true); } - public void BlockchangeSphere(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeSphere(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Sphere(p, x, y, z, p.BcVar[1], type, extType); + AdvSphereDrawOp op = new AdvSphereDrawOp(); + op.Radius = p.BcVar[1]; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); } - public void BlockchangeHSphere(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeHSphere(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.HSphere(p, x, y, z, p.BcVar[1], type, extType); + AdvHollowSphereDrawOp op = new AdvHollowSphereDrawOp(); + op.Radius = p.BcVar[1]; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); } - public void BlockchangeVolcano(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { + void BlockchangeVolcano(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { RevertAndClearState(p, x, y, z); - Util.SCOGenerator.Volcano(p, x, y, z, p.BcVar[0], p.BcVar[1]); + AdvVolcanoDrawOp op = new AdvVolcanoDrawOp(); + op.Radius = p.BcVar[1]; op.Height = p.BcVar[1]; + DrawOp.DoDrawOp(op, null, p, new [] { new Vec3U16(x, y, z) }); + } + + static void Cone(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { + AdvConeDrawOp op = new AdvConeDrawOp(); + op.Radius = radius; op.Height = height; op.Invert = invert; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); + } + + static void HCone(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { + AdvHollowConeDrawOp op = new AdvHollowConeDrawOp(); + op.Radius = radius; op.Height = height; op.Invert = invert; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); + } + + static void Pyramid(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { + AdvPyramidDrawOp op = new AdvPyramidDrawOp(); + op.Radius = radius; op.Height = height; op.Invert = invert; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); + } + + static void HPyramid(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { + AdvHollowPyramidDrawOp op = new AdvHollowPyramidDrawOp(); + op.Radius = radius; op.Height = height; op.Invert = invert; + Brush brush = new SolidBrush(type, extType); + DrawOp.DoDrawOp(op, brush, p, new [] { new Vec3U16(x, y, z) }); } public override void Help(Player p) { Player.SendMessage(p, "/draw - Draw an object in game- " + - "Valid Types cones, spheres, and pyramids, hspheres (hollow sphere), and hpyramids (hollow pyramid)"); + "Valid Types cones, spheres, and pyramids, hspheres (hollow sphere), and hpyramids (hollow pyramid)"); } } } diff --git a/Drawing/DrawOps/AdvConeDrawOps.cs b/Drawing/DrawOps/AdvConeDrawOps.cs new file mode 100644 index 000000000..1222dca5b --- /dev/null +++ b/Drawing/DrawOps/AdvConeDrawOps.cs @@ -0,0 +1,124 @@ +/* + Copyright 2011 MCForge + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +//StormCom Object Generator +// +//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction. +// +// ~Merlin33069 +using System; +using MCGalaxy.Drawing.Brushes; + +namespace MCGalaxy.Drawing.Ops { + + public class AdvConeDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Cone"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius, H = Height; + return (int)(Math.PI / 3 * (R * R * H)); + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + for (short yy = 0; yy <= Height; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curHeight = Invert ? yy : Height - yy; + if (curHeight == 0) continue; + int cx = P.X + xx, cy = P.Y + (Height - curHeight), cz = P.Z + zz; + + double curRadius = Radius * ((double)curHeight / (double)Height); + int dist = xx * xx + zz * zz; + if (dist > curRadius * curRadius) continue; + + byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); + if (ctile != 0) continue; + PlaceBlock(p, lvl, (ushort)cx, (ushort)cy, (ushort)cz, brush); + } + } + } + + public class AdvHollowConeDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Hollow Cone"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius, H = Height; + double outer = (int)(Math.PI / 3 * (R * R * H)); + double inner = (int)(Math.PI / 3 * ((R - 1) * (R - 1) * (H - 1))); + return (int)(outer - inner); + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + for (short yy = 0; yy <= Height; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curHeight = Invert ? yy : Height - yy; + if (curHeight == 0) continue; + int cx = P.X + xx, cy = P.Y + (Height - curHeight), cz = P.Z + zz; + + double curRadius = Radius * ((double)curHeight / (double)Height); + int dist = xx * xx + zz * zz; + if (dist > curRadius * curRadius || dist < (curRadius - 1) * (curRadius - 1)) + continue; + + byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); + if (ctile != 0) continue; + PlaceBlock(p, lvl, (ushort)cx, (ushort)cy, (ushort)cz, brush); + } + } + } + + public class AdvVolcanoDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Volcano"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius, H = Height; + double outer = (int)(Math.PI / 3 * (R * R * H)); + double inner = (int)(Math.PI / 3 * ((R - 1) * (R - 1) * (H - 1))); + return (int)(outer - inner); + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + for (short yy = 0; yy <= Height; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int cx = (P.X + xx), cy = (P.Y + yy), cz = (P.Z + zz); + int curHeight = Height - yy; + if (curHeight == 0) continue; + + double curRadius = Radius * ((double)curHeight / (double)Height); + int dist = xx * xx + zz * zz; + if (dist > curRadius * curRadius)continue; + + byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); + if (ctile != 0) continue; + bool layer = dist >= (curRadius - 1) * (curRadius - 1); + byte type = layer ? Block.grass : Block.lavastill; + PlaceBlock(p, lvl, (ushort)cx, (ushort)cy, (ushort)cz, type, 0); + } + } + } +} \ No newline at end of file diff --git a/Drawing/DrawOps/AdvDrawOps.cs b/Drawing/DrawOps/AdvDrawOps.cs new file mode 100644 index 000000000..6ad444f7f --- /dev/null +++ b/Drawing/DrawOps/AdvDrawOps.cs @@ -0,0 +1,82 @@ +/* + Copyright 2011 MCForge + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +//StormCom Object Generator +// +//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction. +// +// ~Merlin33069 +using System; +using MCGalaxy.Drawing.Brushes; + +namespace MCGalaxy.Drawing.Ops { + + public abstract class AdvDrawOp : DrawOp { + public int Radius, Height; + public bool Invert; + } + + public class AdvSphereDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Sphere"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius; + return (int)(Math.PI * 4.0 / 3.0 * (R * R * R)); + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + int upper = (Radius + 1) * (Radius + 1); + for (short yy = (short)-Radius; yy <= Radius; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curDist = xx * xx + yy * yy + zz * zz; + if (curDist < upper) + PlaceBlock(p, lvl, (ushort)(P.X + xx), (ushort)(P.Y + yy), (ushort)(P.Z + zz), brush); + } + } + } + + public class AdvHollowSphereDrawOp : DrawOp { + + public int Radius; + public override string Name { get { return "Adv Hollow Sphere"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius; + double outer = (int)(Math.PI * 4.0 / 3.0 * (R * R * R)); + double inner = (int)(Math.PI * 4.0 / 3.0 * ((R - 1) * (R - 1) * (R - 1))); + return (int)(outer - inner); + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + int upper = (Radius + 1) * (Radius + 1), inner = (Radius - 1) * (Radius - 1); + for (short yy = (short)-Radius; yy <= Radius; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curDist = xx * xx + yy * yy + zz * zz; + if (curDist < upper && curDist >= inner) { + PlaceBlock(p, lvl, (ushort)(P.X + xx), (ushort)(P.Y + yy), (ushort)(P.Z + zz), brush); + } + } + } + } +} \ No newline at end of file diff --git a/Drawing/DrawOps/AdvPyramidDrawOps.cs b/Drawing/DrawOps/AdvPyramidDrawOps.cs new file mode 100644 index 000000000..861490488 --- /dev/null +++ b/Drawing/DrawOps/AdvPyramidDrawOps.cs @@ -0,0 +1,89 @@ +/* + Copyright 2011 MCForge + + Dual-licensed under the Educational Community License, Version 2.0 and + the GNU General Public License, Version 3 (the "Licenses"); you may + not use this file except in compliance with the Licenses. You may + obtain a copy of the Licenses at + + http://www.opensource.org/licenses/ecl2.php + http://www.gnu.org/licenses/gpl-3.0.html + + Unless required by applicable law or agreed to in writing, + software distributed under the Licenses are distributed on an "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + or implied. See the Licenses for the specific language governing + permissions and limitations under the Licenses. + */ +//StormCom Object Generator +// +//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction. +// +// ~Merlin33069 +using System; +using MCGalaxy.Drawing.Brushes; + +namespace MCGalaxy.Drawing.Ops { + + public class AdvPyramidDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Pyramid"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius, H = Height; + return (R * R * H) / 3; + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + for (short yy = 0; yy <= Height; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curHeight = Invert ? yy : Height - yy; + if (curHeight == 0) continue; + int cx = P.X + xx, cy = P.Y + + (Height - curHeight), cz = P.Z + zz; + + double curRadius = Radius * ((double)curHeight / (double)Height); + if (Math.Abs(xx) > curRadius || Math.Abs(zz) > curRadius) + continue; + byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); + if (ctile != 0) continue; + PlaceBlock(p, lvl, (ushort)cx, (ushort)cy, (ushort)cz, brush); + } + } + } + + public class AdvHollowPyramidDrawOp : AdvDrawOp { + + public override string Name { get { return "Adv Hollow Pyramid"; } } + + public override int GetBlocksAffected(Level lvl, Vec3U16[] marks) { + int R = Radius, H = Height; + int outer = (R * R * H) / 3; + int inner = ((R - 1) * (R - 1) * (H - 1)) / 3; + return outer - inner; + } + + public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush) { + Vec3U16 P = marks[0]; + for (short yy = 0; yy <= Height; yy++) + for (short zz = (short)-Radius; zz <= Radius; zz++) + for (short xx = (short)-Radius; xx <= Radius; xx++) + { + int curHeight = Invert ? yy : Height - yy; + if (curHeight == 0) continue; + int cx = P.X + xx, cy = P.Y + (Height - curHeight), cz = P.Z + zz; + + double curRadius = Radius * ((double)curHeight / (double)Height); + int absx = Math.Abs(xx), absz = Math.Abs(zz); + if (absx > curRadius || absz > curRadius) continue; + if (absx < (curRadius - 1) && absz < (curRadius - 1)) continue; + + byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); + if (ctile != 0) continue; + PlaceBlock(p, lvl, (ushort)cx, (ushort)cy, (ushort)cz, brush); + } + } + } +} \ No newline at end of file diff --git a/Drawing/DrawOps/DrawOp.cs b/Drawing/DrawOps/DrawOp.cs index cc75bfed9..a19301b65 100644 --- a/Drawing/DrawOps/DrawOp.cs +++ b/Drawing/DrawOps/DrawOp.cs @@ -159,7 +159,7 @@ namespace MCGalaxy.Drawing.Ops { int affected = 0; if (!op.CanDraw(marks, p, out affected)) return false; - if (brush != null) { + if (brush != null && affected != -1) { const string format = "{0}({1}): affecting up to {2} blocks"; Player.SendMessage(p, String.Format(format, op.Name, brush.Name, affected)); } else if (affected != -1) { diff --git a/Games/ZombieSurvival/ZombieGameProps.cs b/Games/ZombieSurvival/ZombieGameProps.cs deleted file mode 100644 index d82651df8..000000000 --- a/Games/ZombieSurvival/ZombieGameProps.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright 2015 MCGalaxy - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -using System; -using System.Collections.Generic; - -namespace MCGalaxy.Games { - - /// Properties of players that are relevant to zombie survival. - public class ZombieGameProps { - - /// Whether this player is currently in referee mode. - public bool Referee = false; - - /// Remaining number of blocks that can be manually placed this round. - internal int BlockCount = 50; - - /// Number of blocks that have been sequentially vertically pillared. - public int BlocksStacked = 0; - internal int lastYblock = 0, lastXblock = 0, lastZblock = 0; - - /// Whether this player is currently infected. - public bool Infected = false; - - /// Whether the real name of players are always shown over zombie models. - public bool AkaMode = false; - public bool flipHead = false; - - /// Total number of other players infected this round. - public int NumberInfected = 0; - - internal string lastSpawnColor = ""; - - /// Whether either /like or /dislike has been in this round. - public bool RatedMap = false; - - /// Whether used /pledge has been used in this round. - public bool PledgeSurvive = false; - - /// List of custom infect messages. - public List InfectMessages = null; - } -} diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 04fc3140f..b60ae3dbd 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -409,6 +409,9 @@ + + + @@ -679,7 +682,6 @@ - diff --git a/util/SCOGenerator.cs b/util/SCOGenerator.cs deleted file mode 100644 index 9c6ae3f74..000000000 --- a/util/SCOGenerator.cs +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright 2011 MCForge - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -//StormCom Object Generator -// -//Full use to all StormCom Server System codes (in regards to minecraft classic) have been granted to MCGalaxy without restriction. -// -// ~Merlin33069 -using System; -using System.Collections.Generic; - -namespace MCGalaxy.Util { - - public sealed class SCOGenerator { - - public static void Cone(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = 0; yy <= height; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int cx = (x + xx), cy = (y + yy), cz = (z + zz); - int curHeight = invert ? yy : height - yy; - if (curHeight == 0) - continue; - double curRadius = radius * ((double)curHeight / (double)height); - int dist = xx * xx + zz * zz; - if (dist > curRadius * curRadius) - continue; - - byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); - if (ctile == 0) { - temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz; - buffer.Add(temp); - } - } - Draw(ref buffer, p, x, y, z, height, type, extType, invert); - } - - public static void HCone(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = 0; yy <= height; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int cx = (x + xx), cy = (y + yy), cz = (z + zz); - int curHeight = invert ? yy : height - yy; - if (curHeight == 0) - continue; - double curRadius = radius * ((double)curHeight / (double)height); - int dist = xx * xx + zz * zz; - if (dist > curRadius * curRadius || dist < (curRadius - 1) * (curRadius - 1)) - continue; - - byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); - if (ctile == 0) { - temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz; - buffer.Add(temp); - } - } - Draw(ref buffer, p, x, y, z, height, type, extType, invert); - } - - //For the pyramid commands, Radius still refers to the distance from the center point, but is axis independant, rather than a referance to both axes - public static void Pyramid(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = 0; yy <= height; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int cx = (x + xx), cy = (y + yy), cz = (z + zz); - int curHeight = invert ? yy : height - yy; - if (curHeight == 0) - continue; - double curRadius = radius * ((double)curHeight / (double)height); - if (Math.Abs(xx) > curRadius || Math.Abs(zz) > curRadius) - continue; - - byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); - if (ctile == 0){ - temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz; - buffer.Add(temp); - } - } - Draw(ref buffer, p, x, y, z, height, type, extType, invert); - } - - public static void HPyramid(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) { - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = 0; yy <= height; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int cx = (x + xx), cy = (y + yy), cz = (z + zz); - int curHeight = invert ? yy : height - yy; - if (curHeight == 0) - continue; - double curRadius = radius * ((double)curHeight / (double)height); - int absx = Math.Abs(xx), absz = Math.Abs(zz); - if (absx > curRadius || absz > curRadius) continue; - if (absx < (curRadius - 1) && absz < (curRadius - 1)) continue; - - byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); - if (ctile == 0) { - temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz; - buffer.Add(temp); - } - } - Draw(ref buffer, p, x, y, z, height, type, extType, invert); - } - - static void Draw(ref List buffer, Player p, ushort x, ushort y, ushort z, int height, byte type, byte extType, bool invert) { - if (buffer.Count > p.group.maxBlocks) { - Player.SendMessage(p, "You tried drawing " + buffer.Count + " blocks, your limit is " + p.group.maxBlocks); buffer = null; return; - } - buffer.ForEach(delegate(Pos pos) { p.level.UpdateBlock(p, pos.x, pos.y, pos.z, type, extType); }); - buffer = null; - if (invert) - p.level.UpdateBlock(p, x, y, z, type, extType); - else - p.level.UpdateBlock(p, x, (ushort)(y + height), z, type, extType); - } - - public static void Sphere(Player p, ushort x, ushort y, ushort z, int radius, byte type, byte extType) { - int upper = (radius + 1) * (radius + 1); - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = (short)-radius; yy <= radius; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int curDist = xx * xx + yy * yy + zz * zz; - if (curDist < upper) { - temp.x = (ushort)(x + xx); temp.y = (ushort)(y + yy); temp.z = (ushort)(z + zz); - buffer.Add(temp); - } - } - if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried Sphering " + buffer.Count + " blocks, your limit is " + p.group.maxBlocks); buffer = null; return; } - buffer.ForEach(delegate(Pos pos) { p.level.UpdateBlock(p, pos.x, pos.y, pos.z, type, extType); }); - buffer = null; - } - - public static void HSphere(Player p, ushort x, ushort y, ushort z, int radius, byte type, byte extType) { - int upper = (radius + 1) * (radius + 1), inner = (radius - 1) * (radius - 1); - List buffer = new List(); - Pos temp = new Pos(); - for (short yy = (short)-radius; yy <= radius; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int curDist = xx * xx + yy * yy + zz * zz; - if (curDist < upper && curDist >= inner) { - temp.x = (ushort)(x + xx); temp.y = (ushort)(y + yy); temp.z = (ushort)(z + zz); - buffer.Add(temp); - } - } - if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried HSphering " + buffer.Count + " blocks, your limit is " + p.group.maxBlocks); buffer = null; return; } - buffer.ForEach(delegate(Pos pos) { p.level.UpdateBlock(p, pos.x, pos.y, pos.z, type, extType); }); - buffer = null; - } - - public static void Volcano(Player p, ushort x, ushort y, ushort z, int height, int radius) { - List buffer = new List(); - CatchPos temp = new CatchPos(); - for (short yy = 0; yy <= height; yy++) - for (short zz = (short)-radius; zz <= radius; zz++) - for (short xx = (short)-radius; xx <= radius; xx++) - { - int cx = (x + xx), cy = (y + yy), cz = (z + zz); - int curHeight = height - yy; - if (curHeight == 0) - continue; - double curRadius = radius * ((double)curHeight / (double)height); - int dist = xx * xx + zz * zz; - if (dist > curRadius * curRadius) - continue; - - byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz); - if (ctile == 0) { - temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz; - bool layer = dist >= (curRadius - 1) * (curRadius - 1); - temp.type = layer ? Block.grass : Block.lavastill; - buffer.Add(temp); - } - } - if (buffer.Count > p.group.maxBlocks) { Player.SendMessage(p, "You tried Valcanoing " + buffer.Count + " blocks, your limit is " + p.group.maxBlocks); buffer = null; return; } - buffer.ForEach(delegate(CatchPos pos) { p.level.Blockchange(p, pos.x, pos.y, pos.z, pos.type); }); - buffer = null; - } - struct CatchPos { public ushort x, y, z; public byte type; } - struct Pos { public ushort x, y, z; } - } -} \ No newline at end of file