private void OnVesselRecoveryRequested(Vessel vessel) { Log.dbg("entered; vessel: {0}", vessel.name); // Switch tourists back to tourists List <ProtoCrewMember> crewList = vessel.GetVesselCrew(); foreach (ProtoCrewMember crew in crewList) { Log.dbg("crew={0}", crew.name); if (Tourist.isTourist(crew)) { crew.type = ProtoCrewMember.KerbalType.Tourist; } } }
private void OnVesselRecoveredOffGame(ProtoVessel vessel, bool wtf) { Log.dbg("entered; vessel: {0}; wtf: {1}", vessel.vesselName, wtf); // Switch tourists back to tourists List <ProtoCrewMember> crewList = vessel.GetVesselCrew(); foreach (ProtoCrewMember crew in crewList) { Log.dbg("crew={0}", crew.name); if (Tourist.isTourist(crew)) { crew.type = ProtoCrewMember.KerbalType.Tourist; } } }
private void OnVesselRecoveredOffGame(ProtoVessel vessel, bool wtf) { printDebug("entered; vessel: " + vessel.vesselName + "; wtf: " + wtf); // Switch tourists back to tourists List <ProtoCrewMember> crewList = vessel.GetVesselCrew(); foreach (ProtoCrewMember crew in crewList) { printDebug("crew=" + crew.name); if (Tourist.isTourist(crew)) { crew.type = ProtoCrewMember.KerbalType.Tourist; } } }
private void OnEvaStart(GameEvents.FromToAction <Part, Part> evaData) { printDebug("entered; Parts: " + evaData.from + "; " + evaData.to); printDebug("active vessel: " + FlightGlobals.ActiveVessel); Vessel v = evaData.to.vessel; if (!v || !v.evaController) { return; } printDebug("vessel: " + v + "; evaCtl: " + v.evaController); ProtoCrewMember crew = v.GetVesselCrew() [0]; printDebug("crew: " + crew); if (this.tourists == null) { // Why we get here twice with the same data? printDebug("for some reasons tourists is null"); return; } foreach (KeyValuePair <String, Tourist> pair in this.tourists) { printDebug(pair.Key + "=" + pair.Value); } printDebug("roster: " + this.tourists); Tourist t; if (!tourists.TryGetValue(crew.name, out t)) { return; } printDebug("tourist: " + t); if (!Tourist.isTourist(crew) || t.hasAbility("Jetpack")) { return; } evaData.to.RequestResource(v.evaController.propellantResourceName, v.evaController.propellantResourceDefaultAmount); // Set propellantResourceDefaultAmount to 0 for EVAFuel to recognize it. v.evaController.propellantResourceDefaultAmount = 0.0; ScreenMessages.PostScreenMessage(String.Format( "<color=orange>Jetpack propellant drained as tourists of level {0} are not allowed to use it</color>", t.level)); }
private void OnVesselCreate(Vessel vessel) { if (vessel == null) { return; } printDebug("name=" + vessel.GetName()); reinitVessel(vessel); reinitEvents(vessel); if (vessel.evaController == null) { return; } if (!Tourist.isTourist(vessel.GetVesselCrew() [0])) { return; } }
public void OnDestroy() { // Switch tourists back printDebug("entered"); try { if (FlightGlobals.VesselsLoaded == null) { return; } printDebug(String.Format("VesselsLoaded: {0}", FlightGlobals.VesselsLoaded)); foreach (Vessel v in FlightGlobals.VesselsLoaded) { printDebug("restoring vessel " + v.name); List <ProtoCrewMember> crewList = v.GetVesselCrew(); foreach (ProtoCrewMember crew in crewList) { printDebug("restoring crew=" + crew.name); if (Tourist.isTourist(crew)) { crew.type = ProtoCrewMember.KerbalType.Tourist; } } } } catch (NullReferenceException e) { printDebug(String.Format("Got NullRef while attempting to access loaded vessels: {0}", e)); } GameEvents.onVesselGoOffRails.Remove(OnVesselGoOffRails); GameEvents.onFlightReady.Remove(OnFlightReady); GameEvents.onAttemptEva.Remove(OnAttemptEVA); GameEvents.onVesselChange.Remove(OnVesselChange); GameEvents.onVesselWillDestroy.Remove(OnVesselWillDestroy); tourists = null; factory = null; // do we really need this? smile = false; taken = false; fx = null; }
private void checkApproachingGeeLimit() { if (FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.geeForce < 4.0) // Can there be any tourist with Gee force tolerance below that? { if (highGee) { reinitVessel(FlightGlobals.ActiveVessel); highGee = false; ScreenMessages.PostScreenMessage("EVA prohibition cleared"); } return; } if (tourists == null) { return; } foreach (ProtoCrewMember crew in FlightGlobals.ActiveVessel.GetVesselCrew()) { if (!tourists.ContainsKey(crew.name) || // not among tourists !Tourist.isTourist(crew) || // not really a tourist crew.type != ProtoCrewMember.KerbalType.Crew) { // was probably unpromoted continue; } if (crew.gExperienced / ProtoCrewMember.GToleranceMult(crew) > 50000) // Magic number. At 60000 kerbal passes out { printDebug(String.Format("Unpromoting {0} due to high gee", crew.name)); crew.type = ProtoCrewMember.KerbalType.Tourist; ScreenMessages.PostScreenMessage(String.Format( "{0} temporary prohibited from EVA due to experienced high Gee forces", crew.name)); highGee = true; } } }
private void OnEvaStart(GameEvents.FromToAction <Part, Part> evaData) { Log.dbg("entered; KourageousTourists OnEvaStart Parts: {0}; {1}; active vessel: {2}", evaData.from, evaData.to, FlightGlobals.ActiveVessel); Vessel v = evaData.to.vessel; if (!v || !v.evaController) { return; } Log.dbg("vessel: {0}; evaCtl: {1}", v, v.evaController); ProtoCrewMember crew = v.GetVesselCrew() [0]; Log.dbg("crew: {0}", crew); if (this.tourists == null) { // Why we get here twice with the same data? Log.dbg("for some reasons tourists is null"); return; } #if DEBUG foreach (KeyValuePair <String, Tourist> pair in this.tourists) { Log.dbg("{0}={1}", pair.Key, pair.Value); } #endif Log.dbg("roster: {0}", this.tourists.Keys); Tourist t; if (!tourists.TryGetValue(crew.name, out t)) { return; } if (Tourist.isTourist(crew)) { Log.dbg("tourist: {0}", t); } else { Log.error("{0} is not a Tourist. Aborting!", crew); return; } if (!t.hasAbility("Jetpack")) { evaData.to.RequestResource(v.evaController.propellantResourceName, v.evaController.propellantResourceDefaultAmount); // Set propellantResourceDefaultAmount to 0 for EVAFuel to recognize it. v.evaController.propellantResourceDefaultAmount = 0.0; } // SkyDiving... if (t.looksLikeSkydiving(v)) { Log.info("skydiving: {0}, situation: {1}", t.looksLikeSkydiving(v), v.situation); v.evaController.ladderPushoffForce = 50; v.evaController.autoGrabLadderOnStart = false; StartCoroutine(this.deployChute(v)); return; } if (0f == v.evaController.propellantResourceDefaultAmount) { ScreenMessages.PostScreenMessage(String.Format( "<color=orange>Jetpack propellant drained as tourists of level {0} are not allowed to use it</color>", t.level)); } }
private void reinitEvents(Vessel v) { printDebug("entered"); if (v.evaController == null) { return; } KerbalEVA evaCtl = v.evaController; ProtoCrewMember crew = v.GetVesselCrew() [0]; String kerbalName = crew.name; printDebug("evCtl found; checking name: " + kerbalName); Tourist t; if (!tourists.TryGetValue(kerbalName, out t)) { return; } printDebug("among tourists: " + kerbalName); t.smile = false; t.taken = false; if (!Tourist.isTourist(v.GetVesselCrew()[0])) { printDebug("...but is a crew"); return; // not a real tourist } // Change crew type right away to avoid them being crew after recovery crew.type = ProtoCrewMember.KerbalType.Tourist; BaseEventList pEvents = evaCtl.Events; foreach (BaseEvent e in pEvents) { printDebug("disabling event " + e.guiName); e.guiActive = false; e.guiActiveUnfocused = false; e.guiActiveUncommand = false; } // Adding Selfie button BaseEventDelegate slf = new BaseEventDelegate(TakeSelfie); KSPEvent evt = new KSPEvent(); evt.active = true; evt.externalToEVAOnly = true; evt.guiActive = true; evt.guiActiveEditor = false; evt.guiActiveUnfocused = false; evt.guiActiveUncommand = false; evt.guiName = "Take Selfie"; evt.name = "TakeSelfie"; BaseEvent selfie = new BaseEvent(pEvents, "Take Selfie", slf, evt); pEvents.Add(selfie); selfie.guiActive = true; selfie.active = true; foreach (PartModule m in evaCtl.part.Modules) { if (!m.ClassName.Equals("ModuleScienceExperiment")) { continue; } printDebug("science module id: " + ((ModuleScienceExperiment)m).experimentID); // Disable all science foreach (BaseEvent e in m.Events) { e.guiActive = false; e.guiActiveUnfocused = false; e.guiActiveUncommand = false; } foreach (BaseAction a in m.Actions) { a.active = false; } } printDebug("Initializing sound"); // Should we always invalidate cache??? fx = null; getOrCreateAudio(evaCtl.part.gameObject); }