Пример #1
0
        internal static void SetJumpJetHardpointCount(MechLabMechInfoWidget widget, MechLabPanel mechLab, MechLabHardpointElement[] hardpoints)
        {
            if (mechLab == null || mechLab.activeMechDef == null || mechLab.activeMechInventory == null)
            {
                return;
            }

            if (mechLab.activeMechDef.Chassis == null)
            {
                return;
            }

            var current = mechLab.headWidget.currentJumpjetCount
                          + mechLab.centerTorsoWidget.currentJumpjetCount
                          + mechLab.leftTorsoWidget.currentJumpjetCount
                          + mechLab.rightTorsoWidget.currentJumpjetCount
                          + mechLab.leftArmWidget.currentJumpjetCount
                          + mechLab.rightArmWidget.currentJumpjetCount
                          + mechLab.leftLegWidget.currentJumpjetCount
                          + mechLab.rightLegWidget.currentJumpjetCount;

            var stats = new MechDefMovementStatistics(mechLab.activeMechDef);

            widget.totalJumpjets = stats.JumpJetCount;

            if (hardpoints == null || hardpoints[4] == null)
            {
                return;
            }

            hardpoints[4].SetData(WeaponCategoryEnumeration.GetAMS(), $"{current} / {widget.totalJumpjets}");
        }
Пример #2
0
        internal static void SetJumpJetHardpointCount(MechLabMechInfoWidget widget, MechLabPanel mechLab, MechLabHardpointElement[] hardpoints)
        {
            if (hardpoints == null || hardpoints[4] == null)
            {
                return;
            }

            var mechDef = mechLab?.CreateMechDef();

            if (mechDef == null)
            {
                return;
            }

            var stats = new MechDefMovementStatistics(mechDef);

            widget.totalJumpjets = stats.JumpJetMaxCount;

            hardpoints[4].SetData(WeaponCategoryEnumeration.GetAMS(), $"{stats.JumpJetCount} / {stats.JumpJetMaxCount}");
        }
 internal static bool Prefix(MechDef?def, ref int __result)
 {
     try
     {
         if (def == null)
         {
             __result = -1;
         }
         else
         {
             var stats = new MechDefMovementStatistics(def);
             __result = stats.JumpJetMaxCount;
         }
         return(false);
     }
     catch (Exception e)
     {
         Control.Logger.Error.Log(e);
     }
     return(true);
 }
Пример #4
0
        public void ValidateMech(MechDef mechDef, Errors errors)
        {
            var stats  = new MechDefMovementStatistics(mechDef);
            var engine = stats.Engine;

            if (engine == null)
            {
                return;
            }

            {
                var count = mechDef.Inventory.Count(c => c.ComponentDefType == ComponentType.JumpJet);
                var max   = stats.JumpJetCount;

                if (count > max)
                {
                    if (errors.Add(MechValidationType.InvalidJumpjets, $"JUMP JETS: This Mech mounts too many jumpjets ({count} / {max})"))
                    {
                        return;
                    }
                }
            }

            {
                if (engine.IsMissingHeatSinks(out var min, out var count))
                {
                    if (errors.Add(MechValidationType.InvalidInventorySlots, $"HEAT SINKS: This Mech has too few heat sinks ({count} / {min})"))
                    {
                        return;
                    }
                }
            }

            if (!EngineFeature.settings.AllowMixingHeatSinkTypes)
            {
                var types = new HashSet <string>();

                var inventoryHeatSinkTypes = mechDef.Inventory.Select(r => r.GetComponent <EngineHeatSinkDef>()).Where(hs => hs != null).ToList();
                inventoryHeatSinkTypes.Add(engine.MechHeatSinkDef);
                foreach (var hs in inventoryHeatSinkTypes)
                {
                    types.Add(hs.HSCategory);
                    if (types.Count <= 1)
                    {
                        continue;
                    }

                    if (errors.Add(MechValidationType.InvalidInventorySlots, "HEAT SINKS: Heat Sink types cannot be mixed"))
                    {
                        return;
                    }
                }
            }

            if (EngineFeature.settings.EnforceRulesForAdditionalInternalHeatSinks)
            {
                var count = engine.EngineHeatBlockDef.HeatSinkCount;
                var max   = engine.HeatSinkInternalAdditionalMaxCount;
                if (count > max)
                {
                    if (errors.Add(MechValidationType.InvalidInventorySlots, $"HEAT SINKS: This Mech has too many internal heat sinks ({count} / {max})"))
                    {
                        return;
                    }
                }
            }
        }
Пример #5
0
        internal static string GetJumpJetCountText(MechDef mechDef)
        {
            var stats = new MechDefMovementStatistics(mechDef);

            return(stats.JumpJetCount == 0 ? $"{stats.JumpJetMaxCount}" : $"{stats.JumpJetCount} / {stats.JumpJetMaxCount}");
        }
Пример #6
0
        public void SetupTooltip(StatTooltipData tooltipData, MechDef mechDef)
        {
            var stats = new MechDefMovementStatistics(mechDef);

            tooltipData.dataList.Clear();