public void CmdLmove(int bid, CoordinateDifference d1, CoordinateDifference d2) { if (!Bots.TryGetValue(bid, out var bot)) { throw new CommandException("lmove", "bot does not exist"); } bot.Position = Matrix.Get(bot.Position.X + d1.X + d2.X, bot.Position.Y + d1.Y + d2.Y, bot.Position.Z + d1.Z + d2.Z); }
public void CmdVoid(int bid, CoordinateDifference d) { if (!Bots.TryGetValue(bid, out var bot)) { throw new CommandException("void", "bot does not exist"); } Matrix.Get(bot.Position.X + d.X, bot.Position.Y + d.Y, bot.Position.Z + d.Z).Filled = false; }
private static CoordinateDifference[] GenerateNearDistances() { List <CoordinateDifference> nearDistances = new List <CoordinateDifference>(); for (sbyte x = -1; x <= 1; x++) { for (sbyte y = -1; y <= 1; y++) { for (sbyte z = -1; z <= 1; z++) { var d = new CoordinateDifference(x, y, z); if (d.IsNear) { nearDistances.Add(d); } } } } return(nearDistances.ToArray()); }
public void CalculateNearby(Voxel voxel) { var nearby = new List <Voxel>(); for (sbyte x = -1; x <= 1; x++) { for (sbyte y = -1; y <= 1; y++) { for (sbyte z = -1; z <= 1; z++) { var d = new CoordinateDifference(x, y, z); if (d.IsNear && ValidCoord(voxel.X + d.X, voxel.Y + d.Y, voxel.Z + d.Z)) { nearby.Add(Translate(voxel, d)); } } } } voxel.Nearby = nearby.ToArray(); }
public Voxel Translate(Voxel start, CoordinateDifference offset) { return(Get(start.X + offset.X, start.Y + offset.Y, start.Z + offset.Z)); }