public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
 {
     componentPlayer.ComponentGui.ModalPanelWidget = componentPlayer.ComponentGui.ModalPanelWidget == null ? new Musket2Widget(inventory, slotIndex) : null;
     return(true);
 }
Exemplo n.º 2
0
 public virtual bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
 {
     return(false);
 }
Exemplo n.º 3
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value1           = inventory.GetSlotValue(slotIndex);
            int count            = inventory.GetSlotCount(slotIndex);
            int id               = Terrain.ExtractData(value1);
            var commandBlockData = GetItemData(id);

            if (commandBlockData != null)
            {
                commandBlockData = (CommandData)commandBlockData.Copy();
            }
            else
            {
                commandBlockData = new CommandData();
            }
            DialogsManager.ShowDialog(componentPlayer.View.GameWidget, new TextBoxDialog("enter a one-line command", commandBlockData.Command, 300, delegate(string result)
            {
                commandBlockData.Command = result;
                var data  = StoreItemDataAtUniqueId(commandBlockData);
                var value = Terrain.ReplaceData(value1, data);
                inventory.RemoveSlotItems(slotIndex, count);
                inventory.AddSlotItems(slotIndex, value, 1);
            }));
            return(true);
        }
        public override bool OnAim(Vector3 start, Vector3 direction, ComponentMiner componentMiner, AimState state)
        {
            IInventory inventory = componentMiner.Inventory;

            if (inventory != null)
            {
                int activeSlotIndex = inventory.ActiveSlotIndex;
                if (activeSlotIndex >= 0)
                {
                    int slotValue = inventory.GetSlotValue(activeSlotIndex);
                    int slotCount = inventory.GetSlotCount(activeSlotIndex);
                    int num       = Terrain.ExtractContents(slotValue);
                    int data      = Terrain.ExtractData(slotValue);
                    int num2      = slotValue;
                    int num3      = 0;
                    if (num == Musket2Block.Index && slotCount > 0)
                    {
                        if (!m_aimStartTimes.TryGetValue(componentMiner, out double value))
                        {
                            value = m_subsystemTime.GameTime;
                            m_aimStartTimes[componentMiner] = value;
                        }
                        float   num4 = (float)(m_subsystemTime.GameTime - value);
                        float   num5 = (float)MathUtils.Remainder(m_subsystemTime.GameTime, 1000.0);
                        Vector3 v    = (float)((componentMiner.ComponentCreature.ComponentBody.IsSneaking ? 0.00999999977648258 : 0.0299999993294477) + 0.200000002980232 * MathUtils.Saturate((num4 - 6.5f) / 40f)) * new Vector3
                        {
                            X = SimplexNoise.OctavedNoise(num5, 2f, 3, 2f, 0.5f),
                            Y = SimplexNoise.OctavedNoise(num5 + 100f, 2f, 3, 2f, 0.5f),
                            Z = SimplexNoise.OctavedNoise(num5 + 200f, 2f, 3, 2f, 0.5f)
                        };
                        direction = Vector3.Normalize(direction + v);
                        switch (state)
                        {
                        case AimState.InProgress:
                        {
                            if (num4 >= 30f)
                            {
                                componentMiner.ComponentCreature.ComponentCreatureSounds.PlayMoanSound();
                                return(true);
                            }
                            if (num4 > 0.2f && !Musket2Block.GetHammerState(Terrain.ExtractData(num2)))
                            {
                                num2 = Terrain.MakeBlockValue(num, 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), true));
                                m_subsystemAudio.PlaySound("Audio/HammerCock", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f);
                            }
                            ComponentFirstPersonModel componentFirstPersonModel = componentMiner.Entity.FindComponent <ComponentFirstPersonModel>();
                            if (componentFirstPersonModel != null)
                            {
                                ComponentPlayer componentPlayer2 = componentMiner.ComponentPlayer;
                                if (componentPlayer2 != null)
                                {
                                    componentPlayer2.ComponentGui.ShowAimingSights(start, direction);
                                }
                                componentFirstPersonModel.ItemOffsetOrder   = new Vector3(-0.21f, 0.15f, 0.08f);
                                componentFirstPersonModel.ItemRotationOrder = new Vector3(-0.7f, 0f, 0f);
                            }
                            componentMiner.ComponentCreature.ComponentCreatureModel.AimHandAngleOrder       = 1.4f;
                            componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemOffsetOrder   = new Vector3(-0.08f, -0.08f, 0.07f);
                            componentMiner.ComponentCreature.ComponentCreatureModel.InHandItemRotationOrder = new Vector3(-1.7f, 0f, 0f);
                            break;
                        }

                        case AimState.Cancelled:
                            if (Musket2Block.GetHammerState(Terrain.ExtractData(num2)))
                            {
                                num2 = Terrain.MakeBlockValue(num, 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), false));
                                m_subsystemAudio.PlaySound("Audio/HammerUncock", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f);
                            }
                            m_aimStartTimes.Remove(componentMiner);
                            break;

                        case AimState.Completed:
                        {
                            bool    flag   = false;
                            int     value2 = 0;
                            int     num6   = 0;
                            float   s      = 0f;
                            Vector3 vector = Vector3.Zero;
                            Musket2Block.LoadState loadState = Musket2Block.GetLoadState(data);
                            if (Musket2Block.GetHammerState(Terrain.ExtractData(num2)))
                            {
                                switch (loadState)
                                {
                                case Musket2Block.LoadState.Gunpowder:
                                    flag   = true;
                                    value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.IronBullet));
                                    s      = 320f;
                                    num6   = 1;
                                    vector = new Vector3(0.01f, 0.01f, 0.05f);
                                    goto default;

                                default:
                                    if (loadState == Musket2Block.LoadState.Wad)
                                    {
                                        flag   = true;
                                        value2 = Terrain.MakeBlockValue(214, 0, BulletBlock.SetBulletType(0, BulletBlock.BulletType.IronBullet));
                                        s      = 320f;
                                        num6   = 1;
                                        vector = new Vector3(0.01f, 0.01f, 0.05f);
                                    }
                                    break;

                                case Musket2Block.LoadState.Empty:
                                {
                                    ComponentPlayer componentPlayer = componentMiner.ComponentPlayer;
                                    if (componentPlayer != null)
                                    {
                                        componentPlayer.ComponentGui.DisplaySmallMessage("Load bullet first", true, false);
                                    }
                                    break;
                                }
                                }
                            }
                            if (flag)
                            {
                                if (componentMiner.ComponentCreature.ComponentBody.ImmersionFactor > 0.4f)
                                {
                                    m_subsystemAudio.PlaySound("Audio/MusketMisfire", 1f, m_random.UniformFloat(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 3f, true);
                                }
                                else
                                {
                                    Vector3 eyePosition = componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition;
                                    Matrix  matrix      = componentMiner.ComponentCreature.ComponentBody.Matrix;
                                    Vector3 v2          = eyePosition + matrix.Right * 0.3f;
                                    matrix = componentMiner.ComponentCreature.ComponentBody.Matrix;
                                    Vector3 vector2 = v2 - matrix.Up * 0.2f;
                                    var     vector3 = Vector3.Normalize(vector2 + direction * 10f - vector2);
                                    var     vector4 = Vector3.Normalize(Vector3.Cross(vector3, Vector3.UnitY));
                                    var     v3      = Vector3.Normalize(Vector3.Cross(vector3, vector4));
                                    for (int i = 0; i < num6; i++)
                                    {
                                        Vector3    v4         = m_random.UniformFloat(0f - vector.X, vector.X) * vector4 + m_random.UniformFloat(0f - vector.Y, vector.Y) * v3 + m_random.UniformFloat(0f - vector.Z, vector.Z) * vector3;
                                        Projectile projectile = m_subsystemProjectiles.FireProjectile(value2, vector2, s * (vector3 + v4), Vector3.Zero, componentMiner.ComponentCreature);
                                        if (projectile != null)
                                        {
                                            projectile.ProjectileStoppedAction = ProjectileStoppedAction.Disappear;
                                        }
                                    }
                                    m_subsystemAudio.PlaySound("Audio/MusketFire", 1f, m_random.UniformFloat(-0.1f, 0.1f), componentMiner.ComponentCreature.ComponentCreatureModel.EyePosition, 10f, true);
                                    m_subsystemParticles.AddParticleSystem(new GunSmokeParticleSystem(SubsystemTerrain, vector2 + 0.3f * vector3, vector3));
                                    m_subsystemNoise.MakeNoise(vector2, 1f, 40f);
                                    componentMiner.ComponentCreature.ComponentBody.ApplyImpulse(-1f * vector3);
                                }
                                if (loadState == Musket2Block.LoadState.Gunpowder)
                                {
                                    num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetLoadState(Terrain.ExtractData(num2), Musket2Block.LoadState.Empty));
                                }
                                if (loadState == Musket2Block.LoadState.Wad)
                                {
                                    num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetLoadState(Terrain.ExtractData(num2), Musket2Block.LoadState.Gunpowder));
                                }
                                num3 = 1;
                            }
                            if (Musket2Block.GetHammerState(Terrain.ExtractData(num2)))
                            {
                                num2 = Terrain.MakeBlockValue(Terrain.ExtractContents(num2), 0, Musket2Block.SetHammerState(Terrain.ExtractData(num2), false));
                                m_subsystemAudio.PlaySound("Audio/HammerRelease", 1f, m_random.UniformFloat(-0.1f, 0.1f), 0f, 0f);
                            }
                            m_aimStartTimes.Remove(componentMiner);
                            break;
                        }
                        }
                    }
                    if (num2 != slotValue)
                    {
                        inventory.RemoveSlotItems(activeSlotIndex, 1);
                        inventory.AddSlotItems(activeSlotIndex, num2, 1);
                    }
                    if (num3 > 0)
                    {
                        componentMiner.DamageActiveTool(num3);
                    }
                }
            }
            return(false);
        }
