public void UpdateLoad(World world, Vector3 playerPos, int renderDistance, bool important) { ChunkPos playerChunkPos = ChunkPos.FromWorldSpace(playerPos); 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(playerPos.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); } }
protected 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()); //Load(); }
protected Chunk(ChunkPos pos, World world, short[,,] blockData) : this(pos, world) { ChunkBlocks = blockData; BuildChunkModel(); NeedsSave = false; }
public IEnumerable <Chunk> GetNeighbourChunks(ChunkPos pos) { return(FaceSides.YPlane.Select(dir => World.GetChunk(pos + dir))); }
public bool AreNeighbourChunksGenerated(ChunkPos pos) { return(GetNeighbourChunks(pos).All(chunk => chunk != null && chunk.HasData)); }
public bool Equals(ChunkPos other) { return(x == other.x && z == other.z); }
public void NotifyImportantLoad(ChunkPos chunk) { _importantChunkLoads.Enqueue(chunk); }