public static MechDef GetSalvageRedirect(SimGameState s, MechDef m) { if (!SimpleMechAssembly_Main.Settings.UseOnlyCCAssemblyOptions) { if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMechPartSalvageRedirect.TryGetValue(m.Description.Id, out string red)) { if (s.DataManager.MechDefs.TryGet(red, out MechDef n) && n != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (settings): {m.Description.Id}->{red}"); return(n); } } string c = m.MechTags.FirstOrDefault((x) => x.StartsWith("mech_MechPartSalvageRedirect_")); if (c != null) { c = c.Replace("mech_MechPartSalvageRedirect_", ""); if (s.DataManager.MechDefs.TryGet(c, out MechDef n) && n != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (tag): {m.Description.Id}->{c}"); return(n); } } } IAssemblyVariant v = CCIntegration.GetCCAssemblyVariant(m.Chassis); if (v != null && v.Lootable != null) { if (s.DataManager.MechDefs.TryGet(v.Lootable, out MechDef o)) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (lootable): {m.Description.Id}->{v.Lootable}"); return(o); } } if (!SimpleMechAssembly_Main.Settings.AllowNonMainVariants && !m.IsMechDefMain()) { MechDef ma = m.Chassis.GetMainMechDef(s.DataManager); if (ma != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (main): {m.Description.Id}->{ma.Description.Id}"); return(ma); } } return(m); }