public Chunk(ChunkPos pos, World world) { Pos = pos; World = world; _loadManager = World.LoadManager; BoundingBox = new AxisAlignedBB(Vector3.Zero, Vector3.One * ChunkSize + Vector3.UnitY * 240).offset(Pos.ToVec()); }
public void UpdateLoad(EntityPlayerSP player, int renderDistance, bool important) { World world = SharpCraft.Instance.World; ChunkPos playerChunkPos = ChunkPos.FromWorldSpace(SharpCraft.Instance.Player.Pos); for (int z = -renderDistance; z <= renderDistance; z++) { for (int x = -renderDistance; x <= renderDistance; x++) { ChunkPos pos = new ChunkPos(playerChunkPos.x + x, playerChunkPos.z + z); if (pos.DistanceTo(player.Pos.Xz) < renderDistance * Chunk.ChunkSize) { if (world.GetChunk(pos) == null) { if (important) { NotifyImportantLoad(pos); } else { NotifyLoad(pos); } } } } } LoadChunks(); BuildChunks(); }
public void NotifyLoad(ChunkPos chunk) { lock (_chunkLoads) { _chunkLoads.Add(chunk); } }
public Chunk(ChunkPos pos, World world, short[,,] blockData) : this(pos, world) { _chunkBlocks = blockData; BuildChunkModel(); NeedsSave = false; }
public bool Equals(ChunkPos other) { return(x == other.x && z == other.z); }
public void NotifyImportantLoad(ChunkPos chunk) { _importantChunkLoads.Enqueue(chunk); }