Beispiel #1
0
    public void OnDelete(int x, int y, int z)
    {
        switch (ID)
        {
        case BlockID.Water:
            if (Map.GetBlockSafe(x, y + 1, z).IsFluid())
            {
                Map.SetBlock(x, y, z, new Block(BlockID.Water, FluidSimulator.MaxFluidLevel));
                return;
            }
            else
            {
                FluidSimulator.RemoveFluidAndUnflow(x, y, z, this);
                break;
            }

        default:
            for (int i = 0; i < Vector3i.directions.Length; i++)
            {
                Vector3i dir = Vector3i.directions[i];

                int facing;

                Block block = Map.GetBlockSafe(x + dir.x, y + dir.y, z + dir.z);

                if (block.IsAttached(out facing))
                {
                    if (dir.GetNormalDirection() == facing)
                    {
                        Map.SetBlock(x + dir.x, y + dir.y, z + dir.z, new Block(BlockID.Air));
                    }
                }
            }

            FluidSimulator.TryFlowSurrounding(x, y, z);
            break;
        }
    }
Beispiel #2
0
    public bool CanPlace(Vector3i normal, int x, int y, int z)
    {
        switch (ID)
        {
        case BlockID.TallGrass:
            return(!Map.GetBlockSafe(x, y - 1, z).IsTransparent());

        case BlockID.Ladder:
            if (normal == Vector3i.up || normal == Vector3i.down)
            {
                return(false);
            }

            BlockDirection = Direction.GetOpposite(normal.GetNormalDirection());

            switch (BlockDirection)
            {
            case Direction.Left:
                return(Map.GetBlockSafe(x + 1, y, z).CanHaveAttachments());

            case Direction.Right:
                return(Map.GetBlockSafe(x - 1, y, z).CanHaveAttachments());

            case Direction.Front:
                return(Map.GetBlockSafe(x, y, z - 1).CanHaveAttachments());

            case Direction.Back:
                return(Map.GetBlockSafe(x, y, z + 1).CanHaveAttachments());

            default:
                return(false);
            }

        default:
            return(true);
        }
    }