예제 #1
0
        private IEnumerator launch_complete_construct()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                yield break;
            }
            while (!FlightGlobals.ready)
            {
                yield return(null);
            }
            vessel_spawner.BeginLaunch();
            yield return(null);

            //save the game
            GroundConstructionScenario.SaveGame(Kit.Name + "-before_launch");
            yield return(null);

            yield return(new WaitForFixedUpdate());

            //load ship construct and launch it
            var construct = Kit.LoadConstruct();

            if (construct == null)
            {
                Utils.Log("Unable to load ShipConstruct {}. "
                          + "This usually means that some parts are missing "
                          + "or some modules failed to initialize.",
                          Kit.Name);
                Utils.Message("Something went wrong. Constructed ship cannot be launched.");
                vessel_spawner.AbortLaunch();
                yield break;
            }
            enable_damper();
            var bounds          = new Metric((IShipconstruct)construct, world_space: true).bounds;
            var spawn_transform = SpawnManager.GetSpawnTransform(bounds, out var spawn_offset);

            vessel_spawner.SpawnShipConstruct(construct,
                                              spawn_transform,
                                              spawn_offset
                                              - bounds.center
                                              + construct.Parts[0].localRoot.transform.position,
                                              Vector3.zero,
                                              null,
                                              null,
                                              null,
                                              Kit.TransferCrewToKit);
            yield return(vessel_spawner.WaitForLaunch);

            Kit = new VesselKit();
            Open();
        }
예제 #2
0
        IEnumerator <YieldInstruction> launch_complete_construct()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                yield break;
            }
            while (!FlightGlobals.ready)
            {
                yield return(null);
            }
            vessel_spawner.BeginLaunch();
            yield return(null);

            //save the game
            Utils.SaveGame(Kit.Name + "-before_launch");
            yield return(null);

            //load ship construct and launch it
            var construct = Kit.LoadConstruct();

            if (construct == null)
            {
                Utils.Log("Unable to load ShipConstruct {}. " +
                          "This usually means that some parts are missing " +
                          "or some modules failed to initialize.", Kit.Name);
                Utils.Message("Something whent wrong. Constructed ship cannot be launched.");
                vessel_spawner.AbortLaunch();
                yield break;
            }
            var bounds = new Metric(construct, world_space: true).bounds;

            yield return
                (StartCoroutine(vessel_spawner
                                .SpawnShipConstruct(construct,
                                                    SpawnManager.GetSpawnTransform(bounds),
                                                    SpawnManager.GetSpawnOffset(bounds)
                                                    - bounds.center
                                                    + construct.Parts[0].localRoot.transform.position,
                                                    Vector3.zero,
                                                    null,
                                                    null,
                                                    null,
                                                    Kit.TransferCrewToKit)));

            Kit = new VesselKit();
            Open();
        }
예제 #3
0
        IEnumerator <YieldInstruction> launch_complete_construct()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                yield break;
            }
            while (!FlightGlobals.ready)
            {
                yield return(null);
            }
            vessel_spawner.BeginLaunch();
            //hide UI
            GameEvents.onHideUI.Fire();
            yield return(null);

            //save the game
            GroundConstructionScenario.SaveGame(kit.Name + "-before_launch");
            yield return(null);

            yield return(new WaitForFixedUpdate());

            //load ship construct and launch it
            var construct = kit.LoadConstruct();

            if (construct == null)
            {
                Utils.Log("Unable to load ShipConstruct {}. "
                          + "This usually means that some parts are missing "
                          + "or some modules failed to initialize.",
                          kit.Name);
                Utils.Message("Something went wrong. Constructed ship cannot be launched.");
                GameEvents.onShowUI.Fire();
                vessel_spawner.AbortLaunch();
                yield break;
            }
            model.gameObject.SetActive(false);
            FXMonger.Explode(part, part.partTransform.position, 0);
            yield return(StartCoroutine(launch(construct)));

            GameEvents.onShowUI.Fire();
            part.Die();
        }