First stage of converting /draw into DrawOp classes.

This commit is contained in:
UnknownShadow200 2016-03-28 21:24:56 +11:00
parent a45b761358
commit 8bd1e6423d
8 changed files with 362 additions and 293 deletions

View File

@ -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 <shape> <height> <baseradius> - 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)");
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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);
}
}
}
}
}

View File

@ -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);
}
}
}
}

View File

@ -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) {

View File

@ -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 {
/// <summary> Properties of players that are relevant to zombie survival. </summary>
public class ZombieGameProps {
/// <summary> Whether this player is currently in referee mode. </summary>
public bool Referee = false;
/// <summary> Remaining number of blocks that can be manually placed this round. </summary>
internal int BlockCount = 50;
/// <summary> Number of blocks that have been sequentially vertically pillared. </summary>
public int BlocksStacked = 0;
internal int lastYblock = 0, lastXblock = 0, lastZblock = 0;
/// <summary> Whether this player is currently infected. </summary>
public bool Infected = false;
/// <summary> Whether the real name of players are always shown over zombie models. </summary>
public bool AkaMode = false;
public bool flipHead = false;
/// <summary> Total number of other players infected this round. </summary>
public int NumberInfected = 0;
internal string lastSpawnColor = "";
/// <summary> Whether either /like or /dislike has been in this round. </summary>
public bool RatedMap = false;
/// <summary> Whether used /pledge has been used in this round. </summary>
public bool PledgeSurvive = false;
/// <summary> List of custom infect messages. </summary>
public List<string> InfectMessages = null;
}
}

View File

@ -409,6 +409,9 @@
<Compile Include="Drawing\Brushes\SolidBrush.cs" />
<Compile Include="Drawing\Brushes\StripedBrush.cs" />
<Compile Include="Drawing\CopyState.cs" />
<Compile Include="Drawing\DrawOps\AdvConeDrawOps.cs" />
<Compile Include="Drawing\DrawOps\AdvDrawOps.cs" />
<Compile Include="Drawing\DrawOps\AdvPyramidDrawOps.cs" />
<Compile Include="Drawing\DrawOps\CuboidDrawOp.cs" />
<Compile Include="Drawing\DrawOps\DrawOp.cs" />
<Compile Include="Drawing\DrawOps\FillDrawOp.cs" />
@ -679,7 +682,6 @@
<Compile Include="Util\ICryptoService.cs" />
<Compile Include="Util\MathHelper.cs" />
<Compile Include="Util\MCForgeScripter.cs" />
<Compile Include="Util\SCOGenerator.cs" />
<Compile Include="Player\Player.CPE.cs" />
<Compile Include="Database\PlayerDB.cs" />
</ItemGroup>

View File

@ -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<Pos> buffer = new List<Pos>();
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<Pos> buffer = new List<Pos>();
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<Pos> buffer = new List<Pos>();
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<Pos> buffer = new List<Pos>();
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<Pos> 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<Pos> buffer = new List<Pos>();
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<Pos> buffer = new List<Pos>();
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<CatchPos> buffer = new List<CatchPos>();
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; }
}
}