Exemplo n.º 1
0
        public static PlanetaryInstallationsConfig LoadConfigFile()
        {
            if (MyAPIGateway.Utilities.FileExistsInLocalStorage("planetaryinstallationconfig.xml", typeof(PlanetaryInstallationsConfig)) == true)
            {
                try{
                    PlanetaryInstallationsConfig config = null;
                    var    reader         = MyAPIGateway.Utilities.ReadFileInLocalStorage("planetaryinstallationconfig.xml", typeof(PlanetaryInstallationsConfig));
                    string configcontents = reader.ReadToEnd();
                    config = MyAPIGateway.Utilities.SerializeFromXML <PlanetaryInstallationsConfig>(configcontents);
                    //LogEntry("Found Config File");
                    return(config);
                }catch (Exception exc) {
                    //Not a good config, defaults will be loaded instead.
                }
            }

            PlanetaryInstallationsConfig defaultconfig = new PlanetaryInstallationsConfig();

            //LogEntry("Config File Not Found. Using Default Values");

            using (var writer = MyAPIGateway.Utilities.WriteFileInLocalStorage("planetaryinstallationconfig.xml", typeof(PlanetaryInstallationsConfig))){
                writer.Write(MyAPIGateway.Utilities.SerializeToXML <PlanetaryInstallationsConfig>(defaultconfig));
            }

            return(defaultconfig);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Custom Congfig File Reading and Sanity Checks
 /// </summary>
 /// <param name="loadconfig"> the PlanataryInstallationsConfig</param>
 public void LoadConfig(PlanetaryInstallationsConfig loadconfig)
 {
     SpawnTimerTrigger = loadconfig.SpawnTimerTrigger;
     MaxActiveInstallationsPerPlanet   = loadconfig.MaximumActiveStationsPerPlanet;
     MinDistFromOtherGrids             = loadconfig.MinimumSpawnDistanceFromOtherGrids;
     MediumInstallationChanceBase      = loadconfig.MediumSpawnChanceBaseValue;
     MediumInstallationChanceIncrement = loadconfig.MediumSpawnChanceIncrement;
     MediumInstallationAttempts        = loadconfig.MediumInstallationAttempts;
     LargeInstallationChanceBase       = loadconfig.LargeSpawnChanceBaseValue;
     LargeInstallationChanceIncrement  = loadconfig.LargeSpawnChanceIncrement;
     LargeInstallationAttempts         = loadconfig.LargeInstallationAttempts;
     PlayerTravelTrigger = loadconfig.PlayerDistanceSpawnTrigger;
 }