Пример #1
0
 public bool IsNeighborSolid(VoxelDirection direction)
 {
     Voxel neighbor = NeighborOrNull(direction);
     if (neighbor != null)
         return Voxel.IsSolid(neighbor);
     return false;
 }
Пример #2
0
 public Voxel NeighborOrNull(VoxelDirection direction)
 {
     IntVec3 neighborPosition = Position.Offset(VoxelDirectionOffsets.Offset[(int)direction]);
     if (VoxelWorld.Inst.IsVoxelWorldIndexValid(neighborPosition.X, neighborPosition.Y, neighborPosition.Z))
         return VoxelWorld.Inst.GetVoxel(neighborPosition);
     return null;
 }
Пример #3
0
        public override bool IsSolid(VoxelDirection direction)
        {
            switch (direction)
            {
            case VoxelDirection.Forward:
                return(this.forwardFace.IsSolid);

            case VoxelDirection.Back:
                return(this.backFace.IsSolid);

            case VoxelDirection.Right:
                return(this.rightFace.IsSolid);

            case VoxelDirection.Left:
                return(this.leftFace.IsSolid);

            case VoxelDirection.Up:
                return(this.upFace.IsSolid);

            case VoxelDirection.Down:
                return(this.downFace.IsSolid);

            default:
                throw new InvalidOperationException();
            }
        }
Пример #4
0
        public virtual void AddQuad(Vector3 position, int subMesh, VoxelDirection direction, Rect uv)
        {
            switch (direction)
            {
            case VoxelDirection.Forward:
                this.vertices.Add(position + Vector3.forward + Vector3.left);
                this.vertices.Add(position + Vector3.forward);
                this.vertices.Add(position + Vector3.forward + Vector3.left + Vector3.up);
                this.vertices.Add(position + Vector3.forward + Vector3.up);
                break;

            case VoxelDirection.Back:
                this.vertices.Add(position);
                this.vertices.Add(position + Vector3.left);
                this.vertices.Add(position + Vector3.up);
                this.vertices.Add(position + Vector3.left + Vector3.up);
                break;

            case VoxelDirection.Right:
                this.vertices.Add(position + Vector3.forward);
                this.vertices.Add(position);
                this.vertices.Add(position + Vector3.forward + Vector3.up);
                this.vertices.Add(position + Vector3.up);
                break;

            case VoxelDirection.Left:
                this.vertices.Add(position + Vector3.left);
                this.vertices.Add(position + Vector3.left + Vector3.forward);
                this.vertices.Add(position + Vector3.left + Vector3.up);
                this.vertices.Add(position + Vector3.left + Vector3.forward + Vector3.up);
                break;

            case VoxelDirection.Up:
                this.vertices.Add(position + Vector3.up);
                this.vertices.Add(position + Vector3.up + Vector3.left);
                this.vertices.Add(position + Vector3.up + Vector3.forward);
                this.vertices.Add(position + Vector3.up + Vector3.forward + Vector3.left);
                break;

            case VoxelDirection.Down:
                this.vertices.Add(position + Vector3.forward);
                this.vertices.Add(position + Vector3.forward + Vector3.left);
                this.vertices.Add(position);
                this.vertices.Add(position + Vector3.left);
                break;
            }
            this.triangles[subMesh].Add(this.vertices.Count - 4);
            this.triangles[subMesh].Add(this.vertices.Count - 3);
            this.triangles[subMesh].Add(this.vertices.Count - 2);
            this.triangles[subMesh].Add(this.vertices.Count - 3);
            this.triangles[subMesh].Add(this.vertices.Count - 1);
            this.triangles[subMesh].Add(this.vertices.Count - 2);
            this.uv.Add(new Vector2(uv.x + uv.width, uv.y));
            this.uv.Add(new Vector2(uv.x, uv.y));
            this.uv.Add(new Vector2(uv.x + uv.width, uv.y + uv.height));
            this.uv.Add(new Vector2(uv.x, uv.y + uv.height));
        }
Пример #5
0
    public bool IsNeighborSolid(VoxelDirection direction)
    {
        Voxel neighbor = NeighborOrNull(direction);

        if (neighbor != null)
        {
            return(Voxel.IsSolid(neighbor));
        }
        return(false);
    }
Пример #6
0
    public Voxel NeighborOrNull(VoxelDirection direction)
    {
        IntVec3 neighborPosition = Position.Offset(VoxelDirectionOffsets.Offset[(int)direction]);

        if (VoxelWorld.Inst.IsVoxelWorldIndexValid(neighborPosition.X, neighborPosition.Y, neighborPosition.Z))
        {
            return(VoxelWorld.Inst.GetVoxel(neighborPosition));
        }
        return(null);
    }
Пример #7
0
 public abstract bool IsSolid(VoxelDirection direction);
Пример #8
0
 public virtual void AddQuad(Vector3 position, VoxelDirection direction, Rect uv)
 {
     AddQuad(position, 0, direction, uv);
 }