Beispiel #1
0
        public override void Init(MyObjectBuilder_SessionComponent sessionComponent)
        {
            InitNet();

            if (!Sync.IsServer || !SettingsSession.Static.Settings.Enable || MySession.Static.Settings.WorldSizeKm > 0)
            {
                return;
            }

            MyObjectBuilder_StarSystem b = GetConfig();

            m_objects = b.SystemObjects;

            m_seed = MySession.Static.Settings.ProceduralSeed + MyRandom.Instance.CreateRandomSeed();

            m_settings = SettingsSession.Static.Settings.GeneratorSettings;
            //FilterDefinitions();

            if (b == null || m_objects == null || m_objects.Count == 0)
            {
                GenerateSystem();
            }

            MySession.Static.OnReady += delegate
            {
                if (SettingsSession.Static.Settings.GeneratorSettings.BeltSettings.ShowBeltGPS)
                {
                    AddBeltsGpss();
                }
            };
        }
Beispiel #2
0
 private MyObjectBuilder_StarSystem GetConfig()
 {
     if (MyAPIGateway.Utilities.FileExistsInWorldStorage(STORAGE_FILE, typeof(SystemGenerator)))
     {
         try
         {
             using (var reader = MyAPIGateway.Utilities.ReadFileInWorldStorage(STORAGE_FILE, typeof(SystemGenerator)))
             {
                 MyObjectBuilder_StarSystem saveFile = MyAPIGateway.Utilities.SerializeFromXML <MyObjectBuilder_StarSystem>(reader.ReadToEnd());
                 return(saveFile);
             }
         }
         catch (Exception e)
         {
             MyLog.Default.Error("Couldnt load Starsystem save file.");
             MyLog.Default.Error(e.Message + "\n" + e.StackTrace);
             MyAPIGateway.Utilities.DeleteFileInWorldStorage(STORAGE_FILE, typeof(SystemGenerator));
             return(null);
         }
     }
     else
     {
         return(new MyObjectBuilder_StarSystem());
     }
 }
        /// <summary>
        /// Executed after loading and initializes the generator.
        /// It generates the system, if it should.
        /// </summary>
        /// <param name="sessionComponent"></param>
        public override void Init(MyObjectBuilder_SessionComponent sessionComponent)
        {
            PluginLog.Log("Initializing system generator");

            InitNet();

            if (!Sync.IsServer || !SettingsSession.Static.Settings.Enable || MySession.Static.Settings.WorldSizeKm > 0)
            {
                return;
            }

            MyObjectBuilder_StarSystem b = GetConfig();

            Objects = b.SystemObjects;

            m_seed = MySession.Static.Settings.ProceduralSeed + Guid.NewGuid().GetHashCode();

            m_settings = SettingsSession.Static.Settings.GeneratorSettings;

            if (b == null || Objects == null || Objects.Count == 0)
            {
                GenerateSystem();
            }

            MySession.Static.OnReady += delegate
            {
                if (SettingsSession.Static.Settings.GeneratorSettings.BeltSettings.ShowBeltGPS)
                {
                    AddBeltsGpss();
                }
            };
        }
Beispiel #4
0
        private void SaveConfig()
        {
            MyObjectBuilder_StarSystem conf = new MyObjectBuilder_StarSystem();

            conf.SystemObjects = m_objects;

            MyAPIGateway.Utilities.DeleteFileInWorldStorage(STORAGE_FILE, typeof(SystemGenerator));

            string xml = MyAPIGateway.Utilities.SerializeToXML(conf);

            using (var writer = MyAPIGateway.Utilities.WriteFileInWorldStorage(STORAGE_FILE, typeof(SystemGenerator)))
            {
                writer.Write(xml);
                writer.Close();
            }
        }