Ejemplo 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);
                }
            }
        }
Ejemplo n.º 2
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int?color = GetColor(Terrain.ExtractData(value));
            BlockPlacementData result;

            if (raycastResult.CellFace.Face < 4)
            {
                int data = AttachedSignBlock.SetFace(AttachedSignBlock.SetColor(0, color), raycastResult.CellFace.Face);
                result          = default(BlockPlacementData);
                result.Value    = Terrain.MakeBlockValue(m_attachedSignBlockIndex, 0, data);
                result.CellFace = raycastResult.CellFace;
                return(result);
            }
            Vector3 forward   = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num       = float.MinValue;
            int     direction = 0;

            for (int i = 0; i < 8; i++)
            {
                float num2 = Vector3.Dot(forward, m_directions[i]);
                if (num2 > num)
                {
                    num       = num2;
                    direction = i;
                }
            }
            int data2 = SetHanging(SetDirection(SetColor(0, color), direction), raycastResult.CellFace.Face == 5);

            result          = default(BlockPlacementData);
            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, data2);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Ejemplo n.º 3
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);
            }
            }
        }