Esempio n. 1
0
        public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
        {
            int   cellValue = base.SubsystemTerrain.Terrain.GetCellValue(x, y, z);
            int   num       = Terrain.ExtractContents(cellValue);
            Block obj       = BlocksManager.Blocks[num];
            int   data      = Terrain.ExtractData(cellValue);

            if (obj is TrapdoorBlock)
            {
                int    rotation     = TrapdoorBlock.GetRotation(data);
                bool   upsideDown   = TrapdoorBlock.GetUpsideDown(data);
                bool   flag         = false;
                Point3 point        = CellFace.FaceToPoint3(rotation);
                int    cellContents = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y, z - point.Z);
                flag |= !BlocksManager.Blocks[cellContents].IsTransparent;
                if (upsideDown)
                {
                    int cellContents2 = base.SubsystemTerrain.Terrain.GetCellContents(x, y + 1, z);
                    flag |= !BlocksManager.Blocks[cellContents2].IsTransparent;
                    int cellContents3 = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y + 1, z - point.Z);
                    flag |= !BlocksManager.Blocks[cellContents3].IsTransparent;
                }
                else
                {
                    int cellContents4 = base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z);
                    flag |= !BlocksManager.Blocks[cellContents4].IsTransparent;
                    int cellContents5 = base.SubsystemTerrain.Terrain.GetCellContents(x - point.X, y - point.Y - 1, z - point.Z);
                    flag |= !BlocksManager.Blocks[cellContents5].IsTransparent;
                }
                if (!flag)
                {
                    base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false);
                }
            }
        }
        public bool IsCollapseSupportBlock(int value)
        {
            int num = Terrain.ExtractContents(value);

            if (num != 0)
            {
                int   data  = Terrain.ExtractData(value);
                Block block = BlocksManager.Blocks[num];
                if (block is TrapdoorBlock)
                {
                    if (TrapdoorBlock.GetUpsideDown(data))
                    {
                        return(!TrapdoorBlock.GetOpen(data));
                    }
                    return(false);
                }
                if (block.BlockIndex == 238)
                {
                    return(true);
                }
                if (block.IsFaceTransparent(base.SubsystemTerrain, 4, value))
                {
                    return(block is SoilBlock);
                }
                return(true);
            }
            return(false);
        }
        public static bool IsCollapseDestructibleBlock(int value)
        {
            int   num   = Terrain.ExtractContents(value);
            Block block = BlocksManager.Blocks[num];

            if (block is TrapdoorBlock)
            {
                int data = Terrain.ExtractData(value);
                if (TrapdoorBlock.GetUpsideDown(data) && TrapdoorBlock.GetOpen(data))
                {
                    return(false);
                }
            }
            else if (block is FluidBlock)
            {
                return(false);
            }
            return(true);
        }