コード例 #1
0
        private World2dRegion[,] GetNeighbourRegions()
        {
            var map     = _world.Regions2d;
            var regions = new World2dRegion[3, 3];

            for (var x = 0; x < 3; x++)
            {
                for (var z = 0; z < 3; z++)
                {
                    if (x == 1 && z == 1)
                    {
                        regions[x, z] = this;
                    }
                    else
                    {
                        var position = _position - 1 + new Vector2i(x, z);
                        if (map.TryGetValue(position, out var value))
                        {
                            regions[x, z] = value;
                        }
                    }
                }
            }

            return(regions);
        }
コード例 #2
0
ファイル: World.cs プロジェクト: gaeqs/CMine
        public World2dRegion GetOrCreate2dRegion(Vector2i regionPosition)
        {
            if (_regions2d.TryGetValue(regionPosition, out var value))
            {
                return(value);
            }

            var region = new World2dRegion(this, regionPosition);

            if (!region.Load())
            {
                region.CalculateBiomes();
                region.CalculateHeightsAndCreateSunlightData();
                region.CalculateInterpolatedHeightsAndColors();
            }
            else
            {
                Console.WriteLine("REGION " + regionPosition + " LOADED.");
            }

            _regions2d.TryAdd(regionPosition, region);


            return(region);
        }
コード例 #3
0
ファイル: SunlightData.cs プロジェクト: gaeqs/CMine
 public SunlightData(World2dRegion region, Vector2i position)
 {
     _region        = region;
     _worldPosition = position + (region.Position << World2dRegion.WorldPositionShift);
     _lightHeight   = new int[15];
     for (var i = 0; i < _lightHeight.Length; i++)
     {
         _lightHeight[i] = int.MinValue;
     }
 }
コード例 #4
0
        public ChunkRegion(World world, Vector3i position)
        {
            _world       = world;
            _position    = position;
            _chunks      = new Chunk[RegionChunkLength, RegionChunkLength, RegionChunkLength];
            _savedChunks = new Chunk[RegionChunkLength, RegionChunkLength, RegionChunkLength];
            _render      = new ChunkRegionRender(this);
            _deleted     = true;

            _world2dRegion = world.GetOrCreate2dRegion(new Vector2i(position.X, position.Z));
        }