Пример #1
0
        public byte GetSkyLightFromParent(IBlockContainer blockChild,
                                          Position child)
        {
            int x = ((Chunk)blockChild).X * Chunk.BlocksPerChunkSide + (int)child.X;
            int z = ((Chunk)blockChild).Z * Chunk.BlocksPerChunkSide + (int)child.Z;

            // Same region?
            if (x >= 0 && x < BlocksPerRegionSize &&
                z >= 0 && z < BlocksPerRegionSize)
            {
                return(GetSkyLight(new Position(x, child.Y, z)));
            }
            else
            {
                // Pass to parent
                return(_parent.GetSkyLightFromParent(this, new Position(x, child.Y, z)));
            }
        }
Пример #2
0
        public byte GetSkyLightFromParent(IBlockContainer block, Position child)
        {
            if (child == null)
            {
                throw new ArgumentNullException(nameof(child));
            }
            if (block == null)
            {
                throw new ArgumentNullException(nameof(block));
            }

            // Get total y
            int y = ((Section)block).Y * Section.SectionHeight + (int)child.Y;

            if (y >= World.MaxHeight)
            {
                return(World.DefaultSkyLight);
            }

            if (y < 0)
            {
                return(0);
            }

            // Which chunk?
            if (child.X >= 0 && child.X < BlocksPerChunkSide &&
                child.Z >= 0 && child.Z < BlocksPerChunkSide)
            {
                // Same chunk
                return(GetSkyLight(new Position(child.X, y, child.Z)));
            }
            else
            {
                return(Parent.GetSkyLightFromParent(this, new Position(child.X, y, child.Z)));
            }
        }
Пример #3
0
 public byte GetSkyLightFromParent(IBlockContainer child, Position pos)
 {
     return(IsInBounds(pos) ?
            GetSkyLight(pos)
         : _parent.GetSkyLightFromParent(this, pos));
 }