Exemplo n.º 1
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward  = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num      = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2     = Vector3.Dot(forward, Vector3.UnitX);
            float   num3     = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4     = Vector3.Dot(forward, -Vector3.UnitX);
            int     rotation = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                rotation = 1;
            }
            bool isUpsideDown         = raycastResult.CellFace.Face == 5;
            int  data                 = Terrain.ExtractData(value);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, SetIsUpsideDown(SetRotation(data, rotation), isUpsideDown));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 2
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2    = Vector3.Dot(forward, Vector3.UnitX);
            float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
            int     data    = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                data = 0;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 1;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 2;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                data = 3;
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, 132), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 3
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int  rotation;
            bool upsideDown;

            if (raycastResult.CellFace.Face < 4)
            {
                rotation   = raycastResult.CellFace.Face;
                upsideDown = (raycastResult.HitPoint().Y - (float)raycastResult.CellFace.Y > 0.5f);
            }
            else
            {
                Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
                float   num     = Vector3.Dot(forward, Vector3.UnitZ);
                float   num2    = Vector3.Dot(forward, Vector3.UnitX);
                float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
                float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
                rotation   = ((num == MathUtils.Max(num, num2, num3, num4)) ? 2 : ((num2 == MathUtils.Max(num, num2, num3, num4)) ? 3 : ((num3 != MathUtils.Max(num, num2, num3, num4)) ? ((num4 == MathUtils.Max(num, num2, num3, num4)) ? 1 : 0) : 0)));
                upsideDown = (raycastResult.CellFace.Face == 5);
            }
            int data = SetOpen(SetRotation(SetUpsideDown(0, upsideDown), rotation), open: false);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 4
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int value2 = 0;

            if (raycastResult.CellFace.Face == 0)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 0);
            }
            if (raycastResult.CellFace.Face == 1)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 1);
            }
            if (raycastResult.CellFace.Face == 2)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 2);
            }
            if (raycastResult.CellFace.Face == 3)
            {
                value2 = Terrain.ReplaceData(Terrain.ReplaceContents(0, 121), 3);
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = value2;
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 5
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.CellFace = raycastResult.CellFace;
            result.Value    = Terrain.MakeBlockValue(209, 0, 3);
            return(result);
        }
Exemplo n.º 6
0
        public virtual BlockPlacementData GetDigValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, int toolValue, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = 0;
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 7
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), 0);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 8
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(139, 0, SetMountingFace(Terrain.ExtractData(value), raycastResult.CellFace.Face));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 9
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = ((raycastResult.CellFace.Face < 4) ? Terrain.MakeBlockValue(BlockIndex, 0, SetFace(0, raycastResult.CellFace.Face)) : 0);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 10
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int data = SetMountingFace(SetSpikesState(Terrain.ExtractData(value), spikesState: true), raycastResult.CellFace.Face);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(value, data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 11
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2    = Vector3.Dot(forward, Vector3.UnitX);
            float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
            int     num5    = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 1;
            }
            Point3 point       = CellFace.FaceToPoint3(raycastResult.CellFace.Face);
            int    num6        = raycastResult.CellFace.X + point.X;
            int    y           = raycastResult.CellFace.Y + point.Y;
            int    num7        = raycastResult.CellFace.Z + point.Z;
            bool   rightHanded = true;

            switch (num5)
            {
            case 0:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6 - 1, y, num7)].IsTransparent;
                break;

            case 1:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6, y, num7 + 1)].IsTransparent;
                break;

            case 2:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6 + 1, y, num7)].IsTransparent;
                break;

            case 3:
                rightHanded = BlocksManager.Blocks[subsystemTerrain.Terrain.GetCellContents(num6, y, num7 - 1)].IsTransparent;
                break;
            }
            int data = SetRightHanded(SetOpen(SetRotation(0, num5), open: false), rightHanded);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), data);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
        public override void OnItemPlaced(int x, int y, int z, ref BlockPlacementData placementData, int itemValue)
        {
            int id       = Terrain.ExtractData(itemValue);
            T   itemData = GetItemData(id);

            if (itemData != null)
            {
                m_blocksData[new Point3(x, y, z)] = (T)itemData.Copy();
            }
        }
