/// <summary> /// Starts the simulation with the defined parameters /// </summary> public void StartSimulation() { CalculateComplexity(); //make sure it's up to date SimuLite.Instance.ActivateSimulation(this); setGameUT(); if (SimType == SimulationType.REGULAR) { //start new launch on launchpad/runway startRegularLaunch(); } else { //start new launch in spaaaaacccceee VesselSpawner.VesselData vessel = makeVessel(); Guid?id = null; if ((id = VesselSpawner.CreateVessel(vessel)) != null) { Debug.Log("[SimuLite] Vessel added to world."); //vessel exists, now switch to it FlightDriver.StartAndFocusVessel(HighLogic.CurrentGame, FlightGlobals.Vessels.FindIndex(v => v.id == id)); } else { Debug.Log("[SimuLite] Failed to create vessel."); } } }
private VesselSpawner.VesselData makeVessel() { VesselSpawner.VesselData data = new VesselSpawner.VesselData(); if (SimType == SimulationType.ORBITAL) { data.orbit = new Orbit(Inclination, Eccentricity, (Periapsis + Apoapsis + 2 * SelectedBody.Radius) / 2.0, LongOfAsc, ArgPe, 0, UT.Value, SelectedBody); data.orbit.meanAnomalyAtEpoch = MeanAnomalyAtEpoch; data.altitude = Periapsis; data.orbiting = true; } else { data.orbit = null; data.altitude = null; data.orbiting = false; data.latitude = Latitude; data.longitude = Longitude; } data.body = SelectedBody; data.shipConstruct = Ship; //data.crew = manifest.GetAllCrew(); data.flagURL = EditorLogic.FlagURL; data.owned = true; data.vesselType = VesselType.Ship; foreach (ProtoCrewMember pcm in Crew?.GetAllCrew(false) ?? new List <ProtoCrewMember>()) { if (pcm == null) { continue; } VesselSpawner.CrewData crewData = new VesselSpawner.CrewData(); crewData.name = pcm.name; if (data.crew == null) { data.crew = new List <VesselSpawner.CrewData>(); } data.crew.Add(crewData); } return(data); }