private static void AddMechToSalvage(MechDef mech, ContractHelper contract, SimGameState simgame, SimGameConstants constants, bool can_upgrade)
        {
            Control.LogDebug($"-- Salvaging {mech.Name}");

            int numparts = Control.GetNumParts(mech);

            try
            {
                Control.LogDebug($"--- Adding {numparts} parts");
                contract.AddMechPartsToPotentialSalvage(constants, mech, numparts);
            }
            catch (Exception e)
            {
                Control.LogError("Error in adding parts", e);
            }

            try
            {
                foreach (var component in mech.Inventory.Where(item =>
                                                               !mech.IsLocationDestroyed(item.MountedLocation) &&
                                                               item.DamageLevel != ComponentDamageLevel.Destroyed))
                {
                    contract.AddComponentToPotentialSalvage(component.Def, ComponentDamageLevel.Functional, can_upgrade);
                }
            }
            catch (Exception e)
            {
                Control.LogError("Error in adding component", e);
            }
        }
Exemple #2
0
        public static void SalvageItemsAndParts(UnitResult unit, ContractHelper contract)
        {
            int num_parts = Control.GetNumParts(unit.mech);

            contract.AddMechPartsToPotentialSalvage(UnityGameInstance.BattleTechGame.Simulation.Constants, unit.mech, num_parts);
            foreach (var item in unit.mech.Inventory.Where(i => i.DamageLevel != ComponentDamageLevel.Destroyed && !unit.mech.IsLocationDestroyed(i.MountedLocation)))
            {
                contract.AddComponentToPotentialSalvage(item.Def, item.DamageLevel, false);
            }
        }