public override bool OnUse(Engine.Vector3 start, Engine.Vector3 direction, ComponentMiner componentMiner)
        {
            var bodyResult = componentMiner.PickBody(start, direction);

            if (bodyResult.HasValue)
            {
                var creature = bodyResult.Value.ComponentBody.Entity.FindComponent <ComponentCreature>();
                if (creature != null)
                {
                    string name = creature.DisplayName.Replace(' ', '_').ToLower();
                    ClipboardManager.ClipboardString = name;
                    componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage(name + "is copied to the clipboard", false, false);
                    return(false);
                }
            }

            var terrainResult = componentMiner.PickTerrainForDigging(start, direction);

            if (terrainResult.HasValue)
            {
                var val = terrainResult.Value.Value.ToString();
                ClipboardManager.ClipboardString = val;
                componentMiner.ComponentPlayer.ComponentGui.DisplaySmallMessage(val + "is copied to the clipboard", false, false);
            }
            return(false);
        }
        public override bool OnUse(Vector3 start, Vector3 direction, ComponentMiner componentMiner)
        {
            int               activeBlockValue = componentMiner.ActiveBlockValue;
            var               result           = componentMiner.PickTerrainForDigging(start, direction);
            Entity            entity;
            Vector3           position;
            BodyRaycastResult?body;

            if (activeBlockValue == ItemBlock.IdTable["Wrench"])
            {
                body = componentMiner.PickBody(start, direction);
                Matrix matrix = componentMiner.ComponentCreature.ComponentBody.Matrix;
                position = matrix.Translation + 1f * matrix.Forward + Vector3.UnitY;
                if (body.HasValue && (!result.HasValue || body.Value.Distance < result.Value.Distance))
                {
                    entity = body.Value.ComponentBody.Entity;
                    if (entity.FindComponent <ComponentTrain>() != null || entity.FindComponent <ComponentBoatI>() != null)
                    {
                        for (var i = entity.FindComponents <IInventory>().GetEnumerator(); i.MoveNext();)
                        {
                            i.Current.DropAllItems(position);
                        }
                        Utils.SubsystemPickables.AddPickable(ItemBlock.IdTable[entity.ValuesDictionary.DatabaseObject.Name.Length == 8 ? "Minecart" : entity.ValuesDictionary.DatabaseObject.Name], 1, position, null, null);
                        Project.RemoveEntity(entity, true);
                        return(true);
                    }
                }
            }
            else if ((activeBlockValue == ItemBlock.IdTable["Train"] || activeBlockValue == ItemBlock.IdTable["Minecart"]) && result.HasValue && Terrain.ExtractContents(result.Value.Value) == RailBlock.Index)
            {
                position = new Vector3(result.Value.CellFace.Point) + new Vector3(0.5f);
                entity   = DatabaseManager.CreateEntity(Project, activeBlockValue == ItemBlock.IdTable["Minecart"] ? "Carriage" : "Train", true);

                var rotation = componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation.ToForwardVector();
                entity.FindComponent <ComponentTrain>(true).SetDirection(RailBlock.IsDirectionX(RailBlock.GetRailType(Terrain.ExtractData(result.Value.Value)))
                                        ? rotation.Z < 0 ? 0 : 2
                                        : rotation.X < 0 ? 1 : 3);
                entity.FindComponent <ComponentBody>(true).Position       = position;
                entity.FindComponent <ComponentSpawn>(true).SpawnDuration = 0f;
                Project.AddEntity(entity);
                var componentTrain = entity.FindComponent <ComponentTrain>(true);
                if (activeBlockValue == ItemBlock.IdTable["Minecart"])
                {
                    componentTrain.Update(0);
                    var train = componentTrain.FindNearestTrain();
                    if (train != null)
                    {
                        componentTrain.ParentBody = train;
                    }
                }
                componentMiner.RemoveActiveTool(1);
                Utils.SubsystemAudio.PlaySound("Audio/BlockPlaced", 1f, 0f, position, 3f, true);
                return(true);
            }

            /*else if (activeBlockValue == ItemBlock.IdTable["Minecart"])
             * {
             *      entity = DatabaseManager.CreateEntity(Project, "Carriage", true);
             *      body = componentMiner.PickBody(start, direction);
             *      if (body.HasValue && (!result.HasValue || body.Value.Distance < result.Value.Distance))
             *      {
             *              body = componentMiner.PickBody(start, direction);
             *              var componentTrain = entity.FindComponent<ComponentTrain>(true);
             *              var train = body.Value.ComponentBody.Entity.FindComponent<ComponentTrain>();
             *              if (train != null)
             *                      componentTrain.ParentBody = train;
             *      }
             *      else if (result.HasValue)
             *              position = result.Value.RaycastStart + Vector3.Normalize(result.Value.RaycastEnd - result.Value.RaycastStart) * result.Value.Distance; ;
             *      var rotation = componentMiner.ComponentCreature.ComponentCreatureModel.EyeRotation.ToForwardVector();
             *      entity.FindComponent<ComponentTrain>(true).SetDirection(RailBlock.IsDirectionX(RailBlock.GetRailType(Terrain.ExtractData(result.Value.Value)))
             *              ? rotation.Z < 0 ? 0 : 2
             *              : rotation.X < 0 ? 1 : 3);
             *      goto put;
             * }*/
            else if (activeBlockValue == ItemBlock.IdTable["基因查看器"])
            {
                body = componentMiner.PickBody(start, direction);
                if (body.HasValue && (!result.HasValue || body.Value.Distance < result.Value.Distance))
                {
                    var cv = body.Value.ComponentBody.Entity.FindComponent <ComponentVariant>();
                    if (cv != null)
                    {
                        DialogsManager.ShowDialog(componentMiner.ComponentPlayer?.View.GameWidget, new MessageDialog("Result", cv.Genome.ToString(), "OK", null, null));
                    }
                    return(true);
                }
            }
            else if (result.HasValue)
            {
                position = result.Value.RaycastStart + Vector3.Normalize(result.Value.RaycastEnd - result.Value.RaycastStart) * result.Value.Distance;
                if (activeBlockValue == ItemBlock.IdTable["SteamBoat"])
                {
                    entity = DatabaseManager.CreateEntity(Project, "SteamBoat", true);
                    entity.FindComponent <ComponentFrame>(true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.UniformFloat(0f, 6.283185f));
                    goto put;
                }

                /*else if (activeBlockValue == ItemBlock.IdTable["Minecart"])
                 * {
                 *      entity = DatabaseManager.CreateEntity(Project, "Carriage", true);
                 *      entity.FindComponent<ComponentFrame>(true).Position = position;
                 *      entity.FindComponent<ComponentSpawn>(true).SpawnDuration = 0f;
                 *      var componentTrain = entity.FindComponent<ComponentTrain>(true);
                 *      var componentMount = componentTrain.FindNearestTrain();
                 *      if (componentMount != null)
                 *              componentTrain.ParentBody = componentMount.m_componentBody;
                 *      goto put;
                 * }*/
                else if (activeBlockValue == ItemBlock.IdTable["Airship"])
                {
                    entity = DatabaseManager.CreateEntity(Project, "Airship", true);
                    entity.FindComponent <ComponentFrame>(true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.UniformFloat(0f, 6.283185f));
                    goto put;
                }
                else if (BlocksManager.Blocks[Terrain.ExtractContents(activeBlockValue)] is ItemBlock itemblock && itemblock.GetItem(ref activeBlockValue) is Mine mine)
                {
                    entity = DatabaseManager.CreateEntity(Project, "Mine", new ValuesDictionary
                    {
                        { "Mine", new ValuesDictionary {
                              { "Type", mine.MineType }
                          } }
                    }, true);
                    entity.FindComponent <ComponentFrame>(true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, m_random.UniformFloat(0f, 6.283185f));
                    var componentMine = entity.FindComponent <ComponentMine>(true);
                    componentMine.ExplosionPressure = mine.ExplosionPressure;
                    componentMine.Delay             = mine.Delay;
                    goto put;
                }
            }
            IInventory           inventory = componentMiner.Inventory;
            TerrainRaycastResult?result2;

            if (Terrain.ExtractContents(activeBlockValue) == 90)
            {
                result2 = componentMiner.PickTerrainForGathering(start, direction);
                if (result2.HasValue)
                {
                    CellFace cellFace  = result2.Value.CellFace;
                    int      cellValue = Terrain.ReplaceLight(Utils.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z), 0);
                    if (cellValue != (RottenMeatBlock.Index | 1 << 4 << 14))
                    {
                        return(false);
                    }
                    inventory.RemoveSlotItems(inventory.ActiveSlotIndex, inventory.GetSlotCount(inventory.ActiveSlotIndex));
                    if (inventory.GetSlotCount(inventory.ActiveSlotIndex) == 0)
                    {
                        inventory.AddSlotItems(inventory.ActiveSlotIndex, RottenMeatBlock.Index | 2 << 4 << 14, 1);
                    }
                    Utils.SubsystemTerrain.DestroyCell(0, cellFace.X, cellFace.Y, cellFace.Z, 0, false, false);
                    return(true);
                }
            }
            if (activeBlockValue == (RottenMeatBlock.Index | 2 << 4 << 14))
            {
                result2 = componentMiner.PickTerrainForInteraction(start, direction);
                if (result2.HasValue && componentMiner.Place(result2.Value, RottenMeatBlock.Index | 1 << 4 << 14))
                {
                    inventory.RemoveSlotItems(inventory.ActiveSlotIndex, 1);
                    if (inventory.GetSlotCount(inventory.ActiveSlotIndex) == 0)
                    {
                        inventory.AddSlotItems(inventory.ActiveSlotIndex, Terrain.ReplaceContents(activeBlockValue, 90), 1);
                    }
                    return(true);
                }
            }
            return(false);

put:
            entity.FindComponent <ComponentBody>(true).Position       = position;
            entity.FindComponent <ComponentSpawn>(true).SpawnDuration = 0f;
            Project.AddEntity(entity);
            componentMiner.RemoveActiveTool(1);
            Utils.SubsystemAudio.PlaySound("Audio/BlockPlaced", 1f, 0f, position, 3f, true);
            return(true);
        }
Beispiel #3
0
        public new void Update(float dt)
        {
            PlayerInput playerInput = ComponentInput.PlayerInput;

            if (ComponentInput.IsControlledByTouch && m_aimDirection.HasValue)
            {
                playerInput.Look = Vector2.Zero;
            }
            if (ComponentMiner.Inventory != null)
            {
                ComponentMiner.Inventory.ActiveSlotIndex = MathUtils.Clamp(ComponentMiner.Inventory.ActiveSlotIndex + playerInput.ScrollInventory, 0, 5);
                if (playerInput.SelectInventorySlot.HasValue)
                {
                    ComponentMiner.Inventory.ActiveSlotIndex = MathUtils.Clamp(playerInput.SelectInventorySlot.Value, 0, 5);
                }
            }
            if (m_subsystemTime.PeriodicGameTimeEvent(0.5, 0))
            {
                ReadOnlyList <int> readOnlyList = ComponentClothing.GetClothes(ClothingSlot.Head);
                if ((readOnlyList.Count > 0 && ClothingBlock.GetClothingData(readOnlyList[readOnlyList.Count - 1]).DisplayName == Utils.Get("DZˮͷ¿ø")) || (ComponentBody.ImmersionFluidBlock != null && ComponentBody.ImmersionFluidBlock.BlockIndex == RottenMeatBlock.Index))
                {
                    //if (ComponentBody.ImmersionDepth > 0.8f)
                    //ComponentScreenOverlays.BlackoutFactor = 1f;
                    ComponentHealth.Air = 1f;
                }
            }
            ComponentMount mount = ComponentRider.Mount;

            if (mount != null)
            {
                var componentSteedBehavior = mount.Entity.FindComponent <ComponentSteedBehavior>();
                if (componentSteedBehavior != null)
                {
                    if (playerInput.Move.Z > 0.5f && !m_speedOrderBlocked)
                    {
                        if (PlayerData.PlayerClass == PlayerClass.Male)
                        {
                            m_subsystemAudio.PlayRandomSound("Audio/Creatures/MaleYellFast", 0.75f, 0f, ComponentBody.Position, 2f, false);
                        }
                        else
                        {
                            m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellFast", 0.75f, 0f, ComponentBody.Position, 2f, false);
                        }
                        componentSteedBehavior.SpeedOrder = 1;
                        m_speedOrderBlocked = true;
                    }
                    else if (playerInput.Move.Z < -0.5f && !m_speedOrderBlocked)
                    {
                        if (PlayerData.PlayerClass == PlayerClass.Male)
                        {
                            m_subsystemAudio.PlayRandomSound("Audio/Creatures/MaleYellSlow", 0.75f, 0f, ComponentBody.Position, 2f, false);
                        }
                        else
                        {
                            m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellSlow", 0.75f, 0f, ComponentBody.Position, 2f, false);
                        }
                        componentSteedBehavior.SpeedOrder = -1;
                        m_speedOrderBlocked = true;
                    }
                    else if (MathUtils.Abs(playerInput.Move.Z) <= 0.25f)
                    {
                        m_speedOrderBlocked = false;
                    }
                    componentSteedBehavior.TurnOrder = playerInput.Move.X;
                    componentSteedBehavior.JumpOrder = playerInput.Jump ? 1 : 0;
                    ComponentLocomotion.LookOrder    = new Vector2(playerInput.Look.X, 0f);
                }
                else
                {
                    var componentBoat = mount.Entity.FindComponent <ComponentBoat>();
                    if (componentBoat != null || mount.Entity.FindComponent <ComponentBoatI>() != null)
                    {
                        if (componentBoat != null)
                        {
                            componentBoat.TurnOrder       = playerInput.Move.X;
                            componentBoat.MoveOrder       = playerInput.Move.Z;
                            ComponentLocomotion.LookOrder = new Vector2(playerInput.Look.X, 0f);
                        }
                        else
                        {
                            ComponentLocomotion.LookOrder = playerInput.Look;
                        }
                        ComponentCreatureModel.RowLeftOrder  = playerInput.Move.X <-0.2f || playerInput.Move.Z> 0.2f;
                        ComponentCreatureModel.RowRightOrder = playerInput.Move.X > 0.2f || playerInput.Move.Z > 0.2f;
                    }
                    var c = mount.Entity.FindComponent <ComponentLocomotion>();
                    if (c != null)
                    {
                        c.WalkOrder = playerInput.Move.XZ;
                        c.FlyOrder  = new Vector3(0f, playerInput.Move.Y, 0f);
                        c.TurnOrder = playerInput.Look * new Vector2(1f, 0f);
                        c.JumpOrder = playerInput.Jump ? 1 : 0;
                        c.LookOrder = playerInput.Look;
                        if (playerInput.ToggleCreativeFly)
                        {
                            c.IsCreativeFlyEnabled = !c.IsCreativeFlyEnabled;
                        }
                    }
                }
            }
            else
            {
                ComponentLocomotion.WalkOrder = (ComponentLocomotion.WalkOrder ?? Vector2.Zero) + (ComponentBody.IsSneaking ? (0.66f * new Vector2(playerInput.SneakMove.X, playerInput.SneakMove.Z)) : new Vector2(playerInput.Move.X, playerInput.Move.Z));
                ComponentLocomotion.FlyOrder  = new Vector3(0f, playerInput.Move.Y, 0f);
                ComponentLocomotion.TurnOrder = playerInput.Look * new Vector2(1f, 0f);
                ComponentLocomotion.JumpOrder = MathUtils.Max(playerInput.Jump ? 1 : 0, ComponentLocomotion.JumpOrder);
            }
            ComponentLocomotion.LookOrder += playerInput.Look * (SettingsManager.FlipVerticalAxis ? new Vector2(0f, -1f) : new Vector2(0f, 1f));
            int   num   = Terrain.ExtractContents(ComponentMiner.ActiveBlockValue);
            Block block = BlocksManager.Blocks[num];
            bool  flag  = false;

            if (playerInput.Interact.HasValue && !flag && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185)
            {
                Vector3 viewPosition = View.ActiveCamera.ViewPosition;
                var     direction    = Vector3.Normalize(View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Interact.Value, 1f), Matrix.Identity) - viewPosition);
                if (!ComponentMiner.Use(viewPosition, direction))
                {
                    var body   = ComponentMiner.PickBody(viewPosition, direction);
                    var result = ComponentMiner.PickTerrainForInteraction(viewPosition, direction);
                    if (result.HasValue && (!body.HasValue || result.Value.Distance < body.Value.Distance))
                    {
                        if (!ComponentMiner.Interact(result.Value))
                        {
                            if (ComponentMiner.Place(result.Value))
                            {
                                m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate();
                                flag           = true;
                                m_isAimBlocked = true;
                            }
                        }
                        else
                        {
                            m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate();
                            flag           = true;
                            m_isAimBlocked = true;
                        }
                    }
                }
                else
                {
                    m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate();
                    flag           = true;
                    m_isAimBlocked = true;
                }
            }
            float   num2          = (m_subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative || block.BlockIndex == Musket2Block.Index) ? 0.1f : 1.4f;
            Vector3 viewPosition2 = View.ActiveCamera.ViewPosition;

            if (playerInput.Aim.HasValue && block.IsAimable && m_subsystemTime.GameTime - m_lastActionTime > num2)
            {
                if (!m_isAimBlocked)
                {
                    Vector2 value = playerInput.Aim.Value;
                    Vector3 v     = View.ActiveCamera.ScreenToWorld(new Vector3(value, 1f), Matrix.Identity);
                    Point2  size  = Window.Size;
                    if (playerInput.Aim.Value.X >= size.X * 0.1f && playerInput.Aim.Value.X < size.X * 0.9f && playerInput.Aim.Value.Y >= size.Y * 0.1f && playerInput.Aim.Value.Y < size.Y * 0.9f)
                    {
                        m_aimDirection = Vector3.Normalize(v - viewPosition2);
                        if (ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.InProgress))
                        {
                            ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Cancelled);
                            m_aimDirection = null;
                            m_isAimBlocked = true;
                        }
                    }
                    else if (m_aimDirection.HasValue)
                    {
                        ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Cancelled);
                        m_aimDirection = null;
                        m_isAimBlocked = true;
                    }
                }
            }
            else
            {
                m_isAimBlocked = false;
                if (m_aimDirection.HasValue)
                {
                    ComponentMiner.Aim(viewPosition2, m_aimDirection.Value, AimState.Completed);
                    m_aimDirection   = null;
                    m_lastActionTime = m_subsystemTime.GameTime;
                }
            }
            flag |= m_aimDirection.HasValue;
            if (playerInput.Hit.HasValue && !flag && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185)
            {
                Vector3 viewPosition3          = View.ActiveCamera.ViewPosition;
                var     vector                 = Vector3.Normalize(View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Hit.Value, 1f), Matrix.Identity) - viewPosition3);
                TerrainRaycastResult?nullable3 = ComponentMiner.PickTerrainForInteraction(viewPosition3, vector);
                BodyRaycastResult?   nullable4 = ComponentMiner.PickBody(viewPosition3, vector);
                if (nullable4.HasValue && (!nullable3.HasValue || nullable3.Value.Distance > nullable4.Value.Distance))
                {
                    if (ComponentMiner.ActiveBlockValue == 0)
                    {
                        Widget widget = ComponentNGui.OpenEntity(ComponentMiner.Inventory, nullable4.Value.ComponentBody.Entity);
                        if (widget != null)
                        {
                            ComponentGui.ModalPanelWidget = widget;
                            AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                            return;
                        }
                    }
                    flag           = true;
                    m_isDigBlocked = true;
                    if (Vector3.Distance(viewPosition3 + vector * nullable4.Value.Distance, ComponentCreatureModel.EyePosition) <= 2f)
                    {
                        ComponentMiner.Hit(nullable4.Value.ComponentBody, vector);
                    }
                }
            }
            if (playerInput.Dig.HasValue && !flag && !m_isDigBlocked && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185)
            {
                Vector3 viewPosition4          = View.ActiveCamera.ViewPosition;
                Vector3 v2                     = View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.Dig.Value, 1f), Matrix.Identity);
                TerrainRaycastResult?nullable5 = ComponentMiner.PickTerrainForDigging(viewPosition4, v2 - viewPosition4);
                if (nullable5.HasValue && ComponentMiner.Dig(nullable5.Value))
                {
                    m_lastActionTime = m_subsystemTime.GameTime;
                    m_subsystemTerrain.TerrainUpdater.RequestSynchronousUpdate();
                }
            }
            if (!playerInput.Dig.HasValue)
            {
                m_isDigBlocked = false;
            }
            if (playerInput.Drop && ComponentMiner.Inventory != null)
            {
                IInventory inventory = ComponentMiner.Inventory;
                int        slotValue = inventory.GetSlotValue(inventory.ActiveSlotIndex);
                int        num3      = inventory.RemoveSlotItems(count: inventory.GetSlotCount(inventory.ActiveSlotIndex), slotIndex: inventory.ActiveSlotIndex);
                if (slotValue != 0 && num3 != 0)
                {
                    Vector3 v3       = ComponentBody.Position + new Vector3(0f, ComponentBody.BoxSize.Y * 0.66f, 0f);
                    Matrix  matrix   = ComponentBody.Matrix;
                    Vector3 position = v3 + 0.25f * matrix.Forward;
                    matrix = Matrix.CreateFromQuaternion(ComponentCreatureModel.EyeRotation);
                    Vector3 value2 = 8f * matrix.Forward;
                    m_subsystemPickables.AddPickable(slotValue, num3, position, value2, null);
                }
            }
            if (playerInput.PickBlockType.HasValue && !flag)
            {
                if (ComponentMiner.Inventory is ComponentCreativeInventory componentCreativeInventory)
                {
                    Vector3 viewPosition5          = View.ActiveCamera.ViewPosition;
                    Vector3 v4                     = View.ActiveCamera.ScreenToWorld(new Vector3(playerInput.PickBlockType.Value, 1f), Matrix.Identity);
                    TerrainRaycastResult?nullable6 = ComponentMiner.PickTerrainForDigging(viewPosition5, v4 - viewPosition5);
                    if (nullable6.HasValue)
                    {
                        int value3 = nullable6.Value.Value;
                        value3 = Terrain.ReplaceLight(value3, 0);
                        int   num4           = Terrain.ExtractContents(value3);
                        Block block2         = BlocksManager.Blocks[num4];
                        int   num5           = 0;
                        var   creativeValues = block2.GetCreativeValues();
                        if (block2.GetCreativeValues().Contains(value3))
                        {
                            num5 = value3;
                        }
                        if (num5 == 0 && !block2.IsNonDuplicable)
                        {
                            var  list = new List <BlockDropValue>();
                            bool _;
                            block2.GetDropValues(m_subsystemTerrain, value3, 0, 2147483647, list, out _);
                            if (list.Count > 0 && list[0].Count > 0)
                            {
                                num5 = list[0].Value;
                            }
                        }
                        if (num5 == 0)
                        {
                            num5 = creativeValues.FirstOrDefault();
                        }
                        if (num5 != 0)
                        {
                            int num6 = -1;
                            for (int i = 0; i < 6; i++)
                            {
                                if (componentCreativeInventory.GetSlotCount(i) > 0 && componentCreativeInventory.GetSlotValue(i) == num5)
                                {
                                    num6 = i;
                                    break;
                                }
                            }
                            if (num6 < 0)
                            {
                                for (int j = 0; j < 6; j++)
                                {
                                    if (componentCreativeInventory.GetSlotCount(j) == 0 || componentCreativeInventory.GetSlotValue(j) == 0)
                                    {
                                        num6 = j;
                                        break;
                                    }
                                }
                            }
                            if (num6 < 0)
                            {
                                num6 = componentCreativeInventory.ActiveSlotIndex;
                            }
                            componentCreativeInventory.RemoveSlotItems(num6, 2147483647);
                            componentCreativeInventory.AddSlotItems(num6, num5, 1);
                            componentCreativeInventory.ActiveSlotIndex = num6;
                            ComponentGui.DisplaySmallMessage(block2.GetDisplayName(m_subsystemTerrain, value3), false, false);
                            m_subsystemAudio.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f, 0f);
                        }
                    }
                }
            }
            HighlightRaycastResult = ComponentMiner.PickTerrainForDigging(View.ActiveCamera.ViewPosition, View.ActiveCamera.ViewDirection);
        }