internal List <Chunk> GetRegionChunks(RegionLocation RL) { List <Chunk> chunks = new List <Chunk>(); int x = RL.X * RegionSize; int z = RL.Z * RegionSize; var C = new ChunkLocation(x, z, world); if (C.regionLocation != RL) { Server.Log("Region location mismatch!", LogTypesEnum.Critical); } //else Server.Log("Region Location Checks out!", LogTypesEnum.System); int start_x = (x) - RegionSizeOffset; int start_z = (z) - RegionSizeOffset; int end_x = (x) + RegionSizeOffset; int end_z = (z) + RegionSizeOffset; for (int lx = start_x; lx <= end_x; lx++) { for (int lz = start_z; lz <= end_z; lz++) { var CL = new ChunkLocation(lx, lz, world); //Console.WriteLine("Adding Chunk: " + CL.ToString()); chunks.Add(GetChunkAt(CL)); } } return(chunks); }
public override bool Equals(object obj) { if (obj == null) { return(false); } RegionLocation RL = (RegionLocation)obj; return(X == RL.X && Z == RL.Z); }
internal List <ObjectEntity> GetRegionObjects(RegionLocation RL) { List <ObjectEntity> Objects = new List <ObjectEntity>(); foreach (Chunk c in GetRegionChunks(RL)) { Objects.AddRange(c.Objects.Values); } return(Objects); }
internal List <Mob> GetRegionMobs(RegionLocation RL) { List <Mob> Mobs = new List <Mob>(); foreach (Chunk c in GetRegionChunks(RL)) { Mobs.AddRange(c.Mobs.Values); } return(Mobs); }
internal List <Player> GetRegionPlayers(RegionLocation RL) { List <Player> Players = new List <Player>(); foreach (Chunk c in GetRegionChunks(RL)) { Players.AddRange(c.Players.Values); } return(Players); }
internal List <ObjectEntity> GetVisibleObjects(RegionLocation RL) { List <ObjectEntity> Objects = new List <ObjectEntity>(); for (int x = 0 - RegionViewDistanceOffset; x <= RegionViewDistanceOffset; x++) { for (int z = 0 - RegionViewDistanceOffset; z <= RegionViewDistanceOffset; z++) { int Loop_X = RL.X + x; int Loop_Z = RL.X + z; RegionLocation CRL = new RegionLocation(Loop_X, Loop_Z, world); foreach (Chunk c in GetRegionChunks(RL)) { Objects.AddRange(c.Objects.Values); } } } return(Objects); }
internal List <Mob> GetVisibleMobs(RegionLocation RL) { List <Mob> Mobs = new List <Mob>(); for (int x = 0 - RegionViewDistanceOffset; x <= RegionViewDistanceOffset; x++) { for (int z = 0 - RegionViewDistanceOffset; z <= RegionViewDistanceOffset; z++) { int Loop_X = RL.X + x; int Loop_Z = RL.X + z; RegionLocation CRL = new RegionLocation(Loop_X, Loop_Z, world); foreach (Chunk c in GetRegionChunks(RL)) { Mobs.AddRange(c.Mobs.Values); } } } return(Mobs); }
internal List <Player> GetVisiblePlayers(RegionLocation RL) { List <Player> Players = new List <Player>(); for (int x = 0 - RegionViewDistanceOffset; x <= RegionViewDistanceOffset; x++) { for (int z = 0 - RegionViewDistanceOffset; z <= RegionViewDistanceOffset; z++) { int Loop_X = RL.X + x; int Loop_Z = RL.Z + z; RegionLocation CRL = new RegionLocation(Loop_X, Loop_Z, world); foreach (Chunk c in GetRegionChunks(CRL)) { Players.AddRange(c.Players.Values); } } } return(Players); }
void LoadRegion(RegionLocation rl) { LoadRegion(rl.X, rl.Z); }