Beispiel #1
0
 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());
 }
Beispiel #2
0
        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();
        }
Beispiel #3
0
 public void NotifyLoad(ChunkPos chunk)
 {
     lock (_chunkLoads)
     {
         _chunkLoads.Add(chunk);
     }
 }
Beispiel #4
0
 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);
 }
Beispiel #6
0
 public void NotifyImportantLoad(ChunkPos chunk)
 {
     _importantChunkLoads.Enqueue(chunk);
 }