ExLP.ExLaunchPad.BuildAndLaunchCraft C# (CSharp) Method

BuildAndLaunchCraft() private method

private BuildAndLaunchCraft ( ) : void
return void
        private void BuildAndLaunchCraft()
        {
            // build craft
            ShipConstruct nship = ShipConstruction.LoadShip(uis.craftfile);

            Vector3 offset = nship.Parts[0].transform.localPosition;
            nship.Parts[0].transform.Translate(-offset);
            string landedAt = "External Launchpad";
            string flag = uis.flagname;
            Game state = FlightDriver.FlightStateCache;
            VesselCrewManifest crew = new VesselCrewManifest ();

            ShipConstruction.CreateBackup(nship);
            ShipConstruction.PutShipToGround(nship, GetLanchTransform());

            ShipConstruction.AssembleForLaunch(nship, landedAt, flag, state, crew);

            Vessel vsl = FlightGlobals.Vessels[FlightGlobals.Vessels.Count - 1];
            FlightGlobals.ForceSetActiveVessel(vsl);
            vsl.Landed = false;

            if (kethane_present && !DebugPad)
            UseResources(vsl);

            if (vessel.situation == Vessel.Situations.ORBITING) {
            HackStruts(vsl);
            uis.vesselInfo = new DockedVesselInfo();
            uis.vesselInfo.name = vsl.vesselName;
            uis.vesselInfo.vesselType = vsl.vesselType;
            uis.vesselInfo.rootPartUId = vsl.rootPart.flightID;
            vsl.rootPart.Couple(part);
            FlightGlobals.ForceSetActiveVessel (vessel);
            } else {
            uis.timer = 3.0f;
            uis.launchee = vsl;
            }

            Staging.beginFlight();
        }

Usage Example

 void FinalizeButton()
 {
     if (GUILayout.Button("Finalize Build", Styles.normal,
                          GUILayout.ExpandWidth(true)))
     {
         pad.BuildAndLaunchCraft();
     }
 }