From caa0e3aa4691b2c2a8afb51702f79007027a2fc1 Mon Sep 17 00:00:00 2001
From: 8vogt <8vogt@informatik.uni-hamburg.de>
Date: Sat, 19 Dec 2020 15:39:51 +0100
Subject: [PATCH] *Added*: The new world generation settings object builder, to
give more control over system generation
---
SEWorldGenPlugin/GUI/PluginSettingsGui.cs | 6 +-
SEWorldGenPlugin/GUI/PluginWorldSettings.cs | 10 +-
SEWorldGenPlugin/MySettings.cs | 12 +-
.../LegacyMyObjectBuilder_WorldSettings.cs | 351 ++++++++++++++++++
.../MyObjectBuilder_GlobalSettings.cs | 5 +-
.../MyObjectBuilder_WorldSettings.cs | 333 +++--------------
SEWorldGenPlugin/SEWorldGenPlugin.csproj | 3 +-
SEWorldGenPlugin/Session/SettingsSession.cs | 4 +-
8 files changed, 418 insertions(+), 306 deletions(-)
create mode 100644 SEWorldGenPlugin/ObjectBuilders/LegacyMyObjectBuilder_WorldSettings.cs
diff --git a/SEWorldGenPlugin/GUI/PluginSettingsGui.cs b/SEWorldGenPlugin/GUI/PluginSettingsGui.cs
index a4cd1bd..31ea9f0 100644
--- a/SEWorldGenPlugin/GUI/PluginSettingsGui.cs
+++ b/SEWorldGenPlugin/GUI/PluginSettingsGui.cs
@@ -483,7 +483,7 @@ public void BuildControls()
Controls.Add(scrollPane);
}
- public void SetSettings(MyObjectBuilder_WorldSettings settings, bool useGlobal)
+ public void SetSettings(LegacyMyObjectBuilder_WorldSettings settings, bool useGlobal)
{
m_useGlobalCheck.IsChecked = useGlobal;
@@ -534,10 +534,10 @@ public void SetSettings(MyObjectBuilder_WorldSettings settings, bool useGlobal)
///
/// The plugin settings to set
/// If global config should be used
- public bool GetSettings(ref MyObjectBuilder_WorldSettings settings)
+ public bool GetSettings(ref LegacyMyObjectBuilder_WorldSettings settings)
{
if (settings == null)
- settings = new MyObjectBuilder_WorldSettings();
+ settings = new LegacyMyObjectBuilder_WorldSettings();
settings.GeneratorSettings.SemiRandomizedGeneration = m_useSemiRandomGenerationCheck.IsChecked;
settings.GeneratorSettings.UseVanillaPlanets = m_useVanillaPlanetsCheck.IsChecked;
diff --git a/SEWorldGenPlugin/GUI/PluginWorldSettings.cs b/SEWorldGenPlugin/GUI/PluginWorldSettings.cs
index 09fd016..4097285 100644
--- a/SEWorldGenPlugin/GUI/PluginWorldSettings.cs
+++ b/SEWorldGenPlugin/GUI/PluginWorldSettings.cs
@@ -25,7 +25,7 @@ public class PluginWorldSettings : MyGuiScreenWorldSettings
{
public static MyGuiScreenWorldSettings Static;
- public MyObjectBuilder_WorldSettings PluginSettings;
+ public LegacyMyObjectBuilder_WorldSettings PluginSettings;
private MyGuiControlCheckbox m_enablePlugin;
private MyGuiControlLabel m_enablePluginLabel;
@@ -43,7 +43,7 @@ public class PluginWorldSettings : MyGuiScreenWorldSettings
internal PluginSettingsGui SettingsGui;
- public MyObjectBuilder_WorldSettings PlSettings;
+ public LegacyMyObjectBuilder_WorldSettings PlSettings;
///
/// If the world should use the global configuration file
@@ -129,7 +129,7 @@ protected override void BuildControls()
}
else
{
- MySettings.Static.SessionSettings = new MyObjectBuilder_WorldSettings();
+ MySettings.Static.SessionSettings = new LegacyMyObjectBuilder_WorldSettings();
MySettings.Static.SessionSettings.Enable = m_enablePlugin.IsChecked;
}
};
@@ -179,11 +179,11 @@ private void LoadValues()
var path = Path.Combine(MyFileSystem.SavesPath, Checkpoint.SessionName.Replace(":", "-"));
if(FileUtils.FileExistsInPath(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings)))
{
- PlSettings = FileUtils.ReadXmlFileFromPath(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings));
+ PlSettings = FileUtils.ReadXmlFileFromPath(path, SettingsSession.FILE_NAME, typeof(PluginWorldSettings));
}
else
{
- PlSettings = new MyObjectBuilder_WorldSettings();
+ PlSettings = new LegacyMyObjectBuilder_WorldSettings();
}
m_enablePlugin.IsChecked = PlSettings.Enable;
}
diff --git a/SEWorldGenPlugin/MySettings.cs b/SEWorldGenPlugin/MySettings.cs
index 46cee40..dcebd95 100644
--- a/SEWorldGenPlugin/MySettings.cs
+++ b/SEWorldGenPlugin/MySettings.cs
@@ -27,7 +27,7 @@ public static MySettings Static
///
/// Global configuration settings
///
- public MyObjectBuilder_WorldSettings Settings
+ public LegacyMyObjectBuilder_WorldSettings Settings
{
get;
private set;
@@ -36,7 +36,7 @@ public MyObjectBuilder_WorldSettings Settings
///
/// To be loaded session settings
///
- public MyObjectBuilder_WorldSettings SessionSettings
+ public LegacyMyObjectBuilder_WorldSettings SessionSettings
{
get;
set;
@@ -48,7 +48,7 @@ public MyObjectBuilder_WorldSettings SessionSettings
public MySettings()
{
Static = this;
- Settings = new MyObjectBuilder_WorldSettings();
+ Settings = new LegacyMyObjectBuilder_WorldSettings();
}
///
@@ -63,7 +63,7 @@ public void LoadSettings()
{
using (var reader = FileUtils.ReadFileInGlobalStorage(FILENAME))
{
- MyObjectBuilder_WorldSettings saveFile = FileUtils.SerializeFromXml(reader.ReadToEnd());
+ LegacyMyObjectBuilder_WorldSettings saveFile = FileUtils.SerializeFromXml(reader.ReadToEnd());
if (saveFile != null)
Settings = saveFile;
}
@@ -73,13 +73,13 @@ public void LoadSettings()
PluginLog.Log("Couldnt load Plugin config file.", LogLevel.ERROR);
PluginLog.Log(e.Message + "\n" + e.StackTrace, LogLevel.ERROR);
FileUtils.DeleteFileInGlobalStorage(FILENAME);
- Settings = new MyObjectBuilder_WorldSettings();
+ Settings = new LegacyMyObjectBuilder_WorldSettings();
}
}
else
{
PluginLog.Log("Config does not exist, creating default one");
- Settings = new MyObjectBuilder_WorldSettings();
+ Settings = new LegacyMyObjectBuilder_WorldSettings();
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Moon");
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Titan");
Settings.GeneratorSettings.PlanetSettings.Moons.Add("Europa");
diff --git a/SEWorldGenPlugin/ObjectBuilders/LegacyMyObjectBuilder_WorldSettings.cs b/SEWorldGenPlugin/ObjectBuilders/LegacyMyObjectBuilder_WorldSettings.cs
new file mode 100644
index 0000000..7444305
--- /dev/null
+++ b/SEWorldGenPlugin/ObjectBuilders/LegacyMyObjectBuilder_WorldSettings.cs
@@ -0,0 +1,351 @@
+using ProtoBuf;
+using SEWorldGenPlugin.Utilities;
+using System.Collections.Generic;
+
+namespace SEWorldGenPlugin.ObjectBuilders
+{
+ ///
+ /// Serializable ObjectBuilder used for the plugins save data. Contains
+ /// wheter it is enabled or not, and the Generator settings.
+ ///
+ [ProtoContract]
+ public class LegacyMyObjectBuilder_WorldSettings
+ {
+ public LegacyMyObjectBuilder_WorldSettings()
+ {
+ Enable = false;
+ if(MySettings.Static != null)
+ {
+ if (MySettings.Static.Settings != null)
+ {
+ GeneratorSettings = MySettings.Static.Settings.GeneratorSettings.copy();
+ }
+ else
+ {
+ GeneratorSettings = new GeneratorSettings();
+ }
+ }
+ else
+ {
+ GeneratorSettings = new GeneratorSettings();
+ }
+
+ }
+
+ [ProtoMember(1)]
+ public bool Enable;
+
+ [ProtoMember(2)]
+ public GeneratorSettings GeneratorSettings;
+
+ public LegacyMyObjectBuilder_WorldSettings copy()
+ {
+ LegacyMyObjectBuilder_WorldSettings s = new LegacyMyObjectBuilder_WorldSettings();
+ s.Enable = Enable;
+ s.GeneratorSettings = GeneratorSettings.copy();
+ return s;
+ }
+
+ public void Verify()
+ {
+ GeneratorSettings.Verify();
+ }
+ }
+
+ ///
+ /// Serializable class representing the GeneratorSettings for the plugin
+ ///
+ [ProtoContract]
+ public class GeneratorSettings
+ {
+
+ public GeneratorSettings()
+ {
+ MinObjectsInSystem = 5;
+ MaxObjectsInSystem = 25;
+ MinOrbitDistance = 4000000;
+ MaxOrbitDistance = 10000000;
+ AsteroidGenerator = AsteroidGenerator.PLUGIN;
+ AsteroidDensity = 0.6f;
+ PlanetSettings = new PlanetSettings();
+ BeltSettings = new BeltSettings();
+ SemiRandomizedGeneration = false;
+ WorldSize = -1;
+ FirstPlanetCenter = false;
+ UseVanillaPlanets = true;
+ PlanetsOnlyOnce = false;
+ MoonsOnlyOnce = false;
+ }
+
+ [ProtoMember(1)]
+ public int MinObjectsInSystem;
+
+ [ProtoMember(2)]
+ public int MaxObjectsInSystem;
+
+ [ProtoMember(3)]
+ public int MinOrbitDistance;
+
+ [ProtoMember(4)]
+ public int MaxOrbitDistance;
+
+ [ProtoMember(5)]
+ public AsteroidGenerator AsteroidGenerator;
+
+ [ProtoMember(6)]
+ public float AsteroidDensity;
+
+ [ProtoMember(7)]
+ public PlanetSettings PlanetSettings;
+
+ [ProtoMember(8)]
+ public BeltSettings BeltSettings;
+
+ [ProtoMember(9)]
+ public bool SemiRandomizedGeneration;
+
+ [ProtoMember(10)]
+ public long WorldSize;
+
+ [ProtoMember(10)]
+ public bool FirstPlanetCenter;
+
+ [ProtoMember(11)]
+ public bool UseVanillaPlanets;
+
+ [ProtoMember(12)]
+ public bool PlanetsOnlyOnce;
+
+ [ProtoMember(13)]
+ public bool MoonsOnlyOnce;
+
+ public GeneratorSettings copy()
+ {
+ GeneratorSettings g = new GeneratorSettings();
+ g.MinObjectsInSystem = MinObjectsInSystem;
+ g.MaxObjectsInSystem = MaxObjectsInSystem;
+ g.MinOrbitDistance = MinOrbitDistance;
+ g.MaxOrbitDistance = MaxOrbitDistance;
+ g.AsteroidGenerator = AsteroidGenerator;
+ g.AsteroidDensity = AsteroidDensity;
+ g.PlanetSettings = PlanetSettings.copy();
+ g.BeltSettings = BeltSettings.copy();
+ g.SemiRandomizedGeneration = SemiRandomizedGeneration;
+ g.WorldSize = WorldSize;
+ g.FirstPlanetCenter = FirstPlanetCenter;
+ g.UseVanillaPlanets = UseVanillaPlanets;
+ g.PlanetsOnlyOnce = PlanetsOnlyOnce;
+ g.MoonsOnlyOnce = MoonsOnlyOnce;
+
+ return g;
+ }
+
+ public void Verify()
+ {
+ Verifier.VerifyInt(0, MaxObjectsInSystem, 5, "MinObjectsInSystem", ref MinObjectsInSystem);
+ Verifier.VerifyInt(MinObjectsInSystem, int.MaxValue, 25, "MaxObjectsInSystem", ref MaxObjectsInSystem);
+ Verifier.VerifyInt(0, MinOrbitDistance, 4000000, "MinOrbitDistance", ref MinOrbitDistance);
+ Verifier.VerifyInt(MinOrbitDistance, int.MaxValue, 10000000, "MaxOrbitDistance", ref MaxOrbitDistance);
+ Verifier.VerifyFloat(0f, 1f, 0.5f, "AsteroidDensity", ref AsteroidDensity);
+ Verifier.VerifyLong(-1, long.MaxValue, 10000000, "MaxOrbitDistance", ref WorldSize);
+
+ PlanetSettings.Verify();
+ BeltSettings.Verify();
+ }
+ }
+
+ ///
+ /// Serializable class representing the PlanetSettings for the plugin
+ ///
+ [ProtoContract]
+ public class PlanetSettings
+ {
+ public PlanetSettings()
+ {
+ SizeMultiplier = 2;
+ PlanetSizeCap = 1200000;
+ MoonProbability = 0.5f;
+ RingSettings = new PlanetRingSettings();
+ ShowPlanetGPS = true;
+ ShowMoonGPS = false;
+ BlacklistedPlanets = new HashSet();
+ BlacklistedPlanets.Add("MoonTutorial");
+ PlanetNameFormat = "Planet [ObjectNumber]";
+ MoonNameFormat = "Moon [ObjectNumber]";
+
+ MandatoryPlanets = new HashSet();
+
+ Moons = new HashSet();
+
+ GasGiants = new HashSet();
+ }
+
+ [ProtoMember(1)]
+ public float SizeMultiplier;
+
+ [ProtoMember(2)]
+ public double PlanetSizeCap;
+
+ [ProtoMember(3)]
+ public float MoonProbability;
+
+ [ProtoMember(4)]
+ public PlanetRingSettings RingSettings;
+
+ [ProtoMember(5)]
+ public bool ShowPlanetGPS;
+
+ [ProtoMember(6)]
+ public bool ShowMoonGPS;
+
+ [ProtoMember(7)]
+ public string PlanetNameFormat;
+
+ [ProtoMember(8)]
+ public string MoonNameFormat;
+
+ [ProtoMember(9)]
+ public HashSet BlacklistedPlanets;
+
+ [ProtoMember(10)]
+ public HashSet MandatoryPlanets;
+
+ [ProtoMember(11)]
+ public HashSet Moons;
+
+ [ProtoMember(12)]
+ public HashSet GasGiants;
+
+ public PlanetSettings copy()
+ {
+ PlanetSettings p = new PlanetSettings();
+ p.SizeMultiplier = SizeMultiplier;
+ p.PlanetSizeCap = PlanetSizeCap;
+ p.MoonProbability = MoonProbability;
+ p.RingSettings = RingSettings.copy();
+ p.ShowPlanetGPS = ShowPlanetGPS;
+ p.ShowMoonGPS = ShowMoonGPS;
+ p.PlanetNameFormat = PlanetNameFormat;
+ p.MoonNameFormat = MoonNameFormat;
+ p.BlacklistedPlanets = BlacklistedPlanets;
+ p.MandatoryPlanets = MandatoryPlanets;
+ p.Moons = Moons;
+ p.GasGiants = GasGiants;
+
+ return p;
+ }
+
+ public void Verify()
+ {
+ Verifier.VerifyFloat(0, float.MaxValue, 2, "PlanetSettings.SizeMultiplier", ref SizeMultiplier);
+ Verifier.VerifyDouble(0, double.MaxValue, 1200000, "PlanetSettings.PlanetSizeCap", ref PlanetSizeCap);
+ Verifier.VerifyFloat(0, 1, 0.5f, "PlanetSettings.MoonProbability", ref MoonProbability);
+
+ RingSettings.Verify();
+ }
+ }
+
+ ///
+ /// Serializable class representing the PlanetRingSettings for the plugin
+ ///
+ [ProtoContract]
+ public class PlanetRingSettings
+ {
+ public PlanetRingSettings()
+ {
+ MinPlanetRingWidth = 10000;
+ MaxPlanetRingWidth = 100000;
+ PlanetRingProbability = 0.5f;
+ ShowRingGPS = true;
+ }
+
+ [ProtoMember(1)]
+ public int MinPlanetRingWidth;
+
+ [ProtoMember(2)]
+ public int MaxPlanetRingWidth;
+
+ [ProtoMember(3)]
+ public float PlanetRingProbability;
+
+ [ProtoMember(4)]
+ public bool ShowRingGPS;
+
+ public PlanetRingSettings copy()
+ {
+ PlanetRingSettings r = new PlanetRingSettings();
+ r.MinPlanetRingWidth = MinPlanetRingWidth;
+ r.MaxPlanetRingWidth = MaxPlanetRingWidth;
+ r.PlanetRingProbability = PlanetRingProbability;
+ r.ShowRingGPS = ShowRingGPS;
+
+ return r;
+ }
+
+ public void Verify()
+ {
+ Verifier.VerifyInt(0, MaxPlanetRingWidth, 10000, "PlanetRingSettings.MinPlanetRingWidth", ref MinPlanetRingWidth);
+ Verifier.VerifyInt(MinPlanetRingWidth, int.MaxValue, 100000, "PlanetRingSettings.MaxPlanetRingWidth", ref MaxPlanetRingWidth);
+ Verifier.VerifyFloat(0, 1, 0.5f, "PlanetRingSettings.PlanetRingProbability", ref PlanetRingProbability);
+ }
+ }
+
+ ///
+ /// Serializable class representing the BeltSettings for the plugin
+ ///
+ [ProtoContract]
+ public class BeltSettings
+ {
+ public BeltSettings()
+ {
+ MinBeltHeight = 4000;
+ MaxBeltHeight = 40000;
+ BeltProbability = 0.2f;
+ ShowBeltGPS = true;
+ BeltNameFormat = "Belt [ObjectNumberGreek]";
+ }
+
+ [ProtoMember(1)]
+ public int MinBeltHeight;
+
+ [ProtoMember(2)]
+ public int MaxBeltHeight;
+
+ [ProtoMember(3)]
+ public float BeltProbability;
+
+ [ProtoMember(4)]
+ public bool ShowBeltGPS;
+
+ [ProtoMember(5)]
+ public string BeltNameFormat;
+
+ public BeltSettings copy()
+ {
+ BeltSettings b = new BeltSettings();
+ b.MinBeltHeight = MinBeltHeight;
+ b.MaxBeltHeight = MaxBeltHeight;
+ b.BeltProbability = BeltProbability;
+ b.ShowBeltGPS = ShowBeltGPS;
+ b.BeltNameFormat = BeltNameFormat;
+ return b;
+ }
+
+ public void Verify()
+ {
+ Verifier.VerifyInt(0, MaxBeltHeight, 4000, "BeltSettings.MinBeltHeight", ref MinBeltHeight);
+ Verifier.VerifyInt(MinBeltHeight, int.MaxValue, 40000, "BeltSettings.MaxBeltHeight", ref MaxBeltHeight);
+ Verifier.VerifyFloat(0, 1, 0.4f, "BeltSettings.BeltProbability", ref BeltProbability);
+ }
+ }
+
+ ///
+ /// Enum to set which asteroid generator the plugin uses.
+ ///
+ public enum AsteroidGenerator
+ {
+ PLUGIN,
+ VANILLA,
+ BOTH
+ }
+}
\ No newline at end of file
diff --git a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_GlobalSettings.cs b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_GlobalSettings.cs
index 6c2b4c5..8ec4c0f 100644
--- a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_GlobalSettings.cs
+++ b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_GlobalSettings.cs
@@ -4,7 +4,10 @@
namespace SEWorldGenPlugin.ObjectBuilders
{
- [Serializable]
+ ///
+ /// Serializable object builder used to store the global settings of the plugin.
+ /// Those are valid for all worlds.
+ ///
[ProtoContract]
public class MyObjectBuilder_GlobalSettings : MyAbstractConfigObjectBuilder
{
diff --git a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_WorldSettings.cs b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_WorldSettings.cs
index 0d11fd8..58063e5 100644
--- a/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_WorldSettings.cs
+++ b/SEWorldGenPlugin/ObjectBuilders/MyObjectBuilder_WorldSettings.cs
@@ -1,351 +1,108 @@
using ProtoBuf;
-using SEWorldGenPlugin.Utilities;
-using System.Collections.Generic;
+using System;
+using VRage;
namespace SEWorldGenPlugin.ObjectBuilders
{
+
///
- /// Serializable ObjectBuilder used for the plugins save data. Contains
+ /// Serializable ObjectBuilder used for the worlds settings for the plugin. Contains
/// wheter it is enabled or not, and the Generator settings.
///
[ProtoContract]
- public class MyObjectBuilder_WorldSettings
+ public class MyObjectBuilder_WorldSettings : MyAbstractConfigObjectBuilder
{
- public MyObjectBuilder_WorldSettings()
- {
- Enable = false;
- if(MySettings.Static != null)
- {
- if (MySettings.Static.Settings != null)
- {
- GeneratorSettings = MySettings.Static.Settings.GeneratorSettings.copy();
- }
- else
- {
- GeneratorSettings = new GeneratorSettings();
- }
- }
- else
- {
- GeneratorSettings = new GeneratorSettings();
- }
-
- }
[ProtoMember(1)]
- public bool Enable;
+ public bool Enabled = false;
[ProtoMember(2)]
- public GeneratorSettings GeneratorSettings;
+ public MyObjectBuilder_GeneratorSettings GeneratorSettings = null;
- public MyObjectBuilder_WorldSettings copy()
+ public override MyAbstractConfigObjectBuilder copy()
{
- MyObjectBuilder_WorldSettings s = new MyObjectBuilder_WorldSettings();
- s.Enable = Enable;
- s.GeneratorSettings = GeneratorSettings.copy();
- return s;
- }
+ MyObjectBuilder_WorldSettings copy = new MyObjectBuilder_WorldSettings();
+ copy.Enabled = Enabled;
+ copy.GeneratorSettings = GeneratorSettings == null ? null : GeneratorSettings.copy() as MyObjectBuilder_GeneratorSettings;
- public void Verify()
- {
- GeneratorSettings.Verify();
+ return new MyObjectBuilder_WorldSettings();
}
- }
-
- ///
- /// Serializable class representing the GeneratorSettings for the plugin
- ///
- [ProtoContract]
- public class GeneratorSettings
- {
- public GeneratorSettings()
+ public override void Verify()
{
- MinObjectsInSystem = 5;
- MaxObjectsInSystem = 25;
- MinOrbitDistance = 4000000;
- MaxOrbitDistance = 10000000;
- AsteroidGenerator = AsteroidGenerator.PLUGIN;
- AsteroidDensity = 0.6f;
- PlanetSettings = new PlanetSettings();
- BeltSettings = new BeltSettings();
- SemiRandomizedGeneration = false;
- WorldSize = -1;
- FirstPlanetCenter = false;
- UseVanillaPlanets = true;
- PlanetsOnlyOnce = false;
- MoonsOnlyOnce = false;
- }
-
- [ProtoMember(1)]
- public int MinObjectsInSystem;
-
- [ProtoMember(2)]
- public int MaxObjectsInSystem;
-
- [ProtoMember(3)]
- public int MinOrbitDistance;
-
- [ProtoMember(4)]
- public int MaxOrbitDistance;
-
- [ProtoMember(5)]
- public AsteroidGenerator AsteroidGenerator;
-
- [ProtoMember(6)]
- public float AsteroidDensity;
-
- [ProtoMember(7)]
- public PlanetSettings PlanetSettings;
-
- [ProtoMember(8)]
- public BeltSettings BeltSettings;
-
- [ProtoMember(9)]
- public bool SemiRandomizedGeneration;
-
- [ProtoMember(10)]
- public long WorldSize;
-
- [ProtoMember(10)]
- public bool FirstPlanetCenter;
-
- [ProtoMember(11)]
- public bool UseVanillaPlanets;
-
- [ProtoMember(12)]
- public bool PlanetsOnlyOnce;
-
- [ProtoMember(13)]
- public bool MoonsOnlyOnce;
-
- public GeneratorSettings copy()
- {
- GeneratorSettings g = new GeneratorSettings();
- g.MinObjectsInSystem = MinObjectsInSystem;
- g.MaxObjectsInSystem = MaxObjectsInSystem;
- g.MinOrbitDistance = MinOrbitDistance;
- g.MaxOrbitDistance = MaxOrbitDistance;
- g.AsteroidGenerator = AsteroidGenerator;
- g.AsteroidDensity = AsteroidDensity;
- g.PlanetSettings = PlanetSettings.copy();
- g.BeltSettings = BeltSettings.copy();
- g.SemiRandomizedGeneration = SemiRandomizedGeneration;
- g.WorldSize = WorldSize;
- g.FirstPlanetCenter = FirstPlanetCenter;
- g.UseVanillaPlanets = UseVanillaPlanets;
- g.PlanetsOnlyOnce = PlanetsOnlyOnce;
- g.MoonsOnlyOnce = MoonsOnlyOnce;
-
- return g;
- }
-
- public void Verify()
- {
- Verifier.VerifyInt(0, MaxObjectsInSystem, 5, "MinObjectsInSystem", ref MinObjectsInSystem);
- Verifier.VerifyInt(MinObjectsInSystem, int.MaxValue, 25, "MaxObjectsInSystem", ref MaxObjectsInSystem);
- Verifier.VerifyInt(0, MinOrbitDistance, 4000000, "MinOrbitDistance", ref MinOrbitDistance);
- Verifier.VerifyInt(MinOrbitDistance, int.MaxValue, 10000000, "MaxOrbitDistance", ref MaxOrbitDistance);
- Verifier.VerifyFloat(0f, 1f, 0.5f, "AsteroidDensity", ref AsteroidDensity);
- Verifier.VerifyLong(-1, long.MaxValue, 10000000, "MaxOrbitDistance", ref WorldSize);
-
- PlanetSettings.Verify();
- BeltSettings.Verify();
+ return;
}
}
///
- /// Serializable class representing the PlanetSettings for the plugin
+ /// Serializable object builder for the system generator settings. This object builder
+ /// defines the parameters, the systemgenerator uses to generate the worlds system.
///
[ProtoContract]
- public class PlanetSettings
+ public class MyObjectBuilder_GeneratorSettings : MyAbstractConfigObjectBuilder
{
- public PlanetSettings()
- {
- SizeMultiplier = 2;
- PlanetSizeCap = 1200000;
- MoonProbability = 0.5f;
- RingSettings = new PlanetRingSettings();
- ShowPlanetGPS = true;
- ShowMoonGPS = false;
- BlacklistedPlanets = new HashSet();
- BlacklistedPlanets.Add("MoonTutorial");
- PlanetNameFormat = "Planet [ObjectNumber]";
- MoonNameFormat = "Moon [ObjectNumber]";
-
- MandatoryPlanets = new HashSet();
-
- Moons = new HashSet();
-
- GasGiants = new HashSet();
- }
-
[ProtoMember(1)]
- public float SizeMultiplier;
+ public SystemGenerationMethod SystemGenerator = SystemGenerationMethod.FULL_RANDOM;
[ProtoMember(2)]
- public double PlanetSizeCap;
+ public AsteroidGenerationMethod AsteroidGenerator = AsteroidGenerationMethod.PLUGIN;
[ProtoMember(3)]
- public float MoonProbability;
+ public SerializableMinMax MinMaxPlanets = new SerializableMinMax(5, 15);
[ProtoMember(4)]
- public PlanetRingSettings RingSettings;
-
- [ProtoMember(5)]
- public bool ShowPlanetGPS;
+ public SerializableMinMax MinMaxAsteroidObjects = new SerializableMinMax(5, 15);
- [ProtoMember(6)]
- public bool ShowMoonGPS;
-
- [ProtoMember(7)]
- public string PlanetNameFormat;
-
- [ProtoMember(8)]
- public string MoonNameFormat;
-
- [ProtoMember(9)]
- public HashSet BlacklistedPlanets;
-
- [ProtoMember(10)]
- public HashSet MandatoryPlanets;
-
- [ProtoMember(11)]
- public HashSet Moons;
-
- [ProtoMember(12)]
- public HashSet GasGiants;
-
- public PlanetSettings copy()
+ public override MyAbstractConfigObjectBuilder copy()
{
- PlanetSettings p = new PlanetSettings();
- p.SizeMultiplier = SizeMultiplier;
- p.PlanetSizeCap = PlanetSizeCap;
- p.MoonProbability = MoonProbability;
- p.RingSettings = RingSettings.copy();
- p.ShowPlanetGPS = ShowPlanetGPS;
- p.ShowMoonGPS = ShowMoonGPS;
- p.PlanetNameFormat = PlanetNameFormat;
- p.MoonNameFormat = MoonNameFormat;
- p.BlacklistedPlanets = BlacklistedPlanets;
- p.MandatoryPlanets = MandatoryPlanets;
- p.Moons = Moons;
- p.GasGiants = GasGiants;
-
- return p;
+ return new MyObjectBuilder_GeneratorSettings();
}
- public void Verify()
+ public override void Verify()
{
- Verifier.VerifyFloat(0, float.MaxValue, 2, "PlanetSettings.SizeMultiplier", ref SizeMultiplier);
- Verifier.VerifyDouble(0, double.MaxValue, 1200000, "PlanetSettings.PlanetSizeCap", ref PlanetSizeCap);
- Verifier.VerifyFloat(0, 1, 0.5f, "PlanetSettings.MoonProbability", ref MoonProbability);
-
- RingSettings.Verify();
+ return;
}
}
///
- /// Serializable class representing the PlanetRingSettings for the plugin
+ /// Serializable struct used to represent a min max pair of values.
+ /// The values are automatically sorted in the constructor, so
+ /// min is always min and max is always max.
///
[ProtoContract]
- public class PlanetRingSettings
+ [Serializable]
+ public struct SerializableMinMax
{
- public PlanetRingSettings()
- {
- MinPlanetRingWidth = 10000;
- MaxPlanetRingWidth = 100000;
- PlanetRingProbability = 0.5f;
- ShowRingGPS = true;
- }
-
[ProtoMember(1)]
- public int MinPlanetRingWidth;
+ int Min;
[ProtoMember(2)]
- public int MaxPlanetRingWidth;
+ int Max;
- [ProtoMember(3)]
- public float PlanetRingProbability;
-
- [ProtoMember(4)]
- public bool ShowRingGPS;
-
- public PlanetRingSettings copy()
+ public SerializableMinMax(int v1, int v2)
{
- PlanetRingSettings r = new PlanetRingSettings();
- r.MinPlanetRingWidth = MinPlanetRingWidth;
- r.MaxPlanetRingWidth = MaxPlanetRingWidth;
- r.PlanetRingProbability = PlanetRingProbability;
- r.ShowRingGPS = ShowRingGPS;
-
- return r;
- }
-
- public void Verify()
- {
- Verifier.VerifyInt(0, MaxPlanetRingWidth, 10000, "PlanetRingSettings.MinPlanetRingWidth", ref MinPlanetRingWidth);
- Verifier.VerifyInt(MinPlanetRingWidth, int.MaxValue, 100000, "PlanetRingSettings.MaxPlanetRingWidth", ref MaxPlanetRingWidth);
- Verifier.VerifyFloat(0, 1, 0.5f, "PlanetRingSettings.PlanetRingProbability", ref PlanetRingProbability);
+ Min = Math.Min(v1, v2);
+ Max = Math.Max(v1, v2);
}
}
///
- /// Serializable class representing the BeltSettings for the plugin
+ /// Enum to set which asteroid generator the plugin uses.
///
- [ProtoContract]
- public class BeltSettings
+ public enum AsteroidGenerationMethod
{
- public BeltSettings()
- {
- MinBeltHeight = 4000;
- MaxBeltHeight = 40000;
- BeltProbability = 0.2f;
- ShowBeltGPS = true;
- BeltNameFormat = "Belt [ObjectNumberGreek]";
- }
-
- [ProtoMember(1)]
- public int MinBeltHeight;
-
- [ProtoMember(2)]
- public int MaxBeltHeight;
-
- [ProtoMember(3)]
- public float BeltProbability;
-
- [ProtoMember(4)]
- public bool ShowBeltGPS;
-
- [ProtoMember(5)]
- public string BeltNameFormat;
-
- public BeltSettings copy()
- {
- BeltSettings b = new BeltSettings();
- b.MinBeltHeight = MinBeltHeight;
- b.MaxBeltHeight = MaxBeltHeight;
- b.BeltProbability = BeltProbability;
- b.ShowBeltGPS = ShowBeltGPS;
- b.BeltNameFormat = BeltNameFormat;
- return b;
- }
-
- public void Verify()
- {
- Verifier.VerifyInt(0, MaxBeltHeight, 4000, "BeltSettings.MinBeltHeight", ref MinBeltHeight);
- Verifier.VerifyInt(MinBeltHeight, int.MaxValue, 40000, "BeltSettings.MaxBeltHeight", ref MaxBeltHeight);
- Verifier.VerifyFloat(0, 1, 0.4f, "BeltSettings.BeltProbability", ref BeltProbability);
- }
+ PLUGIN,
+ VANILLA,
+ BOTH
}
///
/// Enum to set which asteroid generator the plugin uses.
///
- public enum AsteroidGenerator
+ public enum SystemGenerationMethod
{
- PLUGIN,
- VANILLA,
- BOTH
+ FULL_RANDOM,
+ MANDATORY_FIRST,
+ MANDATORY_ONLY
}
-}
\ No newline at end of file
+}
diff --git a/SEWorldGenPlugin/SEWorldGenPlugin.csproj b/SEWorldGenPlugin/SEWorldGenPlugin.csproj
index 6343e6e..d6c2826 100644
--- a/SEWorldGenPlugin/SEWorldGenPlugin.csproj
+++ b/SEWorldGenPlugin/SEWorldGenPlugin.csproj
@@ -198,8 +198,9 @@
-
+
+
diff --git a/SEWorldGenPlugin/Session/SettingsSession.cs b/SEWorldGenPlugin/Session/SettingsSession.cs
index a3668a2..de3fa08 100644
--- a/SEWorldGenPlugin/Session/SettingsSession.cs
+++ b/SEWorldGenPlugin/Session/SettingsSession.cs
@@ -24,7 +24,7 @@ public class SettingsSession : MySessionComponentBase
///
/// The current sessions plugin settings.
///
- public MyObjectBuilder_WorldSettings Settings
+ public LegacyMyObjectBuilder_WorldSettings Settings
{
get;
set;
@@ -39,7 +39,7 @@ public override void LoadData()
Static = this;
if (FileUtils.FileExistsInWorldStorage(FILE_NAME, typeof(SettingsSession)))
{
- Settings = FileUtils.ReadXmlFileFromWorld(FILE_NAME, typeof(SettingsSession));
+ Settings = FileUtils.ReadXmlFileFromWorld(FILE_NAME, typeof(SettingsSession));
}
else
{