예제 #1
0
 public void Start()
 {
     if (Instance)
     {
         DestroyImmediate(gameObject);
     }
     else
     {
         DontDestroyOnLoad(gameObject);
         Instance = this;
         GameEvents.onGameSceneLoadRequested.Add(new EventData <GameScenes> .OnEvent(OnGameSceneLoadRequested));
         PlanetSettings.Load(KSPUtil.ApplicationRootPath + "/GameData/PlanetRandomizer/Resources/PlanetRandomizer.cfg");
         PlanetDefault.Load(KSPUtil.ApplicationRootPath + "/GameData/PlanetRandomizer/Resources/PlanetRandomizer.cfg");
     }
 }
예제 #2
0
        public void DefaultSystem()
        {
            if (!File.Exists(KSPUtil.ApplicationRootPath + "/GameData/PlanetRandomizer/Resources/PlanetRandomizerDefault.cfg"))
            {
                print("Saving default system");

                List <ChangedPlanet> tempPlanet = new List <ChangedPlanet>();

                foreach (CelestialBody body in FlightGlobals.Bodies)
                {
                    if (body.gameObject.name != "Sun")
                    {
                        ChangedPlanet cp = new ChangedPlanet();

                        cp.Name   = body.gameObject.name;
                        cp.Radius = body.Radius;
                        cp.Mass   = body.Mass;

                        cp.RotationPeriod     = body.rotationPeriod;
                        cp.SemiMajorAxis      = body.orbit.semiMajorAxis;
                        cp.Eccentricity       = body.orbit.eccentricity;
                        cp.Inclination        = body.orbit.inclination;
                        cp.MeanAnomalyAtEpoch = body.orbit.meanAnomalyAtEpoch;
                        cp.LAN = body.orbit.LAN;
                        cp.ArgumentOfPeriapsis = body.orbit.argumentOfPeriapsis;
                        cp.ReferenceBody       = body.orbit.referenceBody.name;

                        tempPlanet.Add(cp);
                    }
                }

                PlanetDefault.Instance.Planets = tempPlanet.ToArray();
                PlanetDefault.Instance.Save(KSPUtil.ApplicationRootPath + "/GameData/PlanetRandomizer/Resources/PlanetRandomizerDefault.cfg");
                RebuildSystemDef();
            }
            else
            {
                PlanetDefault.Load(KSPUtil.ApplicationRootPath + "/GameData/PlanetRandomizer/Resources/PlanetRandomizerDefault.cfg");
                RebuildSystemDef();
            }
        }