diff --git a/BTSimpleMechAssembly/SimpleMechAssembly_Patches.cs b/BTSimpleMechAssembly/SimpleMechAssembly_Patches.cs index 63c29d3..3a4c833 100644 --- a/BTSimpleMechAssembly/SimpleMechAssembly_Patches.cs +++ b/BTSimpleMechAssembly/SimpleMechAssembly_Patches.cs @@ -32,7 +32,8 @@ public static bool Prefix(SimGameState __instance, string id) MechDef d = __instance.DataManager.MechDefs.Get(id); int p = SimpleMechAssembly_Main.GetNumPartsForAssembly(__instance, d); if (p >= __instance.Constants.Story.DefaultMechPartMax) - SimpleMechAssembly_Main.QueryMechAssemblyPopup(__instance, d, null); + //SimpleMechAssembly_Main.QueryMechAssemblyPopup(__instance, d, null); + __instance.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(__instance, d, null), true); } return false; // completely replace @@ -90,8 +91,8 @@ public static bool Prefix(MechBayChassisInfoWidget __instance, ChassisDef ___sel .AddFader(new UIColorRef?(LazySingletonBehavior.Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); return false; } - SimpleMechAssembly_Main.QueryMechAssemblyPopup(___mechBay.Sim, d, ___mechBay); - //___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, ___mechBay), true); + //SimpleMechAssembly_Main.QueryMechAssemblyPopup(___mechBay.Sim, d, ___mechBay); + ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, ___mechBay), true); return false; } if (___selectedChassis.MechPartCount < ___selectedChassis.MechPartMax) diff --git a/BTSimpleMechAssembly/SimpleMechAssembly_Settings.cs b/BTSimpleMechAssembly/SimpleMechAssembly_Settings.cs index 48c184e..865ed5f 100644 --- a/BTSimpleMechAssembly/SimpleMechAssembly_Settings.cs +++ b/BTSimpleMechAssembly/SimpleMechAssembly_Settings.cs @@ -22,5 +22,6 @@ class SimpleMechAssembly_Settings public int StructurePointBasedSalvageMaxPartsFromMech = 3; public int StructurePointBasedSalvageMinPartsFromMech = 1; public bool StructurePointBasedSalvageVanillaComponents = false; + public string[] StructurePointBasedSalvageSalvageBlacklist = new string[] { }; } } diff --git a/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs b/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs index d6f13e3..8253de3 100644 --- a/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs +++ b/BTSimpleMechAssembly/SimpleMechAssembly_StructurePointBasedSalvage.cs @@ -66,7 +66,7 @@ public static bool Prefix(Contract __instance, List enemyMechs, List log.Log($"generating salvage for vehicle {d.Chassis.Description.Name}"); foreach (VehicleComponentRef r in d.Inventory) { - log.Log(string.Format("added salvage {0} from nondestroyed loc", r.Def.Description.Id)); + log.Log(string.Format("added salvage {0}", r.Def.Description.Id)); AddUpgradeToSalvage(__instance, r.Def, s, ___finalPotentialSalvage); } } @@ -116,7 +116,7 @@ private static void GenerateSalvageForMech(Contract __instance, UnitResult u, Si } float left = currstruct / maxstruct; int maxparts = Math.Min(s.Constants.Story.DefaultMechPartMax, SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMaxPartsFromMech); - int minparts = 1; + int minparts = SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMinPartsFromMech; float parts = left * maxparts; log.Log(string.Format("calculated parts {0}, ct is {1} of total points", parts, u.mech.GetChassisLocationDef(ChassisLocations.CenterTorso).InternalStructure * SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageHighPriorityFactor / maxstruct)); float fract = parts - (float) Math.Floor(parts); @@ -153,12 +153,22 @@ private static void GenerateSalvageForMech(Contract __instance, UnitResult u, Si private static void AddMechPartSalvage(Contract __instance, MechDef d, SimGameState s, int num, List sal) { + if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageSalvageBlacklist.Contains(d.Description.Id)) + { + SimpleMechAssembly_Main.Log.LogError("skipping, cause its blacklisted by mod.json"); + return; + } object[] arg = new object[] { s.Constants, d, num, sal }; Traverse.Create(__instance).Method("CreateAndAddMechPart", arg).GetValue(arg); } private static void AddUpgradeToSalvage(Contract __instance, MechComponentDef d, SimGameState s, List sal) { + if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageSalvageBlacklist.Contains(d.Description.Id)) + { + SimpleMechAssembly_Main.Log.LogError("skipping, cause its blacklisted by mod.json"); + return; + } if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageVanillaComponents) { object[] args = new object[] { sal, d, ComponentDamageLevel.Functional, false, s.Constants, s.NetworkRandom, true }; diff --git a/BTSimpleMechAssembly/mod.json b/BTSimpleMechAssembly/mod.json index 8fb1cca..29e7337 100644 --- a/BTSimpleMechAssembly/mod.json +++ b/BTSimpleMechAssembly/mod.json @@ -28,6 +28,7 @@ "StructurePointBasedSalvageMaxPartsFromMech": 3, "StructurePointBasedSalvageMinPartsFromMech": 1, /*activate to salvage + parts*/ - "StructurePointBasedSalvageVanillaComponents": false + "StructurePointBasedSalvageVanillaComponents": false, + "StructurePointBasedSalvageSalvageBlacklist": [ "Gear_General_Robinson_TG120_Drive_Train", "Gear_Cockpit_Tacticon_B2000_Battle_Computer" ] } } \ No newline at end of file