public override void ApplyOutcome(Vessel vessel, SnacksProcessorResult result) { ProtoCrewMember[] astronauts = null; AstronautData astronautData = null; string message = string.Empty; //Get the crew manifest if (result.afftectedAstronauts != null) { astronauts = result.afftectedAstronauts.ToArray(); } else if (vessel.loaded) { astronauts = vessel.GetVesselCrew().ToArray(); } else { astronauts = vessel.protoVessel.GetVesselCrew().ToArray(); } //Select random crew if needed if (selectRandomCrew) { int randomIndex = UnityEngine.Random.Range(0, astronauts.Length - 1); astronauts = new ProtoCrewMember[] { astronauts[randomIndex] }; } //Go through each kerbal and set their condition for (int index = 0; index < astronauts.Length; index++) { astronautData = SnacksScenario.Instance.GetAstronautData(astronauts[index]); astronautData.SetCondition(conditionName); //If the vessel is loaded then remove skills if (vessel.loaded) { SnacksScenario.Instance.RemoveSkillsIfNeeded(astronauts[index]); } //Inform player if (!string.IsNullOrEmpty(playerMessage)) { message = vessel.vesselName + ": " + astronauts[index].name + " " + playerMessage; ScreenMessages.PostScreenMessage(message, 5.0f, ScreenMessageStyle.UPPER_LEFT); } } //Call the base class base.ApplyOutcome(vessel, result); }
protected void onRosterResourceUpdated(Vessel vessel, SnacksRosterResource rosterResource, AstronautData astronautData, ProtoCrewMember astronaut) { //Make sure it's a resource we're interested in. if (!rosterResource.resourceName.Contains(StressConditionName)) { return; } //If the resource has gone down below max, then remove the stress condition. if (rosterResource.amount < rosterResource.maxAmount && astronautData.conditionSummary.Contains(StressConditionName)) { astronautData.ClearCondition(StressConditionName); SnacksScenario.Instance.RestoreSkillsIfNeeded(astronaut); ScreenMessages.PostScreenMessage(astronaut.name + " " + StressRecoveryMessage, 5.0f, ScreenMessageStyle.UPPER_LEFT); } //If the resource has maxed out then add the stress condition else if (rosterResource.amount >= rosterResource.maxAmount && !astronautData.conditionSummary.Contains(StressConditionName)) { astronautData.SetCondition(StressConditionName); SnacksScenario.Instance.RemoveSkillsIfNeeded(astronaut); ScreenMessages.PostScreenMessage(vessel.vesselName + ": " + astronaut.name + " " + StressPlayerMessage, 5.0f, ScreenMessageStyle.UPPER_LEFT); } }