// static functions, that make live a lot easier /// <summary> /// Stores a Vessel into the specified Hangar /// </summary> internal static void StoreVessel(Vessel vessel, Hangar hangar) { StoredVessel storedVessel = new StoredVessel { uuid = vessel.protoVessel.vesselID, vesselName = vessel.GetDisplayName() }; //get the experience and assign the crew to the rooster foreach (Part part in vessel.parts) { int count = part.protoModuleCrew.Count; if (count != 0) { ProtoCrewMember[] crewList = part.protoModuleCrew.ToArray(); for (int i = 0; i < count; i++) { crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Recover); crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Land, FlightGlobals.currentMainBody.name); crewList[i].ArchiveFlightLog(); // remove the crew from the ship part.RemoveCrewmember(crewList[i]); } } } // save the ship storedVessel.vesselNode = new ConfigNode("VESSEL"); //create a backup of the current state, then save that state ProtoVessel backup = vessel.BackupVessel(); backup.Save(storedVessel.vesselNode); // save the stored information in the hangar hangar.storedVessels.Add(storedVessel); // remove the stored vessel from the game vessel.MakeInactive(); vessel.Unload(); //vessel.Die(); FlightGlobals.RemoveVessel(vessel); if (vessel != null) { vessel.protoVessel.Clean(); } //UnityEngine.Object.Destroy(vessel.gameObject); GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); HighLogic.LoadScene(GameScenes.SPACECENTER); }
internal override void LoadCareerConfig(ConfigNode cfgNode) { base.ParseConfig(cfgNode); storedVessels = new List <StoredVessel>(); foreach (ConfigNode resourceNode in cfgNode.GetNodes("StoredVessel")) { StoredVessel storedVessel = new StoredVessel { uuid = Guid.Parse(resourceNode.GetValue("VesselID")), vesselName = resourceNode.GetValue("VesselName"), vesselNode = resourceNode.GetNode("VESSEL") }; storedVessels.Add(storedVessel); } }
internal static Vessel RollOutVessel(StoredVessel storedVessel, Hangar hangar) { if (!hangar.storedVessels.Contains(storedVessel)) { Log.Error("no Stored Vessel found:" + storedVessel.vesselName); return(null); } hangar.storedVessels.Remove(storedVessel); ProtoVessel protoVessel = new ProtoVessel(storedVessel.vesselNode, HighLogic.CurrentGame); protoVessel.Load(HighLogic.CurrentGame.flightState); Vessel vessel = protoVessel.vesselRef; return(vessel); }