Exemplo n.º 13
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            if (raycastResult.CellFace.Face < 4)
            {
                result.CellFace = raycastResult.CellFace;
                result.Value    = Terrain.MakeBlockValue(197, 0, SetFace(0, CellFace.OppositeFace(raycastResult.CellFace.Face)));
            }
            return(result);
        }
Exemplo n.º 14
0
        public override BlockPlacementData GetDigValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, int toolValue, TerrainRaycastResult raycastResult)
        {
            int wireFacesBitmask = GetWireFacesBitmask(value);

            wireFacesBitmask &= ~(1 << raycastResult.CollisionBoxIndex);
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = SetWireFacesBitmask(value, wireFacesBitmask);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 15
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            BlockPlacementData result = default(BlockPlacementData);

            result.CellFace = raycastResult.CellFace;
            if (raycastResult.CellFace.Face == 4)
            {
                switch (Terrain.ExtractData(value))
                {
                case 0:
                    result.Value = Terrain.MakeBlockValue(19, 0, TallGrassBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 1:
                    result.Value = Terrain.MakeBlockValue(20, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 2:
                    result.Value = Terrain.MakeBlockValue(24, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 3:
                    result.Value = Terrain.MakeBlockValue(25, 0, FlowerBlock.SetIsSmall(0, isSmall: true));
                    break;

                case 4:
                    result.Value = Terrain.MakeBlockValue(174, 0, RyeBlock.SetSize(RyeBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 5:
                    result.Value = Terrain.MakeBlockValue(174, 0, RyeBlock.SetSize(RyeBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 6:
                    result.Value = Terrain.MakeBlockValue(204, 0, CottonBlock.SetSize(CottonBlock.SetIsWild(0, isWild: false), 0));
                    break;

                case 7:
                    result.Value = Terrain.MakeBlockValue(131, 0, BasePumpkinBlock.SetSize(BasePumpkinBlock.SetIsDead(0, isDead: false), 0));
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 16
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward   = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num       = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2      = Vector3.Dot(forward, Vector3.UnitX);
            float   num3      = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4      = Vector3.Dot(forward, -Vector3.UnitX);
            float   num5      = Vector3.Dot(forward, Vector3.UnitY);
            float   num6      = Vector3.Dot(forward, -Vector3.UnitY);
            float   num7      = MathUtils.Min(MathUtils.Min(num, num2, num3), MathUtils.Min(num4, num5, num6));
            int     direction = 0;

            if (num == num7)
            {
                direction = 0;
            }
            else if (num2 == num7)
            {
                direction = 1;
            }
            else if (num3 == num7)
            {
                direction = 2;
            }
            else if (num4 == num7)
            {
                direction = 3;
            }
            else if (num5 == num7)
            {
                direction = 4;
            }
            else if (num6 == num7)
            {
                direction = 5;
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(216, 0, SetDirection(0, direction));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 17
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = float.NegativeInfinity;
            int     cutFace = 0;

            for (int i = 0; i < 6; i++)
            {
                float num2 = Vector3.Dot(CellFace.FaceToVector3(i), forward);
                if (num2 > num)
                {
                    num     = num2;
                    cutFace = i;
                }
            }
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.MakeBlockValue(BlockIndex, 0, SetCutFace(0, cutFace));
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 18
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            int rotation = 0;

            if (raycastResult.CellFace.Face < 4)
            {
                rotation = CellFace.OppositeFace(raycastResult.CellFace.Face);
            }
            else
            {
                Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
                float   num     = Vector3.Dot(forward, Vector3.UnitZ);
                float   num2    = Vector3.Dot(forward, Vector3.UnitX);
                float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
                float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
                if (num == MathUtils.Max(num, num2, num3, num4))
                {
                    rotation = 0;
                }
                else if (num2 == MathUtils.Max(num, num2, num3, num4))
                {
                    rotation = 1;
                }
                else if (num3 == MathUtils.Max(num, num2, num3, num4))
                {
                    rotation = 2;
                }
                else if (num4 == MathUtils.Max(num, num2, num3, num4))
                {
                    rotation = 3;
                }
            }
            int data = SetRotation(Terrain.ExtractData(value), rotation);
            BlockPlacementData result = default(BlockPlacementData);

            result.CellFace = raycastResult.CellFace;
            result.Value    = Terrain.ReplaceData(value, data);
            return(result);
        }
Exemplo n.º 19
0
        public bool Place(TerrainRaycastResult raycastResult, int value)
        {
            if (Place2 != null)
            {
                return(Place2(raycastResult, value));
            }

            int num = Terrain.ExtractContents(value);

            if (BlocksManager.Blocks[num].IsPlaceable)
            {
                Block block = BlocksManager.Blocks[num];
                BlockPlacementData placementData = block.GetPlacementValue(m_subsystemTerrain, this, value, raycastResult);
                if (placementData.Value != 0)
                {
                    Point3 point = CellFace.FaceToPoint3(placementData.CellFace.Face);
                    int    num2  = placementData.CellFace.X + point.X;
                    int    num3  = placementData.CellFace.Y + point.Y;
                    int    num4  = placementData.CellFace.Z + point.Z;
                    if (num3 > 0 && num3 < 255 && (IsBlockPlacingAllowed(ComponentCreature.ComponentBody) || m_subsystemGameInfo.WorldSettings.GameMode <= GameMode.Harmless))
                    {
                        bool flag = false;
                        if (block.IsCollidable)
                        {
                            BoundingBox boundingBox = ComponentCreature.ComponentBody.BoundingBox;
                            boundingBox.Min += new Vector3(0.2f);
                            boundingBox.Max -= new Vector3(0.2f);
                            BoundingBox[] customCollisionBoxes = block.GetCustomCollisionBoxes(m_subsystemTerrain, placementData.Value);
                            for (int i = 0; i < customCollisionBoxes.Length; i++)
                            {
                                BoundingBox box = customCollisionBoxes[i];
                                box.Min += new Vector3(num2, num3, num4);
                                box.Max += new Vector3(num2, num3, num4);
                                if (boundingBox.Intersection(box))
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        if (!flag)
                        {
                            SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(Terrain.ExtractContents(placementData.Value));
                            for (int i = 0; i < blockBehaviors.Length; i++)
                            {
                                blockBehaviors[i].OnItemPlaced(num2, num3, num4, ref placementData, value);
                            }
                            m_subsystemTerrain.DestroyCell(0, num2, num3, num4, placementData.Value, noDrop: false, noParticleSystem: false);
                            m_subsystemAudio.PlaySound("Audio/BlockPlaced", 1f, 0f, new Vector3(placementData.CellFace.X, placementData.CellFace.Y, placementData.CellFace.Z), 5f, autoDelay: false);
                            Poke(forceRestart: false);
                            if (ComponentCreature.PlayerStats != null)
                            {
                                ComponentCreature.PlayerStats.BlocksPlaced++;
                            }
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Exemplo n.º 20
0
        public bool Dig(TerrainRaycastResult raycastResult)
        {
            if (Dig1 != null)
            {
                return(Dig1(raycastResult));
            }

            bool result = false;

            m_lastDigFrameIndex = Time.FrameIndex;
            CellFace cellFace         = raycastResult.CellFace;
            int      cellValue        = m_subsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z);
            int      num              = Terrain.ExtractContents(cellValue);
            Block    block            = BlocksManager.Blocks[num];
            int      activeBlockValue = ActiveBlockValue;
            int      num2             = Terrain.ExtractContents(activeBlockValue);
            Block    block2           = BlocksManager.Blocks[num2];

            if (!DigCellFace.HasValue || DigCellFace.Value.X != cellFace.X || DigCellFace.Value.Y != cellFace.Y || DigCellFace.Value.Z != cellFace.Z)
            {
                m_digStartTime = m_subsystemTime.GameTime;
                DigCellFace    = cellFace;
            }
            float num3 = CalculateDigTime(cellValue, num2);

            m_digProgress = ((num3 > 0f) ? MathUtils.Saturate((float)(m_subsystemTime.GameTime - m_digStartTime) / num3) : 1f);
            if (!CanUseTool(activeBlockValue))
            {
                m_digProgress = 0f;
                if (m_subsystemTime.PeriodicGameTimeEvent(5.0, m_digStartTime + 1.0))
                {
                    ComponentPlayer?.ComponentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), block2.PlayerLevelRequired, block2.GetDisplayName(m_subsystemTerrain, activeBlockValue)), Color.White, blinking: true, playNotificationSound: true);
                }
            }
            bool flag = ComponentPlayer != null && !ComponentPlayer.ComponentInput.IsControlledByTouch && m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative;

            if (flag || (m_lastPokingPhase <= 0.5f && PokingPhase > 0.5f))
            {
                if (m_digProgress >= 1f)
                {
                    DigCellFace = null;
                    if (flag)
                    {
                        Poke(forceRestart: true);
                    }
                    BlockPlacementData digValue = block.GetDigValue(m_subsystemTerrain, this, cellValue, activeBlockValue, raycastResult);
                    m_subsystemTerrain.DestroyCell(block2.ToolLevel, digValue.CellFace.X, digValue.CellFace.Y, digValue.CellFace.Z, digValue.Value, noDrop: false, noParticleSystem: false);
                    m_subsystemSoundMaterials.PlayImpactSound(cellValue, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 2f);
                    DamageActiveTool(1);
                    if (ComponentCreature.PlayerStats != null)
                    {
                        ComponentCreature.PlayerStats.BlocksDug++;
                    }
                    result = true;
                }
                else
                {
                    m_subsystemSoundMaterials.PlayImpactSound(cellValue, new Vector3(cellFace.X, cellFace.Y, cellFace.Z), 1f);
                    BlockDebrisParticleSystem particleSystem = block.CreateDebrisParticleSystem(m_subsystemTerrain, raycastResult.HitPoint(0.1f), cellValue, 0.35f);
                    base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true).AddParticleSystem(particleSystem);
                }
            }
            return(result);
        }
Exemplo n.º 21
0
        public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
        {
            Vector3 forward = Matrix.CreateFromQuaternion(componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation).Forward;
            float   num     = Vector3.Dot(forward, Vector3.UnitZ);
            float   num2    = Vector3.Dot(forward, Vector3.UnitX);
            float   num3    = Vector3.Dot(forward, -Vector3.UnitZ);
            float   num4    = Vector3.Dot(forward, -Vector3.UnitX);
            int     num5    = 0;

            if (num == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 2;
            }
            else if (num2 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 3;
            }
            else if (num3 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 0;
            }
            else if (num4 == MathUtils.Max(num, num2, num3, num4))
            {
                num5 = 1;
            }
            Point3 point = CellFace.FaceToPoint3(raycastResult.CellFace.Face);
            int    num6  = raycastResult.CellFace.X + point.X;
            int    y     = raycastResult.CellFace.Y + point.Y;
            int    num7  = raycastResult.CellFace.Z + point.Z;
            int    num8  = 0;
            int    num9  = 0;

            switch (num5)
            {
            case 0:
                num8 = -1;
                break;

            case 1:
                num9 = 1;
                break;

            case 2:
                num8 = 1;
                break;

            default:
                num9 = -1;
                break;
            }
            int   cellValue           = subsystemTerrain.Terrain.GetCellValue(num6 + num8, y, num7 + num9);
            int   cellValue2          = subsystemTerrain.Terrain.GetCellValue(num6 - num8, y, num7 - num9);
            Block block               = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)];
            Block block2              = BlocksManager.Blocks[Terrain.ExtractContents(cellValue2)];
            int   data                = Terrain.ExtractData(cellValue);
            int   data2               = Terrain.ExtractData(cellValue2);
            bool  flag                = false;
            int   data3               = SetRightHanded(rightHanded: (block is FenceGateBlock && GetRotation(data) == num5) || ((!(block2 is FenceGateBlock) || GetRotation(data2) != num5) && !block.IsCollidable), data: SetOpen(SetRotation(Terrain.ExtractData(value), num5), open: false));
            BlockPlacementData result = default(BlockPlacementData);

            result.Value    = Terrain.ReplaceData(Terrain.ReplaceContents(0, BlockIndex), data3);
            result.CellFace = raycastResult.CellFace;
            return(result);
        }
Exemplo n.º 22
0
 public virtual void OnItemPlaced(int x, int y, int z, ref BlockPlacementData placementData, int itemValue)
 {
 }