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);
     }
 }
Exemple #3
0
        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();
        }
Exemple #4
0
 protected Chunk(ChunkPos pos, World world, short[,,] blockData) : this(pos, world)
 {
     ChunkBlocks = blockData;
     BuildChunkModel();
     NeedsSave = false;
 }
Exemple #5
0
 public IEnumerable <Chunk> GetNeighbourChunks(ChunkPos pos)
 {
     return(FaceSides.YPlane.Select(dir => World.GetChunk(pos + dir)));
 }
Exemple #6
0
 public bool AreNeighbourChunksGenerated(ChunkPos pos)
 {
     return(GetNeighbourChunks(pos).All(chunk => chunk != null && chunk.HasData));
 }
Exemple #7
0
 public bool Equals(ChunkPos other)
 {
     return(x == other.x && z == other.z);
 }
 public void NotifyImportantLoad(ChunkPos chunk)
 {
     _importantChunkLoads.Enqueue(chunk);
 }