Exemplo n.º 5
0
 public void Injure(float amount, ComponentCreature attacker, bool ignoreInvulnerability, string cause)
 {
     if (!(amount > 0f) || (!ignoreInvulnerability && IsInvulnerable))
     {
         return;
     }
     if (Health > 0f)
     {
         if (m_componentCreature.PlayerStats != null)
         {
             if (attacker != null)
             {
                 m_componentCreature.PlayerStats.HitsReceived++;
             }
             m_componentCreature.PlayerStats.TotalHealthLost += MathUtils.Min(amount, Health);
         }
         Health = MathUtils.Max(Health - amount, 0f);
         if (Health <= 0f)
         {
             CauseOfDeath = cause;
             if (m_componentCreature.PlayerStats != null)
             {
                 m_componentCreature.PlayerStats.AddDeathRecord(new PlayerStats.DeathRecord
                 {
                     Day      = m_subsystemTimeOfDay.Day,
                     Location = m_componentCreature.ComponentBody.Position,
                     Cause    = cause
                 });
             }
             if (attacker != null)
             {
                 ComponentPlayer componentPlayer = attacker.Entity.FindComponent <ComponentPlayer>();
                 if (componentPlayer != null)
                 {
                     if (m_componentPlayer != null)
                     {
                         componentPlayer.PlayerStats.PlayerKills++;
                     }
                     else if (m_componentCreature.Category == CreatureCategory.LandPredator || m_componentCreature.Category == CreatureCategory.LandOther)
                     {
                         componentPlayer.PlayerStats.LandCreatureKills++;
                     }
                     else if (m_componentCreature.Category == CreatureCategory.WaterPredator || m_componentCreature.Category == CreatureCategory.WaterOther)
                     {
                         componentPlayer.PlayerStats.WaterCreatureKills++;
                     }
                     else
                     {
                         componentPlayer.PlayerStats.AirCreatureKills++;
                     }
                     int num = (int)MathUtils.Ceiling(m_componentCreature.ComponentHealth.AttackResilience / 12f);
                     for (int i = 0; i < num; i++)
                     {
                         Vector2 vector = m_random.Vector2(2.5f, 3.5f);
                         m_subsystemPickables.AddPickable(248, 1, m_componentCreature.ComponentBody.Position, new Vector3(vector.X, 6f, vector.Y), null);
                     }
                 }
             }
         }
     }
     if (attacker != null && this.Attacked != null)
     {
         this.Attacked(attacker);
     }
 }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemTime   = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_componentGui    = base.Entity.FindComponent <ComponentGui>(throwOnError: true);
     m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
 }
Exemplo n.º 8
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int value = inventory.GetSlotValue(slotIndex);
            int count = inventory.GetSlotCount(slotIndex);
            int data  = Terrain.ExtractData(value);

            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditPistonDialog(data, delegate(int newData)
            {
                int num = Terrain.ReplaceData(value, newData);
                if (num != value)
                {
                    inventory.RemoveSlotItems(slotIndex, count);
                    inventory.AddSlotItems(slotIndex, num, 1);
                }
            }));
            return(true);
        }
Exemplo n.º 9
0
        public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
        {
            int            value          = inventory.GetSlotValue(slotIndex);
            int            count          = inventory.GetSlotCount(slotIndex);
            int            id             = Terrain.ExtractData(value);
            MemoryBankData memoryBankData = GetItemData(id);

            if (memoryBankData != null)
            {
                memoryBankData = (MemoryBankData)memoryBankData.Copy();
            }
            else
            {
                memoryBankData = new MemoryBankData();
            }
            DialogsManager.ShowDialog(componentPlayer.GuiWidget, new EditMemeryDialogB(memoryBankData, delegate() {
                int data   = StoreItemDataAtUniqueId(memoryBankData);
                int value2 = Terrain.ReplaceData(value, data);
                inventory.RemoveSlotItems(slotIndex, count);
                inventory.AddSlotItems(slotIndex, value2, 1);
            }));
            return(true);
        }
Exemplo n.º 10
0
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_componentPlayer = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
 }
 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
 {
     m_subsystemGameInfo    = base.Project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
     m_subsystemTime        = base.Project.FindSubsystem <SubsystemTime>(throwOnError: true);
     m_subsystemSky         = base.Project.FindSubsystem <SubsystemSky>(throwOnError: true);
     m_subsystemBodies      = base.Project.FindSubsystem <SubsystemBodies>(throwOnError: true);
     m_componentCreature    = base.Entity.FindComponent <ComponentCreature>(throwOnError: true);
     m_componentPathfinding = base.Entity.FindComponent <ComponentPathfinding>(throwOnError: true);
     m_dayRange             = valuesDictionary.GetValue <float>("DayRange");
     m_nightRange           = valuesDictionary.GetValue <float>("NightRange");
     m_minRange             = valuesDictionary.GetValue <float>("MinRange");
     m_stateMachine.AddState("Inactive", delegate
     {
         m_importanceLevel = 0f;
         m_target          = null;
     }, delegate
     {
         if (IsActive)
         {
             m_stateMachine.TransitionTo("Move");
         }
         if (m_subsystemGameInfo.WorldSettings.GameMode > GameMode.Harmless)
         {
             m_target = FindTarget();
             if (m_target != null)
             {
                 ComponentPlayer componentPlayer = m_target.Entity.FindComponent <ComponentPlayer>();
                 if (componentPlayer != null && componentPlayer.ComponentSleep.IsSleeping)
                 {
                     m_importanceLevel = 5f;
                 }
                 else if (m_random.Float(0f, 1f) < 0.05f * m_dt)
                 {
                     m_importanceLevel = m_random.Float(1f, 4f);
                 }
             }
             else
             {
                 m_importanceLevel = 0f;
             }
         }
     }, null);
     m_stateMachine.AddState("Move", delegate
     {
         if (m_target != null)
         {
             m_componentPathfinding.SetDestination(m_target.ComponentBody.Position, m_random.Float(0.5f, 0.7f), m_minRange, 500, useRandomMovements: true, ignoreHeightDifference: true, raycastDestination: false, null);
         }
     }, delegate
     {
         if (!IsActive)
         {
             m_stateMachine.TransitionTo("Inactive");
         }
         else if (m_target == null || m_componentPathfinding.IsStuck || !m_componentPathfinding.Destination.HasValue || ScoreTarget(m_target) <= 0f)
         {
             m_importanceLevel = 0f;
         }
         if (m_random.Float(0f, 1f) < 0.1f * m_dt)
         {
             m_componentCreature.ComponentCreatureSounds.PlayIdleSound(skipIfRecentlyPlayed: true);
         }
         m_componentCreature.ComponentCreatureModel.LookRandomOrder = true;
     }, null);
     m_stateMachine.TransitionTo("Inactive");
 }
 public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
 {
     DialogsManager.ShowDialog(componentPlayer.View.GameWidget, new CommandHelperDialog(Project.FindSubsystem <SubsystemCommandEngine>()));
     return(false);
 }
Exemplo n.º 13
0
 public CraftingRecipe FindSmeltingRecipe(float heatLevel)
 {
     if (heatLevel > 0f)
     {
         for (int i = 0; i < m_furnaceSize; i++)
         {
             int slotValue = GetSlotValue(i);
             int num       = Terrain.ExtractContents(slotValue);
             int num2      = Terrain.ExtractData(slotValue);
             if (GetSlotCount(i) > 0)
             {
                 Block block = BlocksManager.Blocks[num];
                 m_matchedIngredients[i] = block.CraftingId + ":" + num2.ToString(CultureInfo.InvariantCulture);
             }
             else
             {
                 m_matchedIngredients[i] = null;
             }
         }
         ComponentPlayer componentPlayer = FindInteractingPlayer();
         float           playerLevel     = componentPlayer?.PlayerData.Level ?? 1f;
         CraftingRecipe  craftingRecipe  = null;
         craftingRecipe = CraftingRecipesManager.FindMatchingRecipe(m_subsystemTerrain, m_matchedIngredients, heatLevel, playerLevel);
         if (craftingRecipe != null && craftingRecipe.ResultValue != 0)
         {
             if (craftingRecipe.RequiredHeatLevel <= 0f)
             {
                 craftingRecipe = null;
             }
             if (craftingRecipe != null)
             {
                 Slot slot = m_slots[ResultSlotIndex];
                 int  num3 = Terrain.ExtractContents(craftingRecipe.ResultValue);
                 if (slot.Count != 0 && (craftingRecipe.ResultValue != slot.Value || craftingRecipe.ResultCount + slot.Count > BlocksManager.Blocks[num3].MaxStacking))
                 {
                     craftingRecipe = null;
                 }
             }
             if (craftingRecipe != null && craftingRecipe.RemainsValue != 0 && craftingRecipe.RemainsCount > 0)
             {
                 if (m_slots[RemainsSlotIndex].Count == 0 || m_slots[RemainsSlotIndex].Value == craftingRecipe.RemainsValue)
                 {
                     if (BlocksManager.Blocks[Terrain.ExtractContents(craftingRecipe.RemainsValue)].MaxStacking - m_slots[RemainsSlotIndex].Count < craftingRecipe.RemainsCount)
                     {
                         craftingRecipe = null;
                     }
                 }
                 else
                 {
                     craftingRecipe = null;
                 }
             }
         }
         if (craftingRecipe != null && !string.IsNullOrEmpty(craftingRecipe.Message))
         {
             componentPlayer?.ComponentGui.DisplaySmallMessage(craftingRecipe.Message, Color.White, blinking: true, playNotificationSound: true);
         }
         return(craftingRecipe);
     }
     return(null);
 }
Exemplo n.º 14
0
 public virtual bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
 {
     return(false);
 }
Exemplo n.º 15
0
        public override int RemoveSlotItems(int slotIndex, int count)
        {
            int num = 0;

            if (slotIndex == ResultSlotIndex)
            {
                if (m_matchedRecipe != null)
                {
                    if (m_matchedRecipe.RemainsValue != 0 && m_matchedRecipe.RemainsCount > 0)
                    {
                        if (m_slots[RemainsSlotIndex].Count == 0 || m_slots[RemainsSlotIndex].Value == m_matchedRecipe.RemainsValue)
                        {
                            int num2 = BlocksManager.Blocks[Terrain.ExtractContents(m_matchedRecipe.RemainsValue)].MaxStacking - m_slots[RemainsSlotIndex].Count;
                            count = MathUtils.Min(count, num2 / m_matchedRecipe.RemainsCount);
                        }
                        else
                        {
                            count = 0;
                        }
                    }
                    count = count / m_matchedRecipe.ResultCount * m_matchedRecipe.ResultCount;
                    if (slotIndex >= 0 && slotIndex < m_slots.Count)
                    {
                        Slot slot = m_slots[slotIndex];
                        count       = MathUtils.Min(count, GetSlotCount(slotIndex));
                        slot.Count -= count;
                        num         = count;
                    }
                    else
                    {
                        num = 0;
                    }
                    if (num > 0)
                    {
                        for (int index = 0; index < 36; index++)
                        {
                            if (!string.IsNullOrEmpty(m_matchedIngredients[index]))
                            {
                                int index2 = index % 6 + m_craftingGridSize * (index / 6);
                                m_slots[index2].Count = MathUtils.Max(m_slots[index2].Count - num / m_matchedRecipe.ResultCount, 0);
                            }
                        }
                        if (m_matchedRecipe.RemainsValue != 0 && m_matchedRecipe.RemainsCount > 0)
                        {
                            m_slots[RemainsSlotIndex].Value  = m_matchedRecipe.RemainsValue;
                            m_slots[RemainsSlotIndex].Count += num / m_matchedRecipe.ResultCount * m_matchedRecipe.RemainsCount;
                        }
                        ComponentPlayer componentPlayer = Entity.FindComponent <ComponentPlayer>();
                        if (componentPlayer == null)
                        {
                            ComponentBlockEntity componentBlockEntity = Entity.FindComponent <ComponentBlockEntity>();
                            if (componentBlockEntity != null)
                            {
                                var position = new Vector3(componentBlockEntity.Coordinates);
                                componentPlayer = Project.FindSubsystem <SubsystemPlayers>(true).FindNearestPlayer(position);
                            }
                        }
                        if (componentPlayer != null && componentPlayer.PlayerStats != null)
                        {
                            componentPlayer.PlayerStats.ItemsCrafted += num;
                        }
                    }
                }
            }
            else
            {
                if (slotIndex >= 0 && slotIndex < m_slots.Count)
                {
                    Slot slot = m_slots[slotIndex];
                    count       = MathUtils.Min(count, GetSlotCount(slotIndex));
                    slot.Count -= count;
                    num         = count;
                }
                else
                {
                    num = 0;
                }
            }
            UpdateCraftingResult();
            return(num);
        }
Exemplo n.º 16
0
 public void setPlayer(ComponentPlayer p)
 {
     this.player = p;
 }
Exemplo n.º 17
0
        public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
        {
            flatBatch           = primitivesRenderer.FlatBatch();
            componentPlayer     = base.Entity.FindComponent <ComponentPlayer>(throwOnError: true);
            subsystemTerrain    = base.Entity.Project.FindSubsystem <SubsystemTerrain>(throwOnError: true);
            subsystemPlantBlock = base.Entity.Project.FindSubsystem <SubsystemPlantBlockBehavior>(throwOnError: true);
            creatureSpawn       = Project.FindSubsystem <SubsystemCreatureSpawn>();
            modelsRenderer      = base.Entity.Project.FindSubsystem <SubsystemModelsRenderer>();
            subsystemBodies     = Project.FindSubsystem <SubsystemBodies>();
            jeiBehavior         = base.Entity.Project.FindSubsystem <SubsystemXjJeiBehavior>();
            jump.Texture        = TextureAtlasManager.GetSubtexture("JEITextures/JEI_Jump").Texture;
            jumpcanvas.Children.Add(touch);
            jumpcanvas.Children.Add(jump);
            jumpcanvas.DesiredSize = SubsystemXjJeiBehavior.jumpsize;
            jump.DesiredSize       = SubsystemXjJeiBehavior.jumpsize;
            jumpcanvas.IsVisible   = SubsystemXjJeiBehavior.showjump;
            messageInfo.setPlayer(componentPlayer);
            if (componentPlayer != null)
            {
                msginfobtn.NormalSubtexture  = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_MSG"), Vector2.Zero, Vector2.One);
                msginfobtn.ClickedSubtexture = new Subtexture(ContentManager.Get <Texture2D>("JEITextures/JEI_MSG_P"), Vector2.Zero, Vector2.One);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(infoDialog);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(messageInfo);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(moreInfo);
                componentPlayer.GuiWidget.Children.Find <StackPanelWidget>("RightControlsContainer").Children.Add(msginfobtn);
                componentPlayer.GuiWidget.Children.Find <CanvasWidget>("ControlsContainer").Children.Add(jumpcanvas);
            }

            int num = 0;

            try
            {
                List <string> namelist = new List <string>();
                Dictionary <string, List <string> > depancys = new Dictionary <string, List <string> >();
                List <uint> verList = new List <uint>();
                foreach (ModInfo modInfo in ModsManager.LoadedMods)
                {
                    if (!namelist.Contains(modInfo.Name))
                    {
                        if (!string.IsNullOrEmpty(modInfo.Dependency))
                        {
                            string[]      mm    = modInfo.Dependency.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            List <string> mlist = new List <string>();
                            if (mm.Length == 1)
                            {
                                mlist.Add(modInfo.Dependency);
                            }
                            else
                            {
                                foreach (string mmsa in mm)
                                {
                                    mlist.Add(mmsa);
                                }
                            }
                            depancys.Add(modInfo.Name, mlist);
                        }
                        namelist.Add(modInfo.Name);
                        verList.Add(modInfo.Version);
                    }
                }
                messageInfo.addMessage("[color=yellow]欢迎使用[/color][color=red]SCCRF合成书[/color][color=yellow]模组![/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]使用一根[color=red]木棍[/color]开始你的[color=green]合成之旅[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]电脑端按下[color=red]TAB[/color]快捷打开[color=green]消息框[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]电脑端按下[color=red]B[/color]快捷打开[color=green]合成谱[/color]");
                messageInfo.addMessage($"[color=green]<SCCRF>:[/color]输入[color=red]/help[/color]使用[color=green]命令[/color]帮助");
                messageInfo.addMessage($"[color=green]并且您已安装([/color][color=red]{namelist.Count}[/color][color=green])个模组[/color]");
                foreach (string modInfo in namelist)
                {
                    messageInfo.addMessage($"[color=blue]{num+1}.[/color] {modInfo.Replace('[','{').Replace(']','}')} [color=yellow]{parseVersion(verList[num])}[/color]");
                    num++;
                }
                num = 0;
                foreach (KeyValuePair <string, List <string> > kkop in depancys)
                {
                    foreach (string huap in kkop.Value)
                    {
                        if (!namelist.Contains(huap))
                        {
                            if (huap == "zh-cn" && namelist.Contains("NewBlocks_SC"))
                            {
                                continue;
                            }
                            messageInfo.addMessage($"[color=yellow]<警告>[/color]:使用[color=blue]{kkop.Key}[/color]需要安装依赖MOD [color=green]{huap}[/color]");
                        }
                    }
                    ++num;
                }
                messageInfo.IsVisible = false;
            }
            catch (Exception e) {
                messageInfo.addMessage(e.ToString());
            }
            infoDialog.IsVisible = false;
            base.Load(valuesDictionary, idToEntityMap);
        }
Exemplo n.º 18
0
        public GameMenuDialog(ComponentPlayer componentPlayer)
        {
            XElement node = ContentManager.Get <XElement>("Dialogs/GameMenuDialog");

            LoadContents(this, node);
            m_statsPanel             = Children.Find <StackPanelWidget>("StatsPanel");
            m_componentPlayer        = componentPlayer;
            m_adventureRestartExists = WorldsManager.SnapshotExists(GameManager.WorldInfo.DirectoryName, "AdventureRestart");
            if (!m_increaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f < 25f && (SettingsManager.VisibilityRange <= 64 || SettingsManager.ResolutionMode == ResolutionMode.Low))
            {
                m_increaseDetailDialogShown = true;
                DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "ok"), null, null));
                AnalyticsManager.LogEvent("[GameMenuScreen] IncreaseDetailDialog Shown");
            }
            if (!m_decreaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f > 50f && (SettingsManager.VisibilityRange >= 64 || SettingsManager.ResolutionMode == ResolutionMode.High))
            {
                m_decreaseDetailDialogShown = true;
                DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "ok"), null, null));
                AnalyticsManager.LogEvent("[GameMenuScreen] DecreaseDetailDialog Shown");
            }
            m_statsPanel.Children.Clear();
            Project           project           = componentPlayer.Project;
            PlayerData        playerData        = componentPlayer.PlayerData;
            PlayerStats       playerStats       = componentPlayer.PlayerStats;
            SubsystemGameInfo subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true);
            SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true);
            BitmapFont       font             = ContentManager.Get <BitmapFont>("Fonts/Pericles");
            BitmapFont       font2            = ContentManager.Get <BitmapFont>("Fonts/Pericles");
            Color            white            = Color.White;
            StackPanelWidget stackPanelWidget = new StackPanelWidget
            {
                Direction           = LayoutDirection.Vertical,
                HorizontalAlignment = WidgetAlignment.Center
            };

            m_statsPanel.Children.Add(stackPanelWidget);
            stackPanelWidget.Children.Add(new LabelWidget
            {
                Text = LanguageControl.Get(fName, 5),
                Font = font,
                HorizontalAlignment = WidgetAlignment.Center,
                Margin = new Vector2(0f, 10f),
                Color  = white
            });
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 6), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()) + ", " + LanguageControl.Get("EnvironmentBehaviorMode", subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode.ToString()));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 7), StringsManager.GetString("TerrainGenerationMode." + subsystemGameInfo.WorldSettings.TerrainGenerationMode.ToString() + ".Name"));
            string seed = subsystemGameInfo.WorldSettings.Seed;

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 8), (!string.IsNullOrEmpty(seed)) ? seed : LanguageControl.Get(fName, 9));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 10), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.SeaLevelOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 11), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.TemperatureOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x");
            int num = 0;

            for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++)
            {
                if (subsystemFurnitureBlockBehavior.GetDesign(i) != null)
                {
                    num++;
                }
            }
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}");
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion);
            stackPanelWidget.Children.Add(new LabelWidget
            {
                Text = LanguageControl.Get(fName, 17),
                Font = font,
                HorizontalAlignment = WidgetAlignment.Center,
                Margin = new Vector2(0f, 10f),
                Color  = white
            });
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 18), playerData.Name);
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 19), playerData.PlayerClass.ToString());
            string value = (playerData.FirstSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.FirstSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 20)) : LanguageControl.Get(fName, 21);

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 22), value);
            string value2 = (playerData.LastSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.LastSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 23)) : LanguageControl.Get(fName, 24);

            AddStat(stackPanelWidget, LanguageControl.Get(fName, 25), value2);
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 26), MathUtils.Max(playerData.SpawnsCount - 1, 0).ToString("N0") + LanguageControl.Get(fName, 27));
            AddStat(stackPanelWidget, LanguageControl.Get(fName, 28), string.Format(LanguageControl.Get(fName, 29), ((int)MathUtils.Floor(playerStats.HighestLevel)).ToString("N0")));
            if (componentPlayer != null)
            {
                Vector3 position = componentPlayer.ComponentBody.Position;
                if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative)
                {
                    AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 31), $"{position.X:0}", $"{position.Z:0}", $"{position.Y:0}"));
                }
                else
                {
                    AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 32), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString())));
                }
            }
            if (string.CompareOrdinal(subsystemGameInfo.WorldSettings.OriginalSerializationVersion, "1.29") > 0)
            {
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 33),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 34), playerStats.PlayerKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 35), playerStats.LandCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 36), playerStats.WaterCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 37), playerStats.AirCreatureKills.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 38), playerStats.MeleeAttacks.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 39), playerStats.MeleeHits.ToString("N0"), $"({((playerStats.MeleeHits == 0L) ? 0.0 : ((double)playerStats.MeleeHits / (double)playerStats.MeleeAttacks * 100.0)):0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 40), playerStats.RangedAttacks.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 41), playerStats.RangedHits.ToString("N0"), $"({((playerStats.RangedHits == 0L) ? 0.0 : ((double)playerStats.RangedHits / (double)playerStats.RangedAttacks * 100.0)):0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 42), playerStats.HitsReceived.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 43),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 44), playerStats.BlocksDug.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 45), playerStats.BlocksPlaced.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 46), playerStats.BlocksInteracted.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 47), playerStats.ItemsCrafted.ToString("N0"));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 48), playerStats.FurnitureItemsMade.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 49),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 50), FormatDistance(playerStats.DistanceTravelled));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 51), FormatDistance(playerStats.DistanceWalked), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceWalked / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 52), FormatDistance(playerStats.DistanceFallen), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFallen / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 53), FormatDistance(playerStats.DistanceClimbed), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceClimbed / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 54), FormatDistance(playerStats.DistanceFlown), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFlown / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 55), FormatDistance(playerStats.DistanceSwam), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceSwam / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 56), FormatDistance(playerStats.DistanceRidden), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceRidden / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 57), FormatDistance(playerStats.LowestAltitude));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 58), FormatDistance(playerStats.HighestAltitude));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 59), playerStats.DeepestDive.ToString("N1") + "m");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 60), playerStats.Jumps.ToString("N0"));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 61),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 62), (playerStats.TotalHealthLost * 100.0).ToString("N0") + "%");
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 63), playerStats.FoodItemsEaten.ToString("N0") + LanguageControl.Get(fName, 64));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 65), playerStats.TimesWentToSleep.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 67), (playerStats.TimeSlept / 1200.0).ToString("N1") + LanguageControl.Get(fName, 68));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 69), playerStats.TimesWasSick.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 70), playerStats.TimesPuked.ToString("N0") + LanguageControl.Get(fName, 66));
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 71), playerStats.TimesHadFlu.ToString("N0") + LanguageControl.Get(fName, 66));
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text = LanguageControl.Get(fName, 72),
                    Font = font,
                    HorizontalAlignment = WidgetAlignment.Center,
                    Margin = new Vector2(0f, 10f),
                    Color  = white
                });
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 73), playerStats.StruckByLightning.ToString("N0") + LanguageControl.Get(fName, 66));
                GameMode easiestModeUsed = playerStats.EasiestModeUsed;
                AddStat(stackPanelWidget, LanguageControl.Get(fName, 74), LanguageControl.Get("GameMode", easiestModeUsed.ToString()));
                if (playerStats.DeathRecords.Count > 0)
                {
                    stackPanelWidget.Children.Add(new LabelWidget
                    {
                        Text = LanguageControl.Get(fName, 75),
                        Font = font,
                        HorizontalAlignment = WidgetAlignment.Center,
                        Margin = new Vector2(0f, 10f),
                        Color  = white
                    });
                    foreach (PlayerStats.DeathRecord deathRecord in playerStats.DeathRecords)
                    {
                        float  num2 = (float)MathUtils.Remainder(deathRecord.Day, 1.0);
                        string arg  = (!(num2 < 0.2f) && !(num2 >= 0.8f)) ? ((!(num2 >= 0.7f)) ? ((!(num2 >= 0.5f)) ? LanguageControl.Get(fName, 76) : LanguageControl.Get(fName, 77)) : LanguageControl.Get(fName, 78)) : LanguageControl.Get(fName, 79);
                        AddStat(stackPanelWidget, string.Format(LanguageControl.Get(fName, 80), MathUtils.Floor(deathRecord.Day) + 1.0, arg), "", deathRecord.Cause);
                    }
                }
            }
            else
            {
                stackPanelWidget.Children.Add(new LabelWidget
                {
                    Text                = LanguageControl.Get(fName, 81),
                    WordWrap            = true,
                    Font                = font2,
                    HorizontalAlignment = WidgetAlignment.Center,
                    TextAnchor          = TextAnchor.HorizontalCenter,
                    Margin              = new Vector2(20f, 10f),
                    Color               = white
                });
            }
        }
 public override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
 {
     componentPlayer.ComponentGui.ModalPanelWidget = ((componentPlayer.ComponentGui.ModalPanelWidget == null) ? new CrossbowWidget(inventory, slotIndex) : null);
     return(true);
 }