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);
            }
        }
Exemplo n.º 2
0
 public static void SalvageItems(UnitResult unit, ContractHelper contract)
 {
     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);
     }
 }
 private static void AddVechicleToSalvage(VehicleDef vechicle, ContractHelper contract, SimGameState simgame)
 {
     foreach (var component in vechicle.Inventory)
     {
         if (component.DamageLevel != ComponentDamageLevel.Destroyed)
         {
             contract.AddComponentToPotentialSalvage(component.Def, component.DamageLevel, true);
         }
     }
 }
Exemplo n.º 4
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);
            }
        }
 private static void AddTurretToSalvage(Turret turret, ContractHelper contract, SimGameState simgame)
 {
     if (turret == null || turret.allComponents != null)
     {
         foreach (var component in turret.allComponents)
         {
             var chance = simgame.NetworkRandom.Float();
             if (component.DamageLevel != ComponentDamageLevel.Destroyed && chance < Control.Settings.SalvageTurretsComponentChance)
             {
                 Control.LogDebug($"--- {chance:0.000} < {Control.Settings.SalvageTurretsComponentChance:0.00}");
                 contract.AddComponentToPotentialSalvage(component.componentDef, component.DamageLevel, true);
             }
             else
             {
                 Control.LogDebug($"--- {chance:0.000} > {Control.Settings.SalvageTurretsComponentChance:0.00} - {component.defId} skipped");
             }
         }
     }
 }