public override void ApplyOutcome(Vessel vessel, SnacksProcessorResult result) { ProtoCrewMember[] astronauts; AstronautData astronautData; //Get the astronauts if (vessel.loaded) { astronauts = vessel.GetVesselCrew().ToArray(); } else { astronauts = vessel.protoVessel.GetVesselCrew().ToArray(); } //If crew member has failed too many cycles then it's time to die. List <ProtoCrewMember> doomed = new List <ProtoCrewMember>(); KerbalRoster roster = HighLogic.CurrentGame.CrewRoster; for (int index = 0; index < astronauts.Length; index++) { astronautData = SnacksScenario.Instance.GetAstronautData(astronauts[index]); //Handle exemptions if (astronautData.isExempt) { continue; } //Add to our cleanup list if (astronautData.processedResourceFailures.ContainsKey(resourceName) && astronautData.processedResourceFailures[resourceName] >= cyclesBeforeDeath) { doomed.Add(astronauts[index]); } } //Remove the dead crew int count = doomed.Count; string message = ""; for (int index = 0; index < count; index++) { //Unregister the crew member SnacksScenario.Instance.UnregisterCrew(doomed[index]); //Remove from ship doomed[index].seat.part.RemoveCrewmember(doomed[index]); if (vessel.loaded) { vessel.RemoveCrew(doomed[index]); vessel.CrewListSetDirty(); } else { vessel.protoVessel.RemoveCrew(doomed[index]); vessel.CrewListSetDirty(); } //Mark status astronauts[index].rosterStatus = ProtoCrewMember.RosterStatus.Dead; //Give player the bad news message = astronauts[index].name + " " + playerMessage; Debug.Log("[DeathPenalty] - " + message); ScreenMessages.PostScreenMessage(message, 5.0f, ScreenMessageStyle.UPPER_CENTER); } //Call the base class base.ApplyOutcome(vessel, result); }
public static void CheckDeadKerbals(Vessel vessel) { if (!SnacksProperties.CanStarveToDeath) { return; } int mealsBeforeDeath = SnacksProperties.MealsSkippedBeforeDeath; ProtoCrewMember[] astronauts; AstronautData data; //Get the astronauts if (vessel.loaded) { astronauts = vessel.GetVesselCrew().ToArray(); } else { astronauts = vessel.protoVessel.GetVesselCrew().ToArray(); } //If crew member has gone hungry too many times then it's time to die. List <ProtoCrewMember> doomed = new List <ProtoCrewMember>(); KerbalRoster roster = HighLogic.CurrentGame.CrewRoster; for (int index = 0; index < astronauts.Length; index++) { data = SnacksScenario.Instance.GetAstronautData(astronauts[index]); //Handle exemptions if (data.isExempt) { continue; } //Add to our cleanup list if (data.mealsMissed >= mealsBeforeDeath) { doomed.Add(astronauts[index]); } } //Remove the dead crew int count = doomed.Count; string message = ""; for (int index = 0; index < count; index++) { //Unregister the crew member SnacksScenario.Instance.UnregisterCrew(doomed[index]); //Remove from ship doomed[index].seat.part.RemoveCrewmember(doomed[index]); if (vessel.loaded) { vessel.RemoveCrew(doomed[index]); vessel.CrewListSetDirty(); } else { vessel.protoVessel.RemoveCrew(doomed[index]); vessel.CrewListSetDirty(); } //Mark status astronauts[index].rosterStatus = ProtoCrewMember.RosterStatus.Dead; //Give player the bad news message = astronauts[index].name + kDeathMessage; Debug.Log("[DeathPenalty] - " + message); ScreenMessages.PostScreenMessage(message, 5.0f, ScreenMessageStyle.UPPER_CENTER); } }