Esempio n. 1
0
        // does not account for matching to assemble, too complex (ref CustomSalvage instead)
        public static string AppendExistingPartialCount(string localItemName)
        {
            // only proceed with mech parts
            if (!localItemName.Contains("Partial Mech Salvage"))
            {
                return(localItemName);
            }
            SimGameState sim = UnityGameInstance.BattleTechGame.Simulation;
            // take "Jenner" off "Jenner Partial Mech Salvage"
            string mechName = localItemName.Split(' ')[0];
            // find all existing chassis variants that match this name
            List <ChassisDef> matchingChassis = sim.GetAllInventoryMechDefs()
                                                .Where(x => ParseName(x.Description.Name) == mechName.ToLower()).ToList();

            Mod.Log.Debug?.Write("Matching chassis:");
            matchingChassis.Do(chassisDef => Mod.Log.Debug?.Write($"\t{chassisDef.Description.Name}"));
            // aggregate the total count of matching chassis variants
            int count = 0;

            foreach (ChassisDef chassis in matchingChassis)
            {
                Mod.Log.Debug?.Write($"{chassis.Description.Name}, parsed {ParseName(chassis.Description.Name)}");
                string id = chassis.Description.Id.Replace("chassisdef", "mechdef");
                count += sim.GetItemCount(id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
            }

            return($"{localItemName} (Have {count})");
        }
Esempio n. 2
0
        public static double CalculateTonnageForAllMechParts(SimGameState sgs)
        {
            double allPartsTonnage = 0;

            foreach (ChassisDef cDef in sgs.GetAllInventoryMechDefs(true))
            {
                double chassisTonnage = CalculateChassisTonnage(cDef);
                allPartsTonnage += chassisTonnage;
            }

            Mod.Log.Debug($"Total tonnage from mech parts:{allPartsTonnage}");
            return(allPartsTonnage);
        }