static bool AddZoneCallback(Player p, Vec3S32[] marks, object state, BlockID block) { Vec3U16 p1 = (Vec3U16)marks[0], p2 = (Vec3U16)marks[1]; TWGame.TWZone zn = new TWGame.TWZone(p1, p2); List <TWGame.TWZone> zones = (List <TWGame.TWZone>)state; zones.Add(zn); p.Message("TNT Wars: Zone added!"); return(false); }
static bool AddZoneCallback(Player p, Vec3S32[] marks, object state, BlockID block) { Vec3U16 p1 = (Vec3U16)marks[0], p2 = (Vec3U16)marks[1]; TWGame.TWZone zn = new TWGame.TWZone(); zn.MinX = Math.Min(p1.X, p2.X); zn.MinY = Math.Min(p1.Y, p2.Y); zn.MinZ = Math.Min(p1.Z, p2.Z); zn.MaxX = Math.Max(p1.X, p2.X); zn.MaxY = Math.Max(p1.Y, p2.Y); zn.MaxZ = Math.Max(p1.Z, p2.Z); List <TWGame.TWZone> zones = (List <TWGame.TWZone>)state; zones.Add(zn); p.Message("TNT Wars: Zone added!"); return(false); }
static bool DeleteZoneCallback(Player p, Vec3S32[] marks, object state, BlockID block) { ushort x = (ushort)marks[0].X, y = (ushort)marks[0].Y, z = (ushort)marks[0].Z; List <TWGame.TWZone> zones = (List <TWGame.TWZone>)state; bool any = false; for (int i = zones.Count - 1; i >= 0; i--) { TWGame.TWZone zn = zones[i]; if (x >= zn.MinX && x <= zn.MaxX && y >= zn.MinY && y <= zn.MaxY && z >= zn.MinZ && z <= zn.MaxZ) { zones.RemoveAt(i); p.Message("TNT Wars: Zone deleted!"); any = true; } } if (!any) { p.Message("TNT Wars Error: You weren't in any zone"); } return(false); }