コード例 #1
0
        public void Awake()
        {
            Debug.Log("TSTGalaxies Galaxies Awake");
            if (Instance != null)
            {
                Destroy(this);
            }
            else
            {
                Instance = this;
            }
            DontDestroyOnLoad(this);

            Debug.Log("TSTGalaxies Starting Galaxies");

            baseTransform = new GameObject();
            baseTransform.transform.localPosition = Vector3.zero;
            baseTransform.transform.localRotation = Quaternion.identity;

            if (ScaledSun.Instance != null)
            {
                baseTransform.transform.parent = ScaledSun.Instance.transform;
                Debug.Log("TSTGalaxies BaseTransform set to the ScaledSun.Instance");
            }
            else
            {
                baseTransform.SetActive(false);
                Debug.Log("TSTGalaxies BaseTransform setactive = false, ScaledSun does not exist");
            }
            if (Utilities.IsKopInstalled)
            {
                baseTransform.transform.parent = FlightGlobals.Bodies[1].transform;
                Debug.Log("TSTGalaxies - Detected Kopernicus - BaseTransform set to Home Planet");
            }

            UrlDir.UrlConfig[] galaxyCfgs = GameDatabase.Instance.GetConfigs("GALAXY");
            foreach (UrlDir.UrlConfig cfg in galaxyCfgs)
            {
                GameObject go = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer), typeof(TSTGalaxy));
                go.transform.parent = baseTransform.transform;
                TSTGalaxy galaxy = go.GetComponent <TSTGalaxy>();
                galaxy.Load(cfg.config);
                Debug.Log("TSTGalaxies Adding Galaxy " + galaxy.name);
                Galaxies.Add(galaxy);

                GameObject goCB = new GameObject(name, typeof(CelestialBody));
                goCB.transform.parent = go.transform;
                CelestialBody celestialBody = goCB.GetComponent <CelestialBody>();
                celestialBody.bodyName           = galaxy.name;
                celestialBody.bodyDisplayName    = galaxy.displayName;
                celestialBody.transform.position = galaxy.position;
                celestialBody.atmosphere         = false;
                celestialBody.ocean = false;
                celestialBody.timeWarpAltitudeLimits = new float[0];
                celestialBody.Radius       = 500;
                celestialBody.orbitDriver  = null;
                celestialBody.progressTree = null;
                CBGalaxies.Add(celestialBody);
            }
        }
コード例 #2
0
        public void Awake()
        {
            Debug.Log("TSTGalaxies Galaxies Awake");
            if (Instance != null)
                Destroy(this);
            else
                Instance = this;
            DontDestroyOnLoad(this);

            Debug.Log("TSTGalaxies Starting Galaxies");

            baseTransform = new GameObject();
            baseTransform.transform.localPosition = Vector3.zero;
            baseTransform.transform.localRotation = Quaternion.identity;

            if (ScaledSun.Instance != null)
            {
                baseTransform.transform.parent = ScaledSun.Instance.transform;
                Debug.Log("TSTGalaxies BaseTransform set to the ScaledSun.Instance");
            }
            else
            {
                baseTransform.SetActive(false);
                Debug.Log("TSTGalaxies BaseTransform setactive = false, ScaledSun does not exist");
            }
            if (Utilities.IsKopInstalled)
            {
                baseTransform.transform.parent = FlightGlobals.Bodies[1].transform;
                Debug.Log("TSTGalaxies - Detected Kopernicus - BaseTransform set to Home Planet");
            }

            UrlDir.UrlConfig[] galaxyCfgs = GameDatabase.Instance.GetConfigs("GALAXY");
            foreach (UrlDir.UrlConfig cfg in galaxyCfgs)
            {
                GameObject go = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer), typeof(TSTGalaxy));
                go.transform.parent = baseTransform.transform;
                TSTGalaxy galaxy = go.GetComponent<TSTGalaxy>();
                galaxy.Load(cfg.config);
                Debug.Log("TSTGalaxies Adding Galaxy " + galaxy.name);
                Galaxies.Add(galaxy);

                GameObject goCB = new GameObject(name, typeof(CelestialBody));
                goCB.transform.parent = go.transform;
                CelestialBody celestialBody = goCB.GetComponent<CelestialBody>();
                celestialBody.bodyName = galaxy.theName;
                celestialBody.transform.position = galaxy.position;
                celestialBody.atmosphere = false;
                celestialBody.ocean = false;
                celestialBody.orbitDriver = null;
                celestialBody.progressTree = null;
                CBGalaxies.Add(celestialBody);
            }
        }