public void DebugParentsChildrenFlight() { LaunchVehicle launchVehicle = null; Payload payload = null; QuickLauncher.Instance.Split(FlightGlobals.ActiveVessel.parts, out launchVehicle, out payload); payload.DebugParts(); launchVehicle.DebugParts(); }
public void DebugParentsChildrenEditor() { LaunchVehicle launchVehicle = null; Payload payload = null; QuickLauncher.Instance.Split(EditorLogic.SortedShipList, out launchVehicle, out payload); payload.DebugParts(); launchVehicle.DebugParts(); }
public void RestoreResources(LaunchVehicle launchVehicle) { for (int i = 0; i < parts.Count; i++) { ProtoPartSnapshot protoPart = parts[i]; Part vesselPart = launchVehicle.parts[i]; foreach (ProtoPartResourceSnapshot protoResource in protoPart.resources) { string resourceName = protoResource.resourceName; double amount = protoResource.amount; Debug.Log(string.Format("[BeenThereDoneThat]: Found resource {0}: amount: {1}", resourceName, amount)); PartResource partResource = vesselPart.Resources.Get(resourceName); partResource.amount = amount; GameEvents.onPartResourceListChange.Fire(vesselPart); } } }
public ProtoVessel LoadLaunchProtoVessel(Vessel vessel) { LaunchVehicle launchVehicle = null; Payload payload = null; if (!QuickLauncher.Instance.Split(vessel.parts, out launchVehicle, out payload)) { return(null); } int key = launchVehicle.GetHashCode(); if (!quickLaunchVessels.ContainsKey(key)) { return(null); } return(quickLaunchVessels[key].launchProtoVessel); }
public void OnStartMission(Vessel vessel) { if (vessel.situation != Vessel.Situations.PRELAUNCH) { ScreenMessages.PostScreenMessage("Can't start, must be pre-launch!", 4, ScreenMessageStyle.UPPER_CENTER); return; } QuickLaunchMissionTracker tracker = vessel.GetComponent <QuickLaunchMissionTracker>(); LaunchVehicle launchVehicle = null; Payload payload = null; if (tracker.isTracking) { ScreenMessages.PostScreenMessage("Already tracking!", 4, ScreenMessageStyle.UPPER_CENTER); return; } if (!QuickLauncher.Instance.Split(vessel.parts, out launchVehicle, out payload)) { ScreenMessages.PostScreenMessage("No payload separator available", 4, ScreenMessageStyle.UPPER_CENTER); return; } QuickLaunchVessel quickLaunchVessel = null; if (quickLaunchVessels.TryGetValue(launchVehicle.GetHashCode(), out quickLaunchVessel)) { string vesselName = quickLaunchVessel.name; tracker.StartTracking(vesselName); ScreenMessages.PostScreenMessage(string.Format("Started tracking {0}", vesselName), 4, ScreenMessageStyle.UPPER_CENTER); return; } else { startMissionDialog = StartMissionDialog.Create(OnStartMissionDialogDismiss, vessel, launchVehicle, tracker); } }
public bool Split(List <Part> parts, out LaunchVehicle launchVehicle, out Payload payload) { Part payloadSeparator = FindPayloadSeparatorPart(parts); if (payloadSeparator == null) { Debug.Log("[BeenThereDoneThat]: No payloadseparator found"); launchVehicle = null; payload = null; return(false); } Part root = parts[0].localRoot; List <Part> payloadParts = new List <Part>(); List <Part> launchVehicleParts = new List <Part>(); PartTreeHelper.AddBreadthFirst(root, payloadParts, payloadSeparator); PartTreeHelper.AddBreadthFirst(payloadSeparator, launchVehicleParts); launchVehicle = new LaunchVehicle(payloadSeparator, launchVehicleParts); payload = new Payload(payloadParts); return(true); }
public void OnQuickLaunchMission(Vessel vessel) { LaunchVehicle launchVehicle = null; Payload payload = null; if (!QuickLauncher.Instance.Split(vessel.parts, out launchVehicle, out payload)) { ScreenMessages.PostScreenMessage("No payload separator available", 4, ScreenMessageStyle.UPPER_CENTER); return; } int key = launchVehicle.GetHashCode(); if (!quickLaunchVessels.ContainsKey(key)) { ScreenMessages.PostScreenMessage("No missions available", 4, ScreenMessageStyle.UPPER_CENTER); return; } QuickLaunchVessel quickLaunchVessel = quickLaunchVessels[key]; quickLaunchMissionDialog = QuickLaunchMissionDialog.Create(OnQuickLaunchDialogDismissed, quickLaunchVessel, vessel); }
public void RemoveBurnedParts(LaunchVehicle launchVehicle) { if (parts.Count < launchVehicle.parts.Count) { int offset = launchVehicle.separator.separationIndex - separator.separationIndex; int sepearationIndexCutoff = maxSeparationIndex + offset; int diff = launchVehicle.parts.Count - parts.Count; int count = 0; List <Part> toDie = new List <Part>(); Debug.Log(string.Format("[BeenThereDoneThat]: Removing {0} burned parts below stage {1}", diff, maxSeparationIndex)); foreach (Part vesselPart in launchVehicle.parts) { if (vesselPart.separationIndex > sepearationIndexCutoff) { Debug.Log(string.Format("[BeenThereDoneThat]: Removing part {0}", vesselPart.name)); toDie.Add(vesselPart); count++; } } if (count != diff) { Debug.Log(string.Format("[BeenThereDoneThat]: Expected to remove {0} but got {1} parts", diff, count)); } else { foreach (Part spent in toDie) { spent.Die(); } } } else { Debug.Log("[BeenThereDoneThat]: No parts to remove"); } }
public bool Equals(LaunchVehicle launchVehicle) { return(launchVehicle.GetHashCode() == GetHashCode()); }
public static StartMissionDialog Create(Callback onDismissMenu, Vessel vessel, LaunchVehicle launchVehicle, QuickLaunchMissionTracker tracker) { GameObject gameObject = new GameObject("BeenThereDoneThat mission start menu"); StartMissionDialog startMissionDialog = gameObject.AddComponent <StartMissionDialog>(); startMissionDialog.onDismissCallback = onDismissMenu; startMissionDialog.launchVehicleName = vessel.GetDisplayName(); startMissionDialog.vessel = vessel; startMissionDialog.launchVehicle = launchVehicle; startMissionDialog.tracker = tracker; return(startMissionDialog); }