Esempio n. 1
0
        public void AdjustTooltipEquipment(TooltipPrefab_Equipment tooltip, MechComponentDef mechComponentDef)
        {
            var def = mechComponentDef.GetComponent <EngineHeatBlockDef>();

            if (def == null)
            {
                return;
            }


            var panel = Global.ActiveMechLabPanel;

            var engine = panel?.CreateMechDef()?.GetEngine();

            if (engine == null)
            {
                return;
            }

            engine.HeatBlockDef = def;

            var originalText = tooltip.detailText.text;

            tooltip.detailText.text = "";

            tooltip.detailText.text += $"<i>{engine.HeatSinkDef.FullName}</i>" +
                                       $"\r\n   Internal" +
                                       $"   Free: <b>{engine.HeatSinkInternalFreeMaxCount}</b> " +
                                       $"   Additional: <b>{engine.HeatBlockDef.HeatSinkCount} / {engine.HeatSinkInternalAdditionalMaxCount}</b>" +
                                       $"\r\n   External" +
                                       $"   Free: <b>{engine.HeatSinkExternalFreeCount} / {engine.HeatSinkExternalFreeMaxCount}</b> " +
                                       $"   Additional: <b>{engine.HeatSinkExternalAdditionalCount}</b>" +
                                       "\r\n";

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

            tooltip.bonusesText.text = BonusValueEngineHeatDissipation(engine) + ", " + BonusValueEngineHeatSinkCounts(engine);
            tooltip.bonusesText.SetAllDirty();
        }
Esempio n. 2
0
        internal static void AddTemplatedExtendedDetail(
            MechComponentDef componentDef,
            IEnumerable <string> elements,
            string elementTemplate,
            string descriptionTemplate,
            string identifier,
            UnitType unityType = UnitType.UNDEFINED)
        {
            var elementsText = string.Join("", elements.Where(x => x != null).Select(x => elementTemplate.Replace("{{element}}", x)).ToArray());
            var text         = descriptionTemplate.Replace("{{elements}}", elementsText);

            var extended = componentDef.GetComponent <ExtendedDetails>() ?? componentDef.AddComponent(new ExtendedDetails(componentDef));
            var detail   = new ExtendedDetail
            {
                UnitType   = unityType,
                Index      = -1,
                Text       = text,
                Identifier = identifier
            };

            extended.AddDetail(detail);
        }
Esempio n. 3
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();
        }
        public static bool CheckDefaults(ref MechComponentDef def)
        {
            if (def == null)
            {
                Control.LogError("Get NULL component in salvage!");
                return(false);
            }


            if (!def.Flags <CCFlags>().NoSalvage)
            {
                return(true);
            }

            var lootable = def.GetComponent <LootableDefault>();

            if (lootable == null)
            {
                Control.LogDebug(DType.SalvageProccess, $"---- default, no lootable - skipped");

                return(false);
            }

            MechComponentDef component = null;

            switch (def.ComponentType)
            {
            case ComponentType.AmmunitionBox:
                if (UnityGameInstance.BattleTechGame.DataManager.AmmoBoxDefs.Exists(lootable.ItemID))
                {
                    component = UnityGameInstance.BattleTechGame.DataManager.AmmoBoxDefs.Get(lootable.ItemID);
                }
                break;

            case ComponentType.Weapon:
                if (UnityGameInstance.BattleTechGame.DataManager.WeaponDefs.Exists(lootable.ItemID))
                {
                    component = UnityGameInstance.BattleTechGame.DataManager.WeaponDefs.Get(lootable.ItemID);
                }
                break;

            case ComponentType.Upgrade:
                if (UnityGameInstance.BattleTechGame.DataManager.UpgradeDefs.Exists(lootable.ItemID))
                {
                    component = UnityGameInstance.BattleTechGame.DataManager.UpgradeDefs.Get(lootable.ItemID);
                }
                break;

            case ComponentType.HeatSink:
                if (UnityGameInstance.BattleTechGame.DataManager.HeatSinkDefs.Exists(lootable.ItemID))
                {
                    component = UnityGameInstance.BattleTechGame.DataManager.HeatSinkDefs.Get(lootable.ItemID);
                }
                break;

            case ComponentType.JumpJet:
                if (UnityGameInstance.BattleTechGame.DataManager.JumpJetDefs.Exists(lootable.ItemID))
                {
                    component = UnityGameInstance.BattleTechGame.DataManager.JumpJetDefs.Get(lootable.ItemID);
                }
                break;
            }

            if (component == null || component.Flags <CCFlags>().NoSalvage)
            {
                Control.LogDebug(DType.SalvageProccess, $"---- default, lootable {lootable.ItemID} not found or notsalvagable - skipped");
                return(false);
            }
            Control.LogDebug(DType.SalvageProccess, $"---- default, lootable {lootable.ItemID} replaced");

            def = component;

            return(true);
        }
Esempio n. 6
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();
        }