Exemplo n.º 1
0
        /// <summary>
        /// Tells which cube is at this cube position
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        public TerraCubeResult GetCube(Vector3I pos)
        {
            var result = new TerraCubeResult();
            int cubeIndex;

            if (!IndexYSafe(pos.X, pos.Y, pos.Z, out cubeIndex))
            {
                return(result);
            }

            result.Cube    = Cubes[cubeIndex];
            result.IsValid = true;

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tells which cube is at this absolute position, takes into account the fact of non full size blocks
        /// </summary>
        /// <param name="pos"></param>
        /// <returns></returns>
        public TerraCubeResult GetCube(Vector3D pos, bool withYCheck = true)
        {
            TerraCubeResult result  = new TerraCubeResult();
            var             cubePos = pos.ToCubePosition();

            int cubeIndex;

            if (withYCheck)
            {
                if (!IndexYSafe(cubePos.X, cubePos.Y, cubePos.Z, out cubeIndex))
                {
                    return(result);
                }
            }
            else
            {
                cubeIndex = Index(cubePos.X, cubePos.Y, cubePos.Z);
            }

            result.Cube = Cubes[cubeIndex];

            var offset = _config.BlockProfiles[result.Cube.Id].YBlockOffset;

            if (offset != 0f && (1 - offset) <= (pos.Y % 1) + 0.001)
            {
                //I'm inside an offsetted block in the Air part, then send back the block above this one !
                cubePos.Y++;
                if (cubePos.Y < AbstractChunk.ChunkSize.Y)
                {
                    cubeIndex++; //Going Up one block
                    result.Cube = Cubes[cubeIndex];
                }
            }

            result.IsValid = true;
            return(result);
        }
Exemplo n.º 3
0
        public bool CheckCube(Vector3I pos, byte cubeId)
        {
            TerraCubeResult result = GetCube(pos);

            return(result.IsValid && result.Cube.Id == cubeId);
        }
Exemplo n.º 4
0
        public bool CheckCube(Vector3D pos, byte cubeId, bool withYCheck = true)
        {
            TerraCubeResult result = GetCube(pos, withYCheck);

            return(result.IsValid && result.Cube.Id == cubeId);
        }