예제 #1
0
        public static void Postfix(TooltipPrefab_Equipment __instance, object data)
        {
            try
            {
                if (data == null)
                {
                    return;
                }

                var panel = MechLab.Current;
                if (panel == null)
                {
                    return;
                }

                var adapter = new TooltipPrefab_EquipmentAdapter(__instance);

                var mechComponentDef = (MechComponentDef)data;
                EngineTooltip.AdjustTooltip(adapter, panel, mechComponentDef);
                Armor.AdjustTooltip(adapter, panel, mechComponentDef);
                Structure.AdjustTooltip(adapter, panel, mechComponentDef);
            }

            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }
        }
예제 #2
0
        // show extended engine information (as its now shown anywhere else)
        internal static void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechLabPanel panel, MechComponentDef mechComponentDef)
        {
            var engineDef = mechComponentDef.GetEngineCoreDef();

            if (engineDef == null)
            {
                return;
            }

            var engineRef = panel.activeMechInventory.GetEngineCoreRef();

            if (engineRef == null)
            {
                return;
            }

            float walkSpeed, runSpeed;

            Control.calc.CalcSpeeds(engineDef, panel.activeMechDef.Chassis.Tonnage, out walkSpeed, out runSpeed);

            var originalText = tooltip.detailText.text;

            tooltip.detailText.text = "";

            if (Control.settings.AllowMixingDoubleAndSingleHeatSinks || engineRef.IsSHS)
            {
                tooltip.detailText.text += "<i>Standard Heat Sinks</i>" +
                                           "   Internal: <b>" + engineRef.InternalSHSCount + "</b>" +
                                           "   Additional: <b>" + engineRef.AdditionalSHSCount + "</b> / <b>" + engineDef.MaxAdditionalHeatSinks + "</b>";
            }

            if (Control.settings.AllowMixingDoubleAndSingleHeatSinks || engineRef.IsDHS)
            {
                tooltip.detailText.text += "<i>Double Heat Sinks</i>" +
                                           "   Internal: <b>" + engineRef.InternalDHSCount + "</b>" +
                                           "   Additional: <b>" + engineRef.AdditionalDHSCount + "</b> / <b>" + engineDef.MaxAdditionalHeatSinks + "</b>";
            }

            tooltip.detailText.text += "\r\n" +
                                       "<i>Speeds</i>" +
                                       "   Cruise <b>" + walkSpeed + "</b>" +
                                       " / Top <b>" + runSpeed + "</b>";

            tooltip.detailText.text += "\r\n" +
                                       "<i>Weights</i>" +
                                       "   Engine: <b>" + engineRef.EngineTonnage + "</b> Ton" +
                                       "   Gyro: <b>" + engineRef.CoreDef.GyroTonnage + "</b> Ton" +
                                       "   Sinks: <b>" + engineRef.HeatSinkTonnage + "</b> Ton";

            tooltip.tonnageText.text = string.Format("{0}", engineRef.Tonnage);

            tooltip.detailText.text += "\r\n";
            tooltip.detailText.text += "\r\n";
            tooltip.detailText.text += originalText;
            tooltip.detailText.SetAllDirty();

            tooltip.bonusesText.text = engineRef.BonusValueA;
            tooltip.bonusesText.SetAllDirty();
        }
예제 #3
0
 internal static void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechLabPanel panel, MechComponentDef mechComponentDef)
 {
     if (mechComponentDef.IsArmor())
     {
         var mechDef = panel.activeMechDef;
         var tonnage = Tonnage(mechDef);
         tooltip.tonnageText.text = string.Format("{0:F2}", tonnage);
     }
 }
예제 #4
0
        public static void Postfix(TooltipPrefab_Equipment __instance, object data)
        {
            try
            {
                if (data == null)
                {
                    return;
                }

                var adapter = new TooltipPrefab_EquipmentAdapter(__instance);

                var mechComponentDef = (MechComponentDef)data;
                EngineHandler.Shared.AdjustTooltip(adapter, mechComponentDef);
                WeightsHandler.Shared.AdjustTooltip(adapter, mechComponentDef);
            }
            catch (Exception e)
            {
                Control.mod.Logger.LogError(e);
            }
        }
예제 #5
0
        public void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechComponentDef mechComponentDef)
        {
            var weights = mechComponentDef.GetComponent <Weights>();

            if (weights == null)
            {
                return;
            }


            var mechDef = Global.ActiveMechDef;

            if (mechDef == null)
            {
                return;
            }

            var tonnageSaved = CalculateWeightSavings(mechDef, weights);

            tonnageSaved -= CalculateEngineTonnageChanges(mechDef, weights);

            tooltip.tonnageText.text = $"- {tonnageSaved}";

            // TODO move to own feature... SlotsHandler or SizeHandler
            var reservedSlots = weights.ReservedSlots;

            if (mechComponentDef.Is <DynamicSlots>(out var dynamicSlots))
            {
                reservedSlots += dynamicSlots.ReservedSlots;
            }

            if (reservedSlots > 0)
            {
                tooltip.slotsText.text = $"{mechComponentDef.InventorySize} + {reservedSlots}";
            }

            tooltip.bonusesText.SetAllDirty();
        }
        public void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechComponentDef mechComponentDef)
        {
            var weightSavings = mechComponentDef.GetComponent <WeightSavings>();

            if (weightSavings == null)
            {
                return;
            }


            var mechDef = Global.ActiveMechDef;

            if (mechDef == null)
            {
                return;
            }

            var tonnageSaved = CalculateWeightSavings(weightSavings, mechDef);

            tooltip.tonnageText.text = $"- {tonnageSaved}";
            tooltip.slotsText.text   = weightSavings.RequiredSlots.ToString();
            tooltip.bonusesText.SetAllDirty();
        }
예제 #7
0
        public void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechComponentDef mechComponentDef)
        {
            var engineDef = mechComponentDef.GetComponent <EngineCoreDef>();

            if (engineDef == null)
            {
                return;
            }

            var panel = Global.ActiveMechLabPanel;

            if (panel == null)
            {
                return;
            }

            var engine = panel.activeMechInventory.GetEngine();

            if (engine == null)
            {
                return;
            }

            // use standard heat sinks for non-installed fusion core
            if (engine.CoreRef.CoreDef.Def.Description.Id != engineDef.Def.Description.Id)
            {
                engine.CoreRef = new EngineCoreRef(panel.dataManager.GetDefaultEngineHeatSinkDef(), engineDef);
            }
            var engineRef = engine.CoreRef;

            var movement = engineDef.GetMovement(panel.activeMechDef.Chassis.Tonnage);

            var originalText = tooltip.detailText.text;

            tooltip.detailText.text = "";

            foreach (var heatSinkDef in panel.dataManager.GetAllEngineHeatSinkDefs())
            {
                var query = engineRef.Query(heatSinkDef);

                if (query.Count == 0)
                {
                    continue;
                }

                if (Control.settings.AllowMixingHeatSinkTypes || query.IsType)
                {
                    tooltip.detailText.text += "<i>" + heatSinkDef.FullName + "</i>" +
                                               "   Internal: <b>" + query.InternalCount + "</b>" +
                                               "   Additional: <b>" + query.AdditionalCount + "</b> / <b>" + engineDef.MaxAdditionalHeatSinks + "</b>" +
                                               "\r\n";
                }
            }

            tooltip.detailText.text += "<i>Speeds</i>" +
                                       "   Cruise <b>" + movement.WalkSpeed + "</b>" +
                                       " / Top <b>" + movement.RunSpeed + "</b>";

            tooltip.detailText.text += "\r\n" +
                                       "<i>Weights [Ton]</i>" +
                                       "   Engine: <b>" + engine.EngineTonnage + "</b>" +
                                       "   Gyro: <b>" + engine.GyroTonnage + "</b>" +
                                       "   Sinks: <b>" + engine.HeatSinkTonnage + "</b>";

            tooltip.tonnageText.text = $"{engine.TotalTonnage}";

            tooltip.detailText.text += "\r\n";
            tooltip.detailText.text += "\r\n";
            tooltip.detailText.text += originalText;
            tooltip.detailText.SetAllDirty();

            tooltip.bonusesText.text = engineRef.BonusValueA;
            tooltip.bonusesText.SetAllDirty();
        }
예제 #8
0
 internal static void AdjustTooltip(TooltipPrefab_EquipmentAdapter tooltip, MechLabPanel panel, MechComponentDef mechComponentDef)
 {
 }