public SpaceCenter getSpaceCenter()
		{
			if (spaceCenter == null)
			{
				spaceCenter = gameObject.AddComponent<SpaceCenter>();
				spaceCenter.cb = (CelestialBody)staticObject.getSetting("CelestialBody");
				spaceCenter.name = SpaceCenterName;

				// Debug.Log("KK: getSpaceCenter set spaceCenter.name to " + SpaceCenterName);

				FieldInfo lat = spaceCenter.GetType().GetField("\u0002", BindingFlags.NonPublic | BindingFlags.Instance);
				lat.SetValue(spaceCenter, spaceCenter.cb.GetLatitude(gameObject.transform.position));
				FieldInfo lon = spaceCenter.GetType().GetField("\u0003", BindingFlags.NonPublic | BindingFlags.Instance);
				lon.SetValue(spaceCenter, spaceCenter.cb.GetLongitude(gameObject.transform.position));
				FieldInfo srfVector = spaceCenter.GetType().GetField("\u0004", BindingFlags.NonPublic | BindingFlags.Instance);
				srfVector.SetValue(spaceCenter, spaceCenter.cb.GetRelSurfaceNVector(spaceCenter.Latitude, spaceCenter.Longitude));
			}
			else
			{
				// Debug.Log("KK: getSpaceCenter was not null.");
			}

			return spaceCenter;
		}
		public static void setKSC()
		{
			KSC = SpaceCenter.Instance;
		}
        public static void getClosestSpaceCenter(Vector3 position, out SpaceCenter ClosestCenter, out float ClosestDistance, 
			out float RecoveryFactor, out float RecoveryRange, out string BaseName)
        {
            CustomSpaceCenter closest = null;

            float smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            // Debug.Log("KK: Distance to KSC is " + smallestDist);

            bool isCareer = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                if (!KerbalKonstructs.instance.disableCareerStrategyLayer)
                {
                    isCareer = true;
                    PersistenceFile<LaunchSite>.LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");
                }
            }

            string sOpenCloseState = "Closed";
            string sBaseName = "";
            float fMyBaseRecovFact = 0f;
            float fMyBaseRecovRang = 0f;

            foreach (CustomSpaceCenter csc in spaceCenters)
            {
                if (isCareer)
                {
                    string OpenCloseState;
                    float OpenCost;
                    // ASH Get openclosestate of launchsite with same name as space centre
                    LaunchSiteManager.getSiteOpenCloseState(csc.SpaceCenterName, out OpenCloseState, out OpenCost);
                    sOpenCloseState = OpenCloseState;
                }

                StaticObject myBase = csc.getStaticObject();
                if ((float)myBase.getSetting("RecoveryFactor") == 0) continue;

                float dist = Vector3.Distance(position, csc.getStaticObject().gameObject.transform.position);

                if (dist < smallestDist)
                {
                    bool bBaseIsOpen = true;
                    if (sOpenCloseState == "Closed" || sOpenCloseState == "ClosedLocked" || sOpenCloseState == "OpenLocked") bBaseIsOpen = false;

                    if (isCareer && !bBaseIsOpen)
                    { }
                    else
                    {
                        closest = csc;
                        smallestDist = dist;
                        fMyBaseRecovFact = (float)myBase.getSetting("RecoveryFactor");
                        fMyBaseRecovRang = (float)myBase.getSetting("RecoveryRange");
                        sBaseName = (string)myBase.getSetting("LaunchSiteName");
                        // Debug.Log("KK: closest updated to " + closest.SpaceCenterName + ", distance " + smallestDist);
                    }
                }
            }

            SpaceCenter sc;

            if (closest == null)
                sc = null;
            else
            {
                // Debug.Log("KK: closest is " + closest.SpaceCenterName);
                sc = closest.getSpaceCenter();
            }

            // Debug.Log("KK: smallestDist is " + smallestDist);
            // Debug.Log("KK: returning closest space centre: " + sc.name);

            if (smallestDist < 1) smallestDist = 0;
            if (sc == null)
            {
                sc = KSC;
                fMyBaseRecovFact = 100;
                sBaseName = "KSC";
            }

            ClosestCenter = sc;
            ClosestDistance = smallestDist;
            RecoveryFactor = fMyBaseRecovFact;
            RecoveryRange = fMyBaseRecovRang;
            BaseName = sBaseName;
        }