예제 #1
0
        public RecipaediaScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/RecipaediaScreen");

            LoadContents(this, node);
            m_blocksList         = Children.Find <ListPanelWidget>("BlocksList");
            m_categoryLabel      = Children.Find <LabelWidget>("Category");
            m_prevCategoryButton = Children.Find <ButtonWidget>("PreviousCategory");
            m_nextCategoryButton = Children.Find <ButtonWidget>("NextCategory");
            m_detailsButton      = Children.Find <ButtonWidget>("DetailsButton");
            m_recipesButton      = Children.Find <ButtonWidget>("RecipesButton");
            m_categories.Add(null);
            m_categories.AddRange(BlocksManager.Categories);
            m_blocksList.ItemWidgetFactory = delegate(object item)
            {
                int             value = (int)item;
                int             num   = Terrain.ExtractContents(value);
                Block           block = BlocksManager.Blocks[num];
                XElement        node2 = ContentManager.Get <XElement>("Widgets/RecipaediaItem");
                ContainerWidget obj   = (ContainerWidget)Widget.LoadWidget(this, node2, null);
                obj.Children.Find <BlockIconWidget>("RecipaediaItem.Icon").Value = value;
                obj.Children.Find <LabelWidget>("RecipaediaItem.Text").Text      = block.GetDisplayName(null, value);
                obj.Children.Find <LabelWidget>("RecipaediaItem.Details").Text   = block.GetDescription(value);
                return(obj);
            };
            m_blocksList.ItemClicked += delegate(object item)
            {
                if (m_blocksList.SelectedItem == item && item is int)
                {
                    ScreensManager.SwitchScreen("RecipaediaDescription", item, m_blocksList.Items.Cast <int>().ToList());
                }
            };
        }
 public void UpdateWidgets()
 {
     m_dirty = false;
     if (m_recipe != null)
     {
         Block block = BlocksManager.Blocks[Terrain.ExtractContents(m_recipe.ResultValue)];
         m_nameWidget.Text             = block.GetDisplayName(null, m_recipe.ResultValue) + ((!string.IsNullOrEmpty(NameSuffix)) ? NameSuffix : string.Empty);
         m_descriptionWidget.Text      = m_recipe.Description;
         m_nameWidget.IsVisible        = true;
         m_descriptionWidget.IsVisible = true;
         foreach (CraftingRecipeSlotWidget child in m_gridWidget.Children)
         {
             Point2 widgetCell = m_gridWidget.GetWidgetCell(child);
             child.SetIngredient(m_recipe.Ingredients[widgetCell.X + widgetCell.Y * 3]);
         }
         m_resultWidget.SetResult(m_recipe.ResultValue, m_recipe.ResultCount);
         m_fireWidget.ParticlesPerSecond = 40f;
     }
     else
     {
         m_nameWidget.IsVisible        = false;
         m_descriptionWidget.IsVisible = false;
         foreach (CraftingRecipeSlotWidget child2 in m_gridWidget.Children)
         {
             child2.SetIngredient(null);
         }
         m_resultWidget.SetResult(0, 0);
         m_fireWidget.ParticlesPerSecond = 0f;
     }
 }
예제 #3
0
 public void UpdateBlockProperties()
 {
     if (m_index >= 0 && m_index < m_valuesList.Count)
     {
         int   value = m_valuesList[m_index];
         int   num   = Terrain.ExtractContents(value);
         Block block = BlocksManager.Blocks[num];
         m_blockIconWidget.Value      = value;
         m_nameWidget.Text            = block.GetDisplayName(null, value);
         m_descriptionWidget.Text     = block.GetDescription(value);
         m_propertyNames1Widget.Text  = string.Empty;
         m_propertyValues1Widget.Text = string.Empty;
         m_propertyNames2Widget.Text  = string.Empty;
         m_propertyValues2Widget.Text = string.Empty;
         Dictionary <string, string> blockProperties = GetBlockProperties(value);
         int num2 = 0;
         foreach (KeyValuePair <string, string> item in blockProperties)
         {
             if (num2 < blockProperties.Count - blockProperties.Count / 2)
             {
                 LabelWidget propertyNames1Widget = m_propertyNames1Widget;
                 propertyNames1Widget.Text = propertyNames1Widget.Text + item.Key + ":\n";
                 LabelWidget propertyValues1Widget = m_propertyValues1Widget;
                 propertyValues1Widget.Text = propertyValues1Widget.Text + item.Value + "\n";
             }
             else
             {
                 LabelWidget propertyNames2Widget = m_propertyNames2Widget;
                 propertyNames2Widget.Text = propertyNames2Widget.Text + item.Key + ":\n";
                 LabelWidget propertyValues2Widget = m_propertyValues2Widget;
                 propertyValues2Widget.Text = propertyValues2Widget.Text + item.Value + "\n";
             }
             num2++;
         }
     }
 }
예제 #4
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);
        }
예제 #5
0
        public bool Aim(Ray3 aim, AimState state)
        {
            int   num   = Terrain.ExtractContents(ActiveBlockValue);
            Block block = BlocksManager.Blocks[num];

            if (block.IsAimable)
            {
                if (!CanUseTool(ActiveBlockValue))
                {
                    ComponentPlayer?.ComponentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), block.PlayerLevelRequired, block.GetDisplayName(m_subsystemTerrain, ActiveBlockValue)), Color.White, blinking: true, playNotificationSound: true);
                    Poke(forceRestart: false);
                    return(true);
                }
                SubsystemBlockBehavior[] blockBehaviors = m_subsystemBlockBehaviors.GetBlockBehaviors(num);
                for (int i = 0; i < blockBehaviors.Length; i++)
                {
                    if (blockBehaviors[i].OnAim(aim, this, state))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #6
0
        public void Hit(ComponentBody componentBody, Vector3 hitPoint, Vector3 hitDirection)
        {
            if (Hit1 != null)
            {
                Hit1(componentBody, hitPoint, hitDirection); return;
            }
            if (!(m_subsystemTime.GameTime - m_lastHitTime > 0.6600000262260437))
            {
                return;
            }
            m_lastHitTime = m_subsystemTime.GameTime;
            Block block = BlocksManager.Blocks[Terrain.ExtractContents(ActiveBlockValue)];

            if (!CanUseTool(ActiveBlockValue))
            {
                ComponentPlayer?.ComponentGui.DisplaySmallMessage(string.Format(LanguageControl.Get(fName, 1), block.PlayerLevelRequired, block.GetDisplayName(m_subsystemTerrain, ActiveBlockValue)), Color.White, blinking: true, playNotificationSound: true);
                Poke(forceRestart: false);
                return;
            }
            float num  = 0f;
            float num2 = 1f;

            if (ActiveBlockValue != 0)
            {
                num  = block.GetMeleePower(ActiveBlockValue) * AttackPower * m_random.Float(0.8f, 1.2f);
                num2 = block.GetMeleeHitProbability(ActiveBlockValue);
            }
            else
            {
                num  = AttackPower * m_random.Float(0.8f, 1.2f);
                num2 = 0.66f;
            }
            bool flag;

            if (ComponentPlayer != null)
            {
                m_subsystemAudio.PlaySound("Audio/Swoosh", 1f, m_random.Float(-0.2f, 0.2f), componentBody.Position, 3f, autoDelay: false);
                flag = m_random.Bool(num2);
                num *= ComponentPlayer.ComponentLevel.StrengthFactor;
            }
            else
            {
                flag = true;
            }
            if (flag)
            {
                AttackBody(componentBody, ComponentCreature, hitPoint, hitDirection, num, isMeleeAttack: true);
                DamageActiveTool(1);
            }
            else if (ComponentCreature is ComponentPlayer)
            {
                HitValueParticleSystem particleSystem = new HitValueParticleSystem(hitPoint + 0.75f * hitDirection, 1f * hitDirection + ComponentCreature.ComponentBody.Velocity, Color.White, LanguageControl.Get(fName, 2));
                base.Project.FindSubsystem <SubsystemParticles>(throwOnError: true).AddParticleSystem(particleSystem);
            }
            if (ComponentCreature.PlayerStats != null)
            {
                ComponentCreature.PlayerStats.MeleeAttacks++;
                if (flag)
                {
                    ComponentCreature.PlayerStats.MeleeHits++;
                }
            }
            Poke(forceRestart: false);
        }
예제 #7
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);
        }
예제 #8
0
        public override void Update()
        {
            if (m_inventory == null || DragHostWidget == null)
            {
                return;
            }
            WidgetInput     input      = base.Input;
            ComponentPlayer viewPlayer = GetViewPlayer();
            int             slotValue  = m_inventory.GetSlotValue(m_slotIndex);
            int             num        = Terrain.ExtractContents(slotValue);
            Block           block      = BlocksManager.Blocks[num];

            if (m_componentPlayer != null)
            {
                m_blockIconWidget.DrawBlockEnvironmentData.InWorldMatrix = m_componentPlayer.ComponentBody.Matrix;
            }
            if (m_focus && !input.Press.HasValue)
            {
                m_focus = false;
            }
            else if (input.Tap.HasValue && HitTestGlobal(input.Tap.Value) == this)
            {
                m_focus = true;
            }
            if (input.SpecialClick.HasValue && HitTestGlobal(input.SpecialClick.Value.Start) == this && HitTestGlobal(input.SpecialClick.Value.End) == this)
            {
                IInventory inventory = null;
                foreach (InventorySlotWidget item in ((ContainerWidget)base.RootWidget).AllChildren.OfType <InventorySlotWidget>())
                {
                    if (item.m_inventory != null && item.m_inventory != m_inventory && item.Input == base.Input && item.IsEnabledGlobal && item.IsVisibleGlobal)
                    {
                        inventory = item.m_inventory;
                        break;
                    }
                }
                if (inventory != null)
                {
                    int num2 = ComponentInventoryBase.FindAcquireSlotForItem(inventory, slotValue);
                    if (num2 >= 0)
                    {
                        HandleMoveItem(m_inventory, m_slotIndex, inventory, num2, m_inventory.GetSlotCount(m_slotIndex));
                    }
                }
            }
            if (input.Click.HasValue && HitTestGlobal(input.Click.Value.Start) == this && HitTestGlobal(input.Click.Value.End) == this)
            {
                bool flag = false;
                if (viewPlayer != null)
                {
                    if (viewPlayer.ComponentInput.SplitSourceInventory == m_inventory && viewPlayer.ComponentInput.SplitSourceSlotIndex == m_slotIndex)
                    {
                        viewPlayer.ComponentInput.SetSplitSourceInventoryAndSlot(null, -1);
                        flag = true;
                    }
                    else if (viewPlayer.ComponentInput.SplitSourceInventory != null)
                    {
                        flag = HandleMoveItem(viewPlayer.ComponentInput.SplitSourceInventory, viewPlayer.ComponentInput.SplitSourceSlotIndex, m_inventory, m_slotIndex, 1);
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                    }
                }
                if (!flag && m_inventory.ActiveSlotIndex != m_slotIndex && m_slotIndex < 10)
                {
                    m_inventory.ActiveSlotIndex = m_slotIndex;
                    if (m_inventory.ActiveSlotIndex == m_slotIndex)
                    {
                        AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
                    }
                }
            }
            if (!m_focus || ProcessingOnly || viewPlayer == null)
            {
                return;
            }
            Vector2?hold = input.Hold;

            if (hold.HasValue && HitTestGlobal(hold.Value) == this && !DragHostWidget.IsDragInProgress && m_inventory.GetSlotCount(m_slotIndex) > 0 && (viewPlayer.ComponentInput.SplitSourceInventory != m_inventory || viewPlayer.ComponentInput.SplitSourceSlotIndex != m_slotIndex))
            {
                input.Clear();
                viewPlayer.ComponentInput.SetSplitSourceInventoryAndSlot(m_inventory, m_slotIndex);
                AudioManager.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f);
            }
            Vector2?drag = input.Drag;

            if (!drag.HasValue || HitTestGlobal(drag.Value) != this || DragHostWidget.IsDragInProgress)
            {
                return;
            }
            int slotCount = m_inventory.GetSlotCount(m_slotIndex);

            if (slotCount > 0)
            {
                DragMode dragMode = input.DragMode;
                if (viewPlayer.ComponentInput.SplitSourceInventory == m_inventory && viewPlayer.ComponentInput.SplitSourceSlotIndex == m_slotIndex)
                {
                    dragMode = DragMode.SingleItem;
                }
                int num3 = (dragMode != 0) ? 1 : slotCount;
                SubsystemTerrain subsystemTerrain = m_inventory.Project.FindSubsystem <SubsystemTerrain>();
                ContainerWidget  containerWidget  = (ContainerWidget)Widget.LoadWidget(null, ContentManager.Get <XElement>("Widgets/InventoryDragWidget"), null);
                containerWidget.Children.Find <BlockIconWidget>("InventoryDragWidget.Icon").Value = Terrain.ReplaceLight(slotValue, 15);
                containerWidget.Children.Find <BlockIconWidget>("InventoryDragWidget.Icon").DrawBlockEnvironmentData.SubsystemTerrain = subsystemTerrain;
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Name").Text       = block.GetDisplayName(subsystemTerrain, slotValue);
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Count").Text      = num3.ToString();
                containerWidget.Children.Find <LabelWidget>("InventoryDragWidget.Count").IsVisible = (!(m_inventory is ComponentCreativeInventory) && !(m_inventory is ComponentFurnitureInventory));
                DragHostWidget.BeginDrag(containerWidget, new InventoryDragData
                {
                    Inventory = m_inventory,
                    SlotIndex = m_slotIndex,
                    DragMode  = dragMode
                }, delegate
                {
                    m_dragMode = null;
                });
                m_dragMode = dragMode;
            }
        }
예제 #9
0
        public void Update(float dt)
        {
            if (componentPlayer == null)
            {
                return;
            }
            if (msginfobtn.IsClicked || componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.Tab))  //消息点击
            {
                if (messageInfo.IsVisible)
                {
                    messageInfo.alwaysShow = false;
                    messageInfo.IsVisible  = messageInfo.alwaysShow;
                }
                else
                {
                    messageInfo.alwaysShow = true;
                    messageInfo.IsVisible  = messageInfo.alwaysShow;
                }
            }
            if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.B))
            {
                if (jeiBehavior.xjJEIWidget == null)
                {
                    jeiBehavior.player      = componentPlayer;
                    jeiBehavior.xjJEIWidget = new XjJEIWidget(jeiBehavior);
                }
                if (componentPlayer.ComponentGui.ModalPanelWidget == null)
                {
                    componentPlayer.ComponentGui.ModalPanelWidget = jeiBehavior.xjJEIWidget;
                }
                else
                {
                    componentPlayer.ComponentGui.ModalPanelWidget = null;
                }
            }
            if (componentPlayer.ComponentHealth.DeathTime.HasValue)
            {
                foreach (SubsystemXjJeiBehavior.MarkFLag mark in SubsystemXjJeiBehavior.markFLags)
                {
                    if (mark.point == componentPlayer.ComponentBody.Position)
                    {
                        markaddflag = true; break;
                    }
                }
                if (!markaddflag)
                {
                    SubsystemXjJeiBehavior.MarkFLag markFLag = new SubsystemXjJeiBehavior.MarkFLag();
                    markFLag.point = componentPlayer.ComponentBody.Position;
                    markFLag.name  = "死亡地点";
                    markFLag.color = Color.Red;
                    SubsystemXjJeiBehavior.markFLags.Add(markFLag);
                    markaddflag = true;
                }
            }
            if (touch.IsPressed)
            {
                componentPlayer.ComponentLocomotion.JumpOrder = 1f;
                jump.Texture = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump_P").Texture;
            }
            else
            {
                jump.Texture = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump").Texture;
            }
            if (messageInfo.IsVisible)
            {
                if (messageInfo.inputpos > 0)
                {
                    if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.UpArrow))
                    {
                        if (messageInfo.inputpos - 1 < 0)
                        {
                            messageInfo.inputpos = messageInfo.inputcache.Count - 1;
                        }
                        else
                        {
                            messageInfo.inputpos -= 1;
                        }
                        messageInfo.inputtext.Text = messageInfo.inputcache[messageInfo.inputpos];
                    }
                    else if (componentPlayer.ViewWidget.Input.IsKeyDownOnce(Key.DownArrow))
                    {
                        if (messageInfo.inputpos + 1 > messageInfo.inputcache.Count - 1)
                        {
                            messageInfo.inputpos = 0;
                        }
                        else
                        {
                            messageInfo.inputpos += 1;
                        }
                        messageInfo.inputtext.Text = messageInfo.inputcache[messageInfo.inputpos];
                    }
                }
            }
            block = BlocksManager.Blocks[Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue)];
            if (block.Durability > 0)
            {
                disname = block.GetDisplayName(null, componentPlayer.ComponentMiner.ActiveBlockValue);
                if (XjJeiManager.is_NewSC && ModsManager.customer_Strings.ContainsKey(disname))
                {
                    disname = ModsManager.customer_Strings[disname];
                }
                int durty  = 0;
                int damage = block.GetDamage(componentPlayer.ComponentMiner.ActiveBlockValue);
                durty = (block.Durability - damage);
                moreInfo.setInfo(disname, durty, block.GetMeleePower(componentPlayer.ComponentMiner.ActiveBlockValue));
                moreInfo.bitmapWidget.Texture = moreInfo.texture;
            }
            else
            {
                moreInfo.naijiu.Text          = "";
                moreInfo.bitmapWidget.Texture = null;
                moreInfo.labelWidget.Text     = "";
            }
            moreInfo.setPosi(componentPlayer.ComponentBody.Position);
            moreInfo.setShow(SubsystemXjJeiBehavior.posi, SubsystemXjJeiBehavior.dura);
            if (!SubsystemXjJeiBehavior.run)
            {
                return;
            }
            if (componentPlayer.ComponentGui.ModalPanelWidget != null)
            {
                infoDialog.IsVisible = false; return;
            }
            //检测是否有方块
            Ray3 ray = new Ray3(componentPlayer.GameWidget.ActiveCamera.ViewPosition, componentPlayer.GameWidget.ActiveCamera.ViewDirection);

            terrainray = componentPlayer.ComponentMiner.Raycast <TerrainRaycastResult>(ray, RaycastMode.Interaction, true, true, false);
            foreach (KeyValuePair <ComponentCreature, bool> creature in creatureSpawn.m_creatures)
            {
                if (creature.Key == null)
                {
                    hasCreature = false; continue;
                }
                Vector3 creaturePosition = creature.Key.ComponentCreatureModel.EyePosition;
                Vector3 start            = ray.Position;
                Vector3 direction        = Vector3.Normalize(ray.Direction);
                Vector3 end = ray.Position + direction * 15f;
                //检测是否有生物
                if (creature.Key.ComponentBody.Position == componentPlayer.ComponentBody.Position)
                {
                    hasCreature = false; continue;
                }
                Raymm = ray.Intersection(creature.Key.ComponentBody.BoundingBox);
                if (Raymm.HasValue)
                {
                    if (Raymm.Value <= 10f)
                    {
                        infoDialog.setCreatureinfo(creature.Key);
                        hasCreature = true;
                        break;
                    }
                }
                else
                {
                    hasCreature = false;
                }
            }
            if (terrainray.HasValue && !hasCreature)
            {
                point = terrainray.Value.CellFace.Point;
                float disb = terrainray.Value.Distance;
                if (Raymm.HasValue && Raymm.Value <= disb)
                {
                    infoDialog.IsVisible = true;
                }
                else
                {
                    cellValue = terrainray.Value.Value;
                    if (Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue) != 0)
                    {
                        //装备的工具等级
                        block     = BlocksManager.Blocks[Terrain.ExtractContents(componentPlayer.ComponentMiner.ActiveBlockValue)];
                        toollevel = block.ToolLevel;
                        //hack为劈砍
                        //shovel为铲子
                        //quarry为镐子
                        //none为手
                    }
                    else
                    {
                        toollevel = 0;
                    }
                    block   = BlocksManager.Blocks[Terrain.ExtractContents(cellValue)];
                    disname = block.GetDisplayName(null, cellValue);
                    if (XjJeiManager.is_NewSC && ModsManager.customer_Strings.ContainsKey(disname))
                    {
                        disname = ModsManager.customer_Strings[disname];
                    }
                    ;
                    if (subsystemPlantBlock.HandledBlocks.Contains(Terrain.ExtractContents(cellValue)))
                    {
                        grow = Terrain.ExtractData(cellValue) & 7;
                        if (Terrain.ExtractContents(cellValue) == 174)
                        {
                            grow = (int)((((float)grow) / 7f) * 100);                                           //黑麦
                        }
                        else
                        {
                            grow = (int)(((7f - (float)grow) / 7f) * 100); //南瓜
                        }
                        infoDialog.setPlantInfo(disname, cellValue, grow);
                    }
                    else
                    {//不是作物
                        grow = 0;
                        dig  = block.RequiredToolLevel;
                        infoDialog.setBlockInfo($"{disname}", cellValue, dig, block.DigMethod, toollevel);
                    }
                    infoDialog.IsVisible = true;
                }
            }
            else
            {
                if (!hasCreature)
                {
                    infoDialog.IsVisible = false;
                }
                else
                {
                    infoDialog.IsVisible = true;
                }
            }
            infoDialog.setBottomWidget(moreInfo);
            infoDialog.setUpmode(SubsystemXjJeiBehavior.upmode);
        }
예제 #10
0
        public void Update(float dt)
        {
            PlayerInput playerInput = ComponentInput.PlayerInput;

            if (ComponentInput.IsControlledByTouch && m_aim.HasValue)
            {
                playerInput.Look = Vector2.Zero;
            }
            if (ComponentMiner.Inventory != null)
            {
                ComponentMiner.Inventory.ActiveSlotIndex += playerInput.ScrollInventory;
                if (playerInput.SelectInventorySlot.HasValue)
                {
                    ComponentMiner.Inventory.ActiveSlotIndex = MathUtils.Clamp(playerInput.SelectInventorySlot.Value, 0, 9);
                }
            }
            ComponentSteedBehavior componentSteedBehavior = null;
            ComponentBoat          componentBoat          = null;
            ComponentMount         mount = ComponentRider.Mount;

            if (mount != null)
            {
                componentSteedBehavior = mount.Entity.FindComponent <ComponentSteedBehavior>();
                componentBoat          = mount.Entity.FindComponent <ComponentBoat>();
            }
            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, base.ComponentBody.Position, 2f, autoDelay: false);
                    }
                    else
                    {
                        m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellFast", 0.75f, 0f, base.ComponentBody.Position, 2f, autoDelay: 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, base.ComponentBody.Position, 2f, autoDelay: false);
                    }
                    else
                    {
                        m_subsystemAudio.PlayRandomSound("Audio/Creatures/FemaleYellSlow", 0.75f, 0f, base.ComponentBody.Position, 2f, autoDelay: 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);
                base.ComponentLocomotion.LookOrder = new Vector2(playerInput.Look.X, 0f);
            }
            else if (componentBoat != null)
            {
                componentBoat.TurnOrder                   = playerInput.Move.X;
                componentBoat.MoveOrder                   = playerInput.Move.Z;
                base.ComponentLocomotion.LookOrder        = new Vector2(playerInput.Look.X, 0f);
                base.ComponentCreatureModel.RowLeftOrder  = (playerInput.Move.X <-0.2f || playerInput.Move.Z> 0.2f);
                base.ComponentCreatureModel.RowRightOrder = (playerInput.Move.X > 0.2f || playerInput.Move.Z > 0.2f);
            }
            else
            {
                base.ComponentLocomotion.WalkOrder = (base.ComponentBody.IsSneaking ? (0.66f * new Vector2(playerInput.SneakMove.X, playerInput.SneakMove.Z)) : new Vector2(playerInput.Move.X, playerInput.Move.Z));
                base.ComponentLocomotion.FlyOrder  = new Vector3(0f, playerInput.Move.Y, 0f);
                base.ComponentLocomotion.TurnOrder = playerInput.Look * new Vector2(1f, 0f);
                base.ComponentLocomotion.JumpOrder = MathUtils.Max(playerInput.Jump ? 1 : 0, base.ComponentLocomotion.JumpOrder);
            }
            base.ComponentLocomotion.LookOrder  += playerInput.Look * (SettingsManager.FlipVerticalAxis ? new Vector2(0f, -1f) : new Vector2(0f, 1f));
            base.ComponentLocomotion.VrLookOrder = playerInput.VrLook;
            base.ComponentLocomotion.VrMoveOrder = playerInput.VrMove;
            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)
            {
                if (!ComponentMiner.Use(playerInput.Interact.Value))
                {
                    TerrainRaycastResult?terrainRaycastResult = ComponentMiner.Raycast <TerrainRaycastResult>(playerInput.Interact.Value, RaycastMode.Interaction);
                    if (terrainRaycastResult.HasValue)
                    {
                        if (!ComponentMiner.Interact(terrainRaycastResult.Value))
                        {
                            if (ComponentMiner.Place(terrainRaycastResult.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) ? 0.1f : 1.4f;

            if (playerInput.Aim.HasValue && block.IsAimable && m_subsystemTime.GameTime - m_lastActionTime > (double)num2)
            {
                if (!m_isAimBlocked)
                {
                    Ray3    value  = playerInput.Aim.Value;
                    Vector3 vector = GameWidget.ActiveCamera.WorldToScreen(value.Position + value.Direction, Matrix.Identity);
                    Point2  size   = Window.Size;
                    if (ComponentInput.IsControlledByVr || (vector.X >= (float)size.X * 0.02f && vector.X < (float)size.X * 0.98f && vector.Y >= (float)size.Y * 0.02f && vector.Y < (float)size.Y * 0.98f))
                    {
                        m_aim = value;
                        if (ComponentMiner.Aim(value, AimState.InProgress))
                        {
                            ComponentMiner.Aim(m_aim.Value, AimState.Cancelled);
                            m_aim          = null;
                            m_isAimBlocked = true;
                        }
                        else if (!m_aimHintIssued && Time.PeriodicEvent(1.0, 0.0))
                        {
                            Time.QueueTimeDelayedExecution(Time.RealTime + 3.0, delegate
                            {
                                if (!m_aimHintIssued && m_aim.HasValue && !base.ComponentBody.IsSneaking)
                                {
                                    m_aimHintIssued = true;
                                    ComponentGui.DisplaySmallMessage(LanguageControl.Get(fName, 1), Color.White, blinking: true, playNotificationSound: true);
                                }
                            });
                        }
                    }
                    else if (m_aim.HasValue)
                    {
                        ComponentMiner.Aim(m_aim.Value, AimState.Cancelled);
                        m_aim          = null;
                        m_isAimBlocked = true;
                    }
                }
            }
            else
            {
                m_isAimBlocked = false;
                if (m_aim.HasValue)
                {
                    ComponentMiner.Aim(m_aim.Value, AimState.Completed);
                    m_aim            = null;
                    m_lastActionTime = m_subsystemTime.GameTime;
                }
            }
            flag |= m_aim.HasValue;
            if (playerInput.Hit.HasValue && !flag && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185)
            {
                BodyRaycastResult?bodyRaycastResult = ComponentMiner.Raycast <BodyRaycastResult>(playerInput.Hit.Value, RaycastMode.Interaction);
                if (bodyRaycastResult.HasValue)
                {
                    flag           = true;
                    m_isDigBlocked = true;
                    if (Vector3.Distance(bodyRaycastResult.Value.HitPoint(), base.ComponentCreatureModel.EyePosition) <= 2f)
                    {
                        ComponentMiner.Hit(bodyRaycastResult.Value.ComponentBody, bodyRaycastResult.Value.HitPoint(), playerInput.Hit.Value.Direction);
                    }
                }
            }
            if (playerInput.Dig.HasValue && !flag && !m_isDigBlocked && m_subsystemTime.GameTime - m_lastActionTime > 0.33000001311302185)
            {
                TerrainRaycastResult?terrainRaycastResult2 = ComponentMiner.Raycast <TerrainRaycastResult>(playerInput.Dig.Value, RaycastMode.Digging);
                if (terrainRaycastResult2.HasValue && ComponentMiner.Dig(terrainRaycastResult2.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 position = base.ComponentBody.Position + new Vector3(0f, base.ComponentBody.BoxSize.Y * 0.66f, 0f) + 0.25f * base.ComponentBody.Matrix.Forward;
                    Vector3 value2   = 8f * Matrix.CreateFromQuaternion(base.ComponentCreatureModel.EyeRotation).Forward;
                    m_subsystemPickables.AddPickable(slotValue, num3, position, value2, null);
                }
            }
            if (!playerInput.PickBlockType.HasValue || flag)
            {
                return;
            }
            ComponentCreativeInventory componentCreativeInventory = ComponentMiner.Inventory as ComponentCreativeInventory;

            if (componentCreativeInventory == null)
            {
                return;
            }
            TerrainRaycastResult?terrainRaycastResult3 = ComponentMiner.Raycast <TerrainRaycastResult>(playerInput.PickBlockType.Value, RaycastMode.Digging, raycastTerrain: true, raycastBodies: false, raycastMovingBlocks: false);

            if (!terrainRaycastResult3.HasValue)
            {
                return;
            }
            int value3 = terrainRaycastResult3.Value.Value;

            value3 = Terrain.ReplaceLight(value3, 0);
            int               num4           = Terrain.ExtractContents(value3);
            Block             block2         = BlocksManager.Blocks[num4];
            int               num5           = 0;
            IEnumerable <int> creativeValues = block2.GetCreativeValues();

            if (block2.GetCreativeValues().Contains(value3))
            {
                num5 = value3;
            }
            if (num5 == 0 && !block2.IsNonDuplicable)
            {
                List <BlockDropValue> list = new List <BlockDropValue>();
                block2.GetDropValues(m_subsystemTerrain, value3, 0, int.MaxValue, list, out bool _);
                if (list.Count > 0 && list[0].Count > 0)
                {
                    num5 = list[0].Value;
                }
            }
            if (num5 == 0)
            {
                num5 = creativeValues.FirstOrDefault();
            }
            if (num5 == 0)
            {
                return;
            }
            int num6 = -1;

            for (int i = 0; i < 10; i++)
            {
                if (componentCreativeInventory.GetSlotCapacity(i, num5) > 0 && componentCreativeInventory.GetSlotCount(i) > 0 && componentCreativeInventory.GetSlotValue(i) == num5)
                {
                    num6 = i;
                    break;
                }
            }
            if (num6 < 0)
            {
                for (int j = 0; j < 10; j++)
                {
                    if (componentCreativeInventory.GetSlotCapacity(j, num5) > 0 && (componentCreativeInventory.GetSlotCount(j) == 0 || componentCreativeInventory.GetSlotValue(j) == 0))
                    {
                        num6 = j;
                        break;
                    }
                }
            }
            if (num6 < 0)
            {
                num6 = componentCreativeInventory.ActiveSlotIndex;
            }
            componentCreativeInventory.RemoveSlotItems(num6, int.MaxValue);
            componentCreativeInventory.AddSlotItems(num6, num5, 1);
            componentCreativeInventory.ActiveSlotIndex = num6;
            ComponentGui.DisplaySmallMessage(block2.GetDisplayName(m_subsystemTerrain, value3), Color.White, blinking: false, playNotificationSound: false);
            m_subsystemAudio.PlaySound("Audio/UI/ButtonClick", 1f, 0f, 0f, 0f);
        }