/// <summary>
        /// Set the SpaceCenterCam to the location os the current LaunchSite
        /// </summary>
        /// <param name="currentSite"></param>
        internal static void SetSpaceCenterCam(KKLaunchSite currentSite)
        {
            //if (KerbalKonstructs.focusLastLaunchSite && (currentSite.body.name == ConfigUtil.GetCelestialBody("HomeWorld").name))
            if (KerbalKonstructs.focusLastLaunchSite && (currentSite.body == FlightGlobals.currentMainBody))
            {
                float nomHeight = 45f - (float)currentSite.body.GetAltitude(currentSite.staticInstance.transform.position);
                KerbalKonstructs.instance.FuckUpKSP();

                foreach (SpaceCenterCamera2 scCam in Resources.FindObjectsOfTypeAll <SpaceCenterCamera2>())
                {
                    Log.Normal("Resetting to: " + currentSite.LaunchSiteName);
                    scCam.transform.parent             = currentSite.staticInstance.transform;
                    scCam.transform.position           = currentSite.staticInstance.transform.position;
                    scCam.initialPositionTransformName = currentSite.staticInstance.transform.name;
                    scCam.pqsName         = currentSite.body.name;
                    scCam.rotationInitial = currentSite.InitialCameraRotation;
                    scCam.altitudeInitial = nomHeight;
                    scCam.ResetCamera();
                    KerbalKonstructs.scCamWasAltered = true;
                }
            }
            else
            {
                foreach (SpaceCenterCamera2 scCam in Resources.FindObjectsOfTypeAll <SpaceCenterCamera2>())
                {
                    Log.Normal("Resetting to KSC");
                    Upgradeables.UpgradeableObject kscRnD = Resources.FindObjectsOfTypeAll <Upgradeables.UpgradeableObject>().Where(x => x.name == "ResearchAndDevelopment").First();
                    float nomHeight = 45f - (float)ConfigUtil.GetCelestialBody("HomeWorld").GetAltitude(kscRnD.gameObject.transform.position);
                    scCam.transform.parent             = kscRnD.gameObject.transform;
                    scCam.transform.position           = kscRnD.gameObject.transform.transform.position;
                    scCam.initialPositionTransformName = kscRnD.gameObject.transform.name;
                    scCam.pqsName         = ConfigUtil.GetCelestialBody("HomeWorld").name;
                    scCam.altitudeInitial = nomHeight;
                    scCam.rotationInitial = -60;
                    scCam.ResetCamera();
                    KerbalKonstructs.scCamWasAltered = false;
                }
            }

            SetNextMorningPoint(currentSite);

            TuneSCCam();
        }
Esempio n. 2
0
        internal static bool CheckLaunchSiteIsValid(KKLaunchSite site)
        {
            // check for deleted launchsites
            if (site == null)
            {
                return(false);
            }

            if (!KerbalKonstructs.instance.launchFromAnySite && (EditorDriver.editorFacility == EditorFacility.VAB) && (site.LaunchSiteType == SiteType.SPH))
            {
                return(false);
            }
            if (!KerbalKonstructs.instance.launchFromAnySite && (EditorDriver.editorFacility == EditorFacility.SPH) && (site.LaunchSiteType == SiteType.VAB))
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public static List <ProtoVessel> FindVesselsLandedAt2(FlightState flightState, string landedAt)
        {
            float maxDistance       = 100f;
            List <ProtoVessel> list = new List <ProtoVessel>();

            if (flightState != null)
            {
                KKLaunchSite launchSite = LaunchSiteManager.GetLaunchSiteByName(landedAt);

                foreach (ProtoVessel vessel in flightState.protoVessels)
                {
                    if (vessel == null)
                    {
                        continue;
                    }

                    if (launchSite == null || launchSite.isSquad)
                    {
                        if (vessel.landedAt.Contains(landedAt))
                        {
                            list.Add(vessel);
                        }
                    }
                    else
                    {
                        //if (vessel.situation == Vessel.Situations.SPLASHED || vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.PRELAUNCH)
                        //{
                        CelestialBody body     = FlightGlobals.Bodies[vessel.orbitSnapShot.ReferenceBodyIndex];
                        Vector3       position = body.GetWorldSurfacePosition(vessel.latitude, vessel.longitude, vessel.altitude);
                        float         distance = Vector3.Distance(position, launchSite.staticInstance.transform.position);

                        if (distance < maxDistance)
                        {
                            Log.Normal("Found Vessel at Launchsite with distance: " + distance);
                            list.Add(vessel);
                        }
                        //}
                    }
                }
            }
            return(list);
        }
        /// <summary>
        /// Removes the launchSite from the facilities
        /// </summary>
        /// <param name="site"></param>
        internal static void UnregisterLaunchSite(KKLaunchSite site)
        {
            if (site.isOpen)
            {
                CloseLaunchSite(site);
            }

            List <PSystemSetup.SpaceCenterFacility> spaceCenters = PSystemSetup.Instance.SpaceCenterFacilities.ToList();

            PSystemSetup.SpaceCenterFacility spaceToDel = spaceCenters.Where(x => x.facilityName == site.LaunchSiteName).FirstOrDefault();

            if (spaceToDel != null)
            {
                spaceCenters.Remove(spaceToDel);
                PSystemSetup.Instance.SpaceCenterFacilities = spaceCenters.ToArray();
                Log.Normal("Launchsite: " + site.LaunchSiteName + " sucessfully unregistered");
            }

            KKFacilities.Remove(site.spaceCenterFacility);
        }
        internal static void LoadCareerConfig(KKLaunchSite site, ConfigNode cfgNode)
        {
            if (!initialized)
            {
                InitTypes();
            }

            foreach (var field in launchSiteFields.Values)
            {
                if (Attribute.IsDefined(field, typeof(CareerSetting)))
                {
                    ConfigUtil.ReadCFGNode(site, field, cfgNode);
                }
            }
            foreach (var field in launchSiteProperties.Values)
            {
                if (Attribute.IsDefined(field, typeof(CareerSetting)))
                {
                    ConfigUtil.ReadCFGNode(site, field, cfgNode);
                }
            }
        }
Esempio n. 6
0
        // Returns a specific Launchsite, keyed by site.name
        public static KKLaunchSite GetLaunchSiteByName(string siteName)
        {
            KKLaunchSite mySite = null;

            if (checkLaunchSiteExists(siteName))
            {
                foreach (KKLaunchSite site in allLaunchSites)
                {
                    if (site.LaunchSiteName.Equals(siteName))
                    {
                        mySite = site;
                        Log.Normal("found LS: " + mySite.LaunchSiteName);
                    }
                }
                return(mySite);
            }
            else
            {
                Log.UserError("Could not find Launchsite in list: " + siteName);
                return(null);
            }
        }
        internal static void WriteConfig(KKLaunchSite site, ConfigNode cfgNode)
        {
            if (!initialized)
            {
                InitTypes();
            }

            // Close everything before saving.
            site.SetClosed();
            cfgNode.SetValue("FacilityType", site.GetType().Name, true);

            foreach (var field in launchSiteFields)
            {
                if (Attribute.IsDefined(field.Value, typeof(CFGSetting)))
                {
                    if (field.Value.GetValue(site) == null)
                    {
                        continue;
                    }

                    ConfigUtil.Write2CfgNode(site, field.Value, cfgNode);
                }
            }

            foreach (var field in launchSiteProperties)
            {
                if (field.Key == "OpenCloseState")
                {
                    cfgNode.SetValue("OpenCloseState", site.defaultState, true);
                    continue;
                }

                if (Attribute.IsDefined(field.Value, typeof(CFGSetting)))
                {
                    ConfigUtil.Write2CfgNode(site, field.Value, cfgNode);
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Removes the launchSite from the facilities
        /// </summary>
        /// <param name="site"></param>
        internal static void UnregisterLaunchSite(KKLaunchSite site)
        {
            if (site.isOpen)
            {
                CloseLaunchSite(site);
            }

            List <PSystemSetup.SpaceCenterFacility> spaceCenters = new List <PSystemSetup.SpaceCenterFacility>();

            foreach (PSystemSetup.SpaceCenterFacility center in PSystemSetup.Instance.SpaceCenterFacilities)
            {
                if (center.facilityDisplayName == site.LaunchSiteName)
                {
                    Log.Normal("Launchsite: " + site.LaunchSiteName + " sucessfully unregistered");
                    continue;
                }
                else
                {
                    spaceCenters.Add(center);
                }
            }

            PSystemSetup.Instance.SpaceCenterFacilities = spaceCenters.ToArray();
        }
Esempio n. 9
0
        // Returns the nearest Launchsite to a position and range in m to the Launchsite, regardless of whether it is open or closed
        public static KKLaunchSite getNearestBase(GroupCenter center, Vector3 position)
        {
            SpaceCenter  KSC              = SpaceCenter.Instance;
            var          smallestDist     = Vector3.Distance(KSC.gameObject.transform.position, position);
            var          lastSmallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            string       sNearestBase     = "";
            KKLaunchSite lTargetSite      = null;
            KKLaunchSite lLastSite        = null;
            KKLaunchSite lKSC             = null;
            string       sLastNearest     = "";


            foreach (KKLaunchSite site in center.launchsites)
            {
                if (site.staticInstance.gameObject == null)
                {
                    continue;
                }

                var radialposition = site.staticInstance.gameObject.transform.position;
                var dist           = Vector3.Distance(position, radialposition);

                if (radialposition == position)
                {
                    continue;
                }

                if (site.LaunchSiteName == "Runway" || site.LaunchSiteName == "LaunchPad")
                {
                    lKSC = site;
                }
                else
                {
                    if ((float)dist < (float)smallestDist)
                    {
                        sLastNearest     = sNearestBase;
                        lLastSite        = lTargetSite;
                        lastSmallestDist = smallestDist;
                        sNearestBase     = site.LaunchSiteName;
                        smallestDist     = dist;
                        lTargetSite      = site;
                    }
                    else if (dist < lastSmallestDist)
                    {
                        sLastNearest     = site.LaunchSiteName;
                        lastSmallestDist = dist;
                        lLastSite        = site;
                    }
                }
            }

            if (sNearestBase.Length == 0)
            {
                sNearestBase = "KSC";
                lTargetSite  = lKSC;
            }
            if (sLastNearest.Length == 0)
            {
                sLastNearest = "KSC";
                lLastSite    = lKSC;
            }

            rangeNearestBase = (float)smallestDist;

            return(lTargetSite);
        }
Esempio n. 10
0
        // Returns the nearest open Launchsite to a position and range to the Launchsite in m
        // The basic ATC feature is in here for now
        public static void GetNearestOpenBase(Vector3 position, out string sBase, out float flRange, out KKLaunchSite lNearest)
        {
            SpaceCenter  KSC          = SpaceCenter.Instance;
            var          smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            string       sNearestBase = "";
            KKLaunchSite lNearestBase = null;
            KKLaunchSite lKSC         = null;

            foreach (KKLaunchSite site in allLaunchSites)
            {
                if (site.isOpen)
                {
                    var radialposition = site.staticInstance.transform.position;
                    var dist           = Vector3.Distance(position, radialposition);

                    if (site.LaunchSiteName == "Runway")
                    {
                        if (lNearestBase == null)
                        {
                            lNearestBase = site;
                        }

                        lKSC = site;
                    }
                    else
                    if (site.LaunchSiteName != "LaunchPad")
                    {
                        if ((float)dist < (float)smallestDist)
                        {
                            {
                                sNearestBase = site.LaunchSiteName;
                                lNearestBase = site;
                                smallestDist = dist;
                            }
                        }
                    }
                    else
                    {
                        lKSC = site;
                    }
                }
            }

            if (sNearestBase.Length == 0)
            {
                sNearestBase = "KSC";
                lNearestBase = lKSC;
            }

            rangeNearestOpenBase = (float)smallestDist;

            // Air traffic control messaging
            if (LandingGuideUI.instance.IsOpen())
            {
                if (sNearestBase != nearestOpenBase)
                {
                    if (rangeNearestOpenBase < 25000)
                    {
                        nearestOpenBase = sNearestBase;
                        MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.BLUE;
                        MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You have entered the airspace of " + sNearestBase + " ATC. Please keep this channel open and obey all signal lights. Thank you. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE);
                        MessageSystem.Instance.AddMessage(m);
                    }
                    else
                    if (nearestOpenBase.Length != 0)
                    {
                        // you have left ...
                        MessageSystemButton.MessageButtonColor color = MessageSystemButton.MessageButtonColor.GREEN;
                        MessageSystem.Message m = new MessageSystem.Message("KK ATC", "You are now leaving the airspace of " + sNearestBase + ". Safe journey. " + sNearestBase + " Air Traffic Control out.", color, MessageSystemButton.ButtonIcons.MESSAGE);
                        MessageSystem.Instance.AddMessage(m);
                        nearestOpenBase = "";
                    }
                }
            }

            sBase    = sNearestBase;
            flRange  = rangeNearestOpenBase;
            lNearest = lNearestBase;
        }
Esempio n. 11
0
 // Returns the distance in m from a position to a specified Launchsite
 public static float getDistanceToBase(Vector3 position, KKLaunchSite site)
 {
     return(Vector3.Distance(position, site.staticInstance.transform.position));
 }
Esempio n. 12
0
        /// <summary>
        /// Registers the a created LaunchSite to the PSystemSetup and LaunchSiteManager
        /// </summary>
        /// <param name="site"></param>
        internal static void RegisterLaunchSite(KKLaunchSite site)
        {
            if (string.IsNullOrEmpty(site.LaunchSiteName))
            {
                Log.UserWarning("No LaunchSiteName specified:" + site);
                return;
            }


            if (site.isSquad)
            {
                if (site.staticInstance.mesh.transform.Find(site.LaunchPadTransform) == null)
                {
                    Log.UserWarning("Launch pad transform \"" + site.LaunchPadTransform + "\" missing for " + site.LaunchSiteName);
                    return;
                }
            }
            else
            {
                if (site.staticInstance.model.prefab.transform.Find(site.LaunchPadTransform) == null)
                {
                    Log.UserWarning("Launch pad transform \"" + site.LaunchPadTransform + "\" missing for " + site.LaunchSiteName);
                    return;
                }
            }

            KKFacilities = PSystemSetup.Instance.SpaceCenterFacilities.ToList();
            if (KKFacilities.Where(fac => fac.facilityName == site.LaunchSiteName).FirstOrDefault() != null)
            {
                Log.Error("Launch site " + site.LaunchSiteName + " already exists.");
            }


            //site.staticInstance.gameObject.transform.name = site.LaunchSiteName;
            //site.staticInstance.gameObject.name = site.LaunchSiteName;
            Log.Normal("Registering LaunchSite: " + site.LaunchSiteName + " isHidden: " + site.LaunchSiteIsHidden);
            PSystemSetup.SpaceCenterFacility spaceCenterFacility = new PSystemSetup.SpaceCenterFacility();
            spaceCenterFacility.name = site.LaunchSiteName;
            spaceCenterFacility.facilityDisplayName = site.LaunchSiteName;
            spaceCenterFacility.facilityName        = site.LaunchSiteName;
            spaceCenterFacility.facilityPQS         = site.staticInstance.CelestialBody.pqsController;
            spaceCenterFacility.hostBody            = site.staticInstance.CelestialBody;
            spaceCenterFacility.facilityTransform   = site.staticInstance.mesh.transform;
            if (site.LaunchSiteType == SiteType.VAB)
            {
                spaceCenterFacility.editorFacility = EditorFacility.VAB;
            }
            else
            {
                spaceCenterFacility.editorFacility = EditorFacility.SPH;
            }
            spaceCenterFacility.pqsName = site.body.pqsController.name;


            //if (site.staticInstance.groupCenter == null)
            //{
            //    spaceCenterFacility.facilityTransformName = site.staticInstance.gameObject.name;
            //}
            //else
            //{
            //    spaceCenterFacility.facilityTransformName = site.staticInstance.groupCenter.gameObject.name + "/" + site.staticInstance.gameObject.name + "/Mesh";
            //}
            // newFacility.facilityTransform = site.lsGameObject.transform.Find(site.LaunchPadTransform);
            //     newFacility.facilityTransformName = instance.gameObject.transform.name;

            PSystemSetup.SpaceCenterFacility.SpawnPoint spawnPoint = new PSystemSetup.SpaceCenterFacility.SpawnPoint
            {
                name = site.LaunchSiteName,
                spawnTransformURL = site.LaunchPadTransform
            };
            spawnPoint.Setup(spaceCenterFacility);
            spawnPoint.SetSpawnPointLatLonAlt();
            spaceCenterFacility.spawnPoints = new PSystemSetup.SpaceCenterFacility.SpawnPoint[] { spawnPoint };

            //spaceCenterFacility.Setup(new PQS[] { site.staticInstance.CelestialBody.pqsController });

            KKFacilities.Add(spaceCenterFacility);
            KKFacilities.Sort(delegate(PSystemSetup.SpaceCenterFacility a, PSystemSetup.SpaceCenterFacility b)
            {
                if (a.editorFacility == EditorFacility.None)
                {
                    return(1);
                }
                return((a.facilityDisplayName).CompareTo(b.facilityDisplayName));
            });

            PSystemSetup.Instance.SpaceCenterFacilities = KKFacilities.ToArray();
            site.spaceCenterFacility = spaceCenterFacility;

            if (site.staticInstance.destructible != null)
            {
                ScenarioDestructibles.RegisterDestructible(site.staticInstance.destructible, site.LaunchSiteName);
            }

            AddLaunchSite(site);

            if (site.staticInstance.gameObject != null)
            {
                CustomSpaceCenter.CreateFromLaunchsite(site);
            }


            //if (PSystemSetup.Instance.SpaceCenterFacilities.ToList().Where(fac => fac.facilityName == site.LaunchSiteName).FirstOrDefault() != null)
            //{
            //    Log.Normal("LaunchSite registered: " + site.LaunchSiteName);
            //}
            //else
            //{
            //    Log.Normal("LaunchSite registration failed: " + site.LaunchSiteName);
            //}
        }
        // Returns the nearest Launchsite to a position and range in m to the Launchsite, regardless of whether it is open or closed
        public static void getNearestBase(Vector3 position, out string sBase, out string sBase2, out float flRange, out KKLaunchSite lSite, out KKLaunchSite lSite2)
        {
            SpaceCenter  KSC              = SpaceCenter.Instance;
            var          smallestDist     = Vector3.Distance(KSC.gameObject.transform.position, position);
            var          lastSmallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            string       sNearestBase     = "";
            KKLaunchSite lTargetSite      = null;
            KKLaunchSite lLastSite        = null;
            KKLaunchSite lKSC             = null;
            string       sLastNearest     = "";


            foreach (KKLaunchSite site in allLaunchSites)
            {
                if (site.lsGameObject == null)
                {
                    continue;
                }

                var radialposition = site.lsGameObject.transform.position;
                var dist           = Vector3.Distance(position, radialposition);

                if (radialposition == position)
                {
                    continue;
                }

                if (site.LaunchSiteName == "Runway" || site.LaunchSiteName == "LaunchPad")
                {
                    lKSC = site;
                }
                else
                {
                    if ((float)dist < (float)smallestDist)
                    {
                        sLastNearest     = sNearestBase;
                        lLastSite        = lTargetSite;
                        lastSmallestDist = smallestDist;
                        sNearestBase     = site.LaunchSiteName;
                        smallestDist     = dist;
                        lTargetSite      = site;
                    }
                    else if (dist < lastSmallestDist)
                    {
                        sLastNearest     = site.LaunchSiteName;
                        lastSmallestDist = dist;
                        lLastSite        = site;
                    }
                }
            }

            if (sNearestBase == "")
            {
                sNearestBase = "KSC";
                lTargetSite  = lKSC;
            }
            if (sLastNearest == "")
            {
                sLastNearest = "KSC";
                lLastSite    = lKSC;
            }

            rangeNearestBase = (float)smallestDist;

            sBase   = sNearestBase;
            sBase2  = sLastNearest;
            flRange = rangeNearestBase;
            lSite   = lTargetSite;
            lSite2  = lLastSite;
        }
 internal static void RegisterLaunchSitesStock(KKLaunchSite site)
 {
     SetupKSPFacilities();
 }
        /// <summary>
        /// Registers the a created LaunchSite to the PSystemSetup and LaunchSiteManager
        /// </summary>
        /// <param name="site"></param>
        internal static void RegisterLaunchSite(KKLaunchSite site, bool isSquad = false)
        {
            if (!string.IsNullOrEmpty(site.LaunchSiteName) && site.lsGameObject.transform.Find(site.LaunchPadTransform) != null)
            {
                site.lsGameObject.transform.name = site.LaunchSiteName;
                site.lsGameObject.name           = site.LaunchSiteName;

                if (KKFacilities == null)
                {
                    KKFacilities = PSystemSetup.Instance.SpaceCenterFacilities.ToList();
                }

                if (KKFacilities.Where(fac => fac.facilityName == site.LaunchSiteName).FirstOrDefault() == null)
                {
                    //Log.Normal("Registering LaunchSite: " + site.LaunchSiteName);
                    PSystemSetup.SpaceCenterFacility spaceCenterFacility = new PSystemSetup.SpaceCenterFacility();
                    spaceCenterFacility.name = site.LaunchSiteName;
                    spaceCenterFacility.facilityDisplayName   = site.LaunchSiteName;
                    spaceCenterFacility.facilityName          = site.LaunchSiteName;
                    spaceCenterFacility.facilityPQS           = site.staticInstance.CelestialBody.pqsController;
                    spaceCenterFacility.facilityTransformName = site.staticInstance.gameObject.name;
                    // newFacility.facilityTransform = site.lsGameObject.transform.Find(site.LaunchPadTransform);
                    //     newFacility.facilityTransformName = instance.gameObject.transform.name;
                    spaceCenterFacility.pqsName = site.body.pqsController.name;
                    PSystemSetup.SpaceCenterFacility.SpawnPoint spawnPoint = new PSystemSetup.SpaceCenterFacility.SpawnPoint();
                    spawnPoint.name = site.LaunchSiteName;
                    spawnPoint.spawnTransformURL       = site.LaunchPadTransform;
                    spaceCenterFacility.spawnPoints    = new PSystemSetup.SpaceCenterFacility.SpawnPoint[1];
                    spaceCenterFacility.spawnPoints[0] = spawnPoint;
                    if (site.LaunchSiteType == SiteType.VAB)
                    {
                        spaceCenterFacility.editorFacility = EditorFacility.VAB;
                    }
                    else
                    {
                        spaceCenterFacility.editorFacility = EditorFacility.SPH;
                    }

                    KKFacilities.Add(spaceCenterFacility);
                    site.spaceCenterFacility = spaceCenterFacility;

                    AddLaunchSite(site);
                }
                else
                {
                    Log.Error("Launch site " + site.LaunchSiteName + " already exists.");
                }

                RegisterLaunchSitesStock(site);


                if (site.staticInstance.gameObject != null)
                {
                    CustomSpaceCenter.CreateFromLaunchsite(site);
                }
            }
            else
            {
                Log.UserWarning("Launch pad transform \"" + site.LaunchPadTransform + "\" missing for " + site.LaunchSiteName);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Set the SpaceCenterCam to the location os the current LaunchSite
        /// </summary>
        /// <param name="currentSite"></param>
        internal static void SetSpaceCenterCam(KKLaunchSite currentSite)
        {
            if (KerbalKonstructs.focusLastLaunchSite && (currentSite.body.name == ConfigUtil.GetCelestialBody("HomeWorld").name))
            {
                foreach (SpaceCenterCamera2 scCam in Resources.FindObjectsOfTypeAll <SpaceCenterCamera2>())
                {
                    Log.Normal("Restting to: " + currentSite.LaunchSiteName);
                    scCam.transform.parent             = currentSite.lsGameObject.transform;
                    scCam.transform.position           = currentSite.lsGameObject.transform.position;
                    scCam.initialPositionTransformName = currentSite.lsGameObject.transform.name;
                    scCam.pqsName         = currentSite.body.name;
                    scCam.rotationInitial = currentSite.InitialCameraRotation;
                    scCam.ResetCamera();
                    KerbalKonstructs.scCamWasAltered = true;
                }
            }
            else
            {
                foreach (SpaceCenterCamera2 scCam in Resources.FindObjectsOfTypeAll <SpaceCenterCamera2>())
                {
                    Log.Normal("Restting to KSC");
                    Upgradeables.UpgradeableObject kscRnD = Resources.FindObjectsOfTypeAll <Upgradeables.UpgradeableObject>().Where(x => x.name == "ResearchAndDevelopment").First();
                    scCam.transform.parent             = kscRnD.gameObject.transform;
                    scCam.transform.position           = kscRnD.gameObject.transform.transform.position;
                    scCam.initialPositionTransformName = kscRnD.gameObject.transform.name;
                    scCam.pqsName         = ConfigUtil.GetCelestialBody("HomeWorld").name;
                    scCam.rotationInitial = -60;
                    scCam.ResetCamera();
                    KerbalKonstructs.scCamWasAltered = false;
                }
            }

            if (currentSite.LaunchSiteName == "Runway" || currentSite.LaunchSiteName == "LaunchPad" || currentSite.body.name != ConfigUtil.GetCelestialBody("HomeWorld").name)
            {
                foreach (SpaceCenterCamera2 cam in Resources.FindObjectsOfTypeAll(typeof(SpaceCenterCamera2)))
                {
                    cam.altitudeInitial = 45f;
                    cam.ResetCamera();
                }
            }
            else
            {
                PQSCity sitePQS = currentSite.staticInstance.pqsCity;

                foreach (SpaceCenterCamera2 cam in Resources.FindObjectsOfTypeAll(typeof(SpaceCenterCamera2)))
                {
                    if (sitePQS.repositionToSphere || sitePQS.repositionToSphereSurface)
                    {
                        double nomHeight = currentSite.body.pqsController.GetSurfaceHeight((Vector3d)sitePQS.repositionRadial.normalized) - currentSite.body.Radius;
                        if (sitePQS.repositionToSphereSurface)
                        {
                            nomHeight += sitePQS.repositionRadiusOffset;
                        }
                        cam.altitudeInitial = 0f - (float)nomHeight;
                    }
                    else
                    {
                        cam.altitudeInitial = 0f - (float)sitePQS.repositionRadiusOffset;
                    }
                    cam.ResetCamera();
                    Log.Normal("fixed the Space Center camera.");
                }
            }
            SetNextMorningPoint(currentSite);
        }