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

            if (block is AttachedSignBlock)
            {
                Point3 point        = CellFace.FaceToPoint3(AttachedSignBlock.GetFace(data));
                int    x2           = x - point.X;
                int    y2           = y - point.Y;
                int    z2           = z - point.Z;
                int    cellContents = base.SubsystemTerrain.Terrain.GetCellContents(x2, y2, z2);
                if (!BlocksManager.Blocks[cellContents].IsCollidable)
                {
                    base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false);
                }
            }
            else if (block is PostedSignBlock)
            {
                int num2 = PostedSignBlock.GetHanging(data) ? base.SubsystemTerrain.Terrain.GetCellContents(x, y + 1, z) : base.SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z);
                if (!BlocksManager.Blocks[num2].IsCollidable)
                {
                    base.SubsystemTerrain.DestroyCell(0, x, y, z, 0, noDrop: false, noParticleSystem: false);
                }
            }
        }
Esempio n. 2
0
        public static bool IsBlockMovable(int value, int pistonFace, int y, out bool isEnd)
        {
            isEnd = false;
            int num  = Terrain.ExtractContents(value);
            int data = Terrain.ExtractData(value);

            switch (num)
            {
            case 27:
            case 45:
            case 64:
            case 65:
            case 216:
                return(false);

            case 227:
                return(true);

            case 237:
                return(!PistonBlock.GetIsExtended(data));

            case 238:
                return(false);

            case 131:
            case 132:
            case 244:
                return(false);

            case 127:
                return(false);

            case 126:
                return(false);

            case 1:
                return(y > 1);

            default:
            {
                Block block = BlocksManager.Blocks[num];
                if (block is BottomSuckerBlock)
                {
                    return(false);
                }
                if (block is MountedElectricElementBlock)
                {
                    isEnd = true;
                    return(((MountedElectricElementBlock)block).GetFace(value) == pistonFace);
                }
                if (block is DoorBlock || block is TrapdoorBlock)
                {
                    return(false);
                }
                if (block is LadderBlock)
                {
                    isEnd = true;
                    return(pistonFace == LadderBlock.GetFace(data));
                }
                if (block is AttachedSignBlock)
                {
                    isEnd = true;
                    return(pistonFace == AttachedSignBlock.GetFace(data));
                }
                if (block.IsNonDuplicable)
                {
                    return(false);
                }
                if (block.IsCollidable)
                {
                    return(true);
                }
                return(false);
            }
            }
        }