コード例 #1
0
        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);
        }
コード例 #2
0
 internal Chunk GetChunkAt(ChunkLocation Cl)
 {
     if (!Chunks.ContainsKey(Cl))
     {
         LoadRegion(Cl.regionLocation);                 //load the entire region
     }
     return(Chunks[Cl]);
 }
コード例 #3
0
ファイル: ChunkLocation.cs プロジェクト: namezis/DragonSpire
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            ChunkLocation CL = (ChunkLocation)obj;

            return(X == CL.X && Z == CL.Z);
        }
コード例 #4
0
ファイル: BlockLocation.cs プロジェクト: namezis/DragonSpire
        void CalculateAdditionalData()
        {
            int cx = (int)Math.Floor((double)_x / 16);             //Get the x/z in chunk coordinates, converting via math.floor to make sure were getting lower bounds
            int cz = (int)Math.Floor((double)_z / 16);

            //if (_x < 0) cx--; //If BL_X or BL_Z are negative then we need to go DOWN one more chunk (because 0 0 is a positive only chunk)
            //if (_z < 0) cz--;

            _chunkLocation  = _chunkLocation.MoveTo(cx, cz, world);            //Get the chunk based on the cx and cz variables defined above
            _playerLocation = _playerLocation.MoveTo(X, Y, Y, Z, true);
        }
コード例 #5
0
ファイル: Chunk.cs プロジェクト: namezis/DragonSpire
        /// <summary>
        /// Create a new instance of the Chunk class for storing ChunkSections (which store block data)
        /// </summary>
        /// <param name="World">The world in which this chunk exists</param>
        /// <param name="Point">The ChunkCoordinate of this Chunk</param>
        internal Chunk(World World, ChunkLocation CL)
        {
            this.World = World;
            this.CL    = CL;

            for (int i = 0; i < 16; i++)
            {
                ChunkParts[i] = new ChunkSection(i);
            }

            HeightMapGenerator.GenerateHeightMap(this);
        }
コード例 #6
0
ファイル: BlockLocation.cs プロジェクト: namezis/DragonSpire
        internal BlockLocation(int x, byte y, int z, World w)
        {
            _x     = x;
            _y     = y;
            _z     = z;
            _world = w;
            //_chunk = null;
            //_chunkSection = null;
            _chunkLocation  = new ChunkLocation(w);
            _playerLocation = new EntityLocation(w);

            CalculateAdditionalData();
        }
コード例 #7
0
ファイル: BlockLocation.cs プロジェクト: namezis/DragonSpire
        internal BlockLocation(World w)
        {
            _x     = 0;
            _y     = 0;
            _z     = 0;
            _world = w;
            //_chunk = null;
            //_chunkSection = null;
            _chunkLocation  = new ChunkLocation(w);
            _playerLocation = new EntityLocation(w);

            CalculateAdditionalData();
        }
コード例 #8
0
 //TODO redo this to check for generated chunks and only generate chunks that are not generated D:
 //Since we currently do not unload them this is fine, but when we DO unload them we want to
 //be able to reload them, not just generate new ones :)
 void LoadChunk(ChunkLocation l, bool Persistant)
 {
     if (!Chunks.ContainsKey(l))
     {
         Chunk chunk = new Chunk(world, l);
         chunk.isPersistant = Persistant;
         Generator.Generate(chunk);
         chunk.isLoaded = true;
         if (!Chunks.ContainsKey(l))
         {
             Chunks.Add(l, chunk);
         }
     }
 }
コード例 #9
0
ファイル: ChunkLocation.cs プロジェクト: namezis/DragonSpire
 public bool Equals(ChunkLocation CL)
 {
     return(X == CL.X && Z == CL.Z);
 }
コード例 #10
0
 void LoadRegionContainingChunk(ChunkLocation cl)
 {
     LoadRegion(cl.regionLocation);
 }
コード例 #11
0
 internal Chunk GetChunkAt(ChunkLocation CL)
 {
     return(chunkManager.GetChunkAt(CL));
 }