static void Prefix(SimGameState __instance, Pilot p) { if (p == null || !__instance.PilotRoster.Contains(p)) { return; } Mod.Log.Debug?.Write($"Removing pilot: {p.Name} from company."); CrewDetails details = ModState.GetCrewDetails(p.pilotDef); // Remove any mechtech, medtech, or aerospace points if (details.IsAerospaceCrew) { // Track our skill points Statistic aerospaceSkill = __instance.CompanyStats.GetStatistic(ModStats.Aerospace_Skill); if (aerospaceSkill == null) { aerospaceSkill = __instance.CompanyStats.AddStatistic <int>(ModStats.Aerospace_Skill, 0); } if (aerospaceSkill.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.Aerospace_Skill, StatCollection.StatOperation.Int_Subtract, details.Value); } // Track the crew count Statistic crewCount = __instance.CompanyStats.GetStatistic(ModStats.CrewCount_Aerospace); if (crewCount == null) { crewCount = __instance.CompanyStats.AddStatistic <int>(ModStats.CrewCount_Aerospace, 0); } if (crewCount.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.CrewCount_Aerospace, StatCollection.StatOperation.Int_Subtract, 1); } } else if (details.IsMechTechCrew) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.HBS_Company_MechTech_Skill, StatCollection.StatOperation.Int_Subtract, details.Value); // Track the crew count Statistic crewCount = __instance.CompanyStats.GetStatistic(ModStats.CrewCount_MechTechs); if (crewCount == null) { crewCount = __instance.CompanyStats.AddStatistic <int>(ModStats.CrewCount_MechTechs, 0); } if (crewCount.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.CrewCount_MechTechs, StatCollection.StatOperation.Int_Subtract, 1); } } else if (details.IsMechWarrior) { // Track the crew count Statistic crewCount = __instance.CompanyStats.GetStatistic(ModStats.CrewCount_MechWarriors); if (crewCount == null) { crewCount = __instance.CompanyStats.AddStatistic <int>(ModStats.CrewCount_MechWarriors, 0); } if (crewCount.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.CrewCount_MechWarriors, StatCollection.StatOperation.Int_Subtract, 1); } } else if (details.IsMedTechCrew) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.HBS_Company_MedTech_Skill, StatCollection.StatOperation.Int_Subtract, details.Value); // Track the crew count Statistic crewCount = __instance.CompanyStats.GetStatistic(ModStats.CrewCount_MedTechs); if (crewCount == null) { crewCount = __instance.CompanyStats.AddStatistic <int>(ModStats.CrewCount_MedTechs, 0); } if (crewCount.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.CrewCount_MedTechs, StatCollection.StatOperation.Int_Subtract, 1); } } else if (details.IsVehicleCrew) { // Track the crew count Statistic crewCount = __instance.CompanyStats.GetStatistic(ModStats.CrewCount_VehicleCrews); if (crewCount == null) { crewCount = __instance.CompanyStats.AddStatistic <int>(ModStats.CrewCount_VehicleCrews, 0); } if (crewCount.Value <int>() > 0) { __instance.CompanyStats.ModifyStat <int>(null, -1, ModStats.CrewCount_VehicleCrews, StatCollection.StatOperation.Int_Subtract, 1); } } // Cleanup company state ModState.RemoveCrewDetails(p.pilotDef, details); __instance.RoomManager.RefreshTimeline(false); __instance.RoomManager.RefreshDisplay(); }