Skip to content

Commit

Permalink
2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Jun 13, 2022
1 parent c3f39db commit cc27995
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Bootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class GS2
}


[BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.5.15")]
[BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.6.0")]
[BepInDependency("space.customizing.console", BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency("dsp.nebula-multiplayer-api", BepInDependency.DependencyFlags.SoftDependency)]
public class Bootstrap : BaseUnityPlugin
Expand Down
2 changes: 1 addition & 1 deletion GalacticScale3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PropertyGroup>
<AssemblyName>GalacticScale</AssemblyName>
<Description>Galaxy Customization for Dyson Sphere Program</Description>
<Version>2.5.15</Version>
<Version>2.6.0</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
<OutDir>bin/$(Configuration)</OutDir>
Expand Down
6 changes: 5 additions & 1 deletion Package/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# DSP Galactic Scale 2.0 Mod

# BACKUP YOUR SAVES
# BACKUP YOUR SAVES. SERIOUSLY.

- Version 2.6.0 - Fixed terrain generation code that has been broken since version 2.0.0. I wouldn't upgrade if you have an existing save. Your planets may morph into their true form. This probably isn't a good thing if you have buildings on them.

# BACKUP YOUR SAVES. PLEASE.

- Version 2.5.15 - Add new Planet Types (IceGelisol 2/3, FrozenTundra, PandoraSwamp 1/2, Crystal Desert, Savanna)
- Version 2.5.14 - Update for DSP 12900 (New Planets Not Yet Added, I'll be working on them today)
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static void Init()
Log($"Vanilla Theme Count: {LDB._themes.dataArray.Length.ToString()}");
if (File.Exists(Path.Combine(AssemblyPath, "icon.png")))
{
if (ActiveGenerator != null && ActiveGenerator.GUID == "space.customizing.generators.vanilla") updateMessage += "Note: Settings for this mod are in the settings menu. Make sure to change the Generator to get the full Galactic Scale experience.\r\n";
if (ActiveGenerator != null && ActiveGenerator.GUID == "space.customizing.generators.vanilla") updateMessage += "BACKUP YOUR SAVES. This version has potentially BREAKING CHANGES.\r\nNote: Settings for this mod are in the settings menu. Make sure to change the Generator to get the full Galactic Scale experience.\r\n";
updateMessage += "Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward".Translate();
File.Delete(Path.Combine(AssemblyPath, "icon.png"));
updateMessage += "The latest DSP update has added additional planet themes which are yet to be included in GS2. \r\nI'm working on getting them added to the GS2 themeset, as well as implementing their new subtheme system";
Expand Down
9 changes: 8 additions & 1 deletion Scripts/Models/Themes/GSFSThemeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ protected override fsResult DoSerialize(GSTheme model, Dictionary<string, fsData
if (model.BaseName != null && model.BaseName != "")
SerializeMember(serialized, null, "BaseName", model.BaseName);

if (!based || model.ModX != baseTheme.ModX)
SerializeMember(serialized, null, "ModX", model.ModX);
if (!based || model.ModY != baseTheme.ModY)
SerializeMember(serialized, null, "ModY", model.ModY);
if (!based || model.MinRadius != baseTheme.MinRadius)
SerializeMember(serialized, null, "MinRadius", model.MinRadius);
if (!based || model.MaxRadius != baseTheme.MaxRadius)
Expand Down Expand Up @@ -120,6 +124,8 @@ protected override fsResult DoSerialize(GSTheme model, Dictionary<string, fsData
SerializeMember(serialized, null, "CustomGeneration", model.CustomGeneration);
SerializeMember(serialized, null, "DisplayName", model.DisplayName);
SerializeMember(serialized, null, "BaseName", model.BaseName);
SerializeMember(serialized, null, "ModX", model.ModX);
SerializeMember(serialized, null, "ModY", model.ModY);
SerializeMember(serialized, null, "MaxRadius", model.MaxRadius);
SerializeMember(serialized, null, "MinRadius", model.MinRadius);
SerializeMember(serialized, null, "ThemeType", model.ThemeType);
Expand Down Expand Up @@ -175,7 +181,8 @@ protected override fsResult DoDeserialize(Dictionary<string, fsData> data, ref G
if (data.ContainsKey("PlanetType")) DeserializeMember(data, null, "PlanetType", out model.PlanetType);
if (data.ContainsKey("StarTypes")) DeserializeMember(data, null, "StarTypes", out model.StarTypes);
if (data.ContainsKey("Algo")) DeserializeMember(data, null, "Algo", out model.Algo);

if (data.ContainsKey("ModX")) DeserializeMember(data, null, "ModX", out model.ModX);
if (data.ContainsKey("ModY")) DeserializeMember(data, null, "ModY", out model.ModY);
if (data.ContainsKey("CustomGeneration"))
DeserializeMember(data, null, "CustomGeneration", out model.CustomGeneration);

Expand Down
36 changes: 36 additions & 0 deletions Scripts/Patches/PlanetAlgorithm/PlanetAlgorithm.GenerateTerrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,42 @@ namespace GalacticScale
{
public partial class PatchOnPlanetAlgorithm
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm14), "GenerateTerrain")]
public static bool PlanetAlgorithm14_GenerateTerrain(PlanetAlgorithm14 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateTerrain")]
public static bool PlanetAlgorithm13_GenerateTerrain(PlanetAlgorithm13 __instance)
{
GS2.Log("Running GenerateTerrain on PA13");
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateTerrain")]
public static bool PlanetAlgorithm12_GenerateTerrain(PlanetAlgorithm12 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateTerrain")]
public static bool PlanetAlgorithm11_GenerateTerrain(PlanetAlgorithm11 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm10), "GenerateTerrain")]
public static bool PlanetAlgorithm10_GenerateTerrain(PlanetAlgorithm10 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm9), "GenerateTerrain")]
public static bool PlanetAlgorithm9_GenerateTerrain(PlanetAlgorithm9 __instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,41 @@ namespace GalacticScale
public partial class PatchOnPlanetAlgorithm
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm14), "GenerateVegetables")]
public static bool PlanetAlgorithm14_GenerateVegetables(PlanetAlgorithm14 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateVegetables")]
public static bool PlanetAlgorithm13_GenerateVegetables(PlanetAlgorithm13 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateVegetables")]
public static bool PlanetAlgorithm12_GenerateVegetables(PlanetAlgorithm12 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateVegetables")]
public static bool PlanetAlgorithm11_GenerateVegetables(PlanetAlgorithm11 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm10), "GenerateVegetables")]
public static bool PlanetAlgorithm10_GenerateVegetables(PlanetAlgorithm10 __instance)
{
if (__instance.planet == null || __instance.planet.data == null) return false;
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetAlgorithm9), "GenerateVegetables")]
public static bool PlanetAlgorithm9_GenerateVegetables(PlanetAlgorithm9 __instance)
{
Expand Down
36 changes: 36 additions & 0 deletions Scripts/Patches/PlanetModelingManager/Algorithm.csbak
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using HarmonyLib;

namespace GalacticScale
{
public partial class PatchOnPlanetModelingManager
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetModelingManager), "Algorithm")]
public static bool Algorithm(PlanetData planet, ref PlanetAlgorithm __result)
{
// GS2.Log("Start");
if (DSPGame.IsMenuDemo) return true;

if (GS2.Vanilla)
{
return true;
}
GS2.Log("CHOOSING ALGORITHM FOR " + planet.displayName + " rawdata?"+(planet.data != null));
var gsPlanet = GS2.GetGSPlanet(planet);
GS2.Warn(gsPlanet.Theme);
var gsTheme = GSSettings.ThemeLibrary.Find(gsPlanet.Theme);
GS2.Log("Use Custom Generation? " + gsTheme.CustomGeneration);
if (!gsTheme.CustomGeneration)
{
GS2.Warn("CHOSE COMPLETELY VANILLA");
if (gsPlanet.veinSettings == null || gsPlanet.veinSettings == new GSVeinSettings())
return true;
}

GS2.Warn("USING CUSTOM GENERATION FOR PLANET " + planet.displayName);
__result = new GS2PlanetAlgorithm(gsPlanet); //new GS2PlanetAlgorithm(gsPlanet);
__result.Reset(5, planet);
return false;
}
}
}
135 changes: 135 additions & 0 deletions Scripts/Planet Generation/PlanetAlgorithm.csbak
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
namespace GalacticScale
{
public class GS2PlanetAlgorithm : PlanetAlgorithm
{
public PlanetAlgorithm baseAlgorithm;
public GSPlanet gsPlanet;
public GSTerrainAlgorithm terrainAlgo;
public GSVegeAlgorithm vegeAlgo;
public GSVeinAlgorithm veinAlgo;

public GS2PlanetAlgorithm(GSPlanet gsPlanet)
{
GS2.Log("GS2PlanetAlgorithm|Constructor|Begin");
GS2.Log("GS2PlanetAlgorithm|Constructor|CREATING CUSTOM PLANET ALGORITHM FOR " + gsPlanet.Name);
GS2.Log("GS2PlanetAlgorithm|Constructor|Selecting Theme " + gsPlanet.Theme);
var gSTheme = GSSettings.ThemeLibrary.Find(gsPlanet.Theme);
GS2.Log("GS2PlanetAlgorithm|Constructor|Selected Theme");
this.gsPlanet = gsPlanet;
planet = gsPlanet.planetData;
seed = gsPlanet.Seed;
GS2.Log("GS2PlanetAlgorithm|Constructor|planetRawData exists?=" + (planet.data != null));
GS2.Log("GS2PlanetAlgorithm|Constructor|Getting Base Algo");
baseAlgorithm = GetBaseAlgo(gsTheme.Algo);
GS2.Log("GS2PlanetAlgorithm|Constructor|Resetting Base Algo|" + (gsPlanet.planetData == null));
baseAlgorithm.Reset(gsPlanet.Seed, gsPlanet.planetData);
GS2.Log($"GS2PlanetAlgorithm|Constructor|Custom Generation:{gsPlanet.GsTheme.CustomGeneration} Terrain Algo: " + gsTheme.TerrainSettings.Algorithm + " Vein Algo: " + gsTheme.VeinSettings.Algorithm + " Vege Algo: " + gsTheme.VegeSettings.Algorithm);

if (gsTheme.TerrainSettings.Algorithm == "Vanilla")
{
GS2.Log("GS2PlanetAlgorithm|Constructor|Terrain Algo Being Set to Vanilla");
terrainAlgo = (p, modX, modY) =>
{
GS2.Log("GS2PlanetAlgorithm|Constructor|Vanilla Terrain Algo Running");
if (!UIRoot.instance.backToMainMenu) baseAlgorithm.GenerateTerrain(modX, modY);
};
}
else
GS2.Log("GS2PlanetAlgorithm|Constructor|Terrain Algo Being Set to " + gsTheme.TerrainSettings.Algorithm);
terrainAlgo = GS2.TerrainAlgorithmLibrary.Find(gsTheme.TerrainSettings.Algorithm);
//this.}terrainAlgo = (gsTheme.TerrainSettings.Algorithm == "Vanilla") ? (GSPlanet p, double modX, double modY) => { baseAlgorithm.GenerateTerrain(modX, modY); } :

if (gsPlanet.veinSettings == null || gsPlanet.veinSettings == new GSVeinSettings())
{
if (gsTheme.VeinSettings.Algorithm == "Vanilla")
veinAlgo = (p, sketchOnly) =>
{
// GS2.Log("GS2PlanetAlgorithm|Constructor|Vanilla Vein Algo Running");
if (!UIRoot.instance.backToMainMenu) baseAlgorithm.GenerateVeins(sketchOnly);
};
else
veinAlgo = GS2.VeinAlgorithmLibrary.Find(gsTheme.VeinSettings.Algorithm);
}
else
{
if (gsPlanet.veinSettings.Algorithm == "Vanilla")
veinAlgo = (p, sketchOnly) =>
{
// GS2.WarnJson(gsPlanet);
// GS2.WarnJson(gsPlanet.GsTheme);
// GS2.Log("GS2PlanetAlgorithm|Constructor|Vanilla Vein Algo Running");
if (!UIRoot.instance.backToMainMenu) baseAlgorithm.GenerateVeins(sketchOnly);
};
else
veinAlgo = GS2.VeinAlgorithmLibrary.Find(gsPlanet.veinSettings.Algorithm);
}

//this.veinAlgo = (gsTheme.VeinSettings.Algorithm == "Vanilla") ? (GSPlanet p, bool sketchOnly) => { baseAlgorithm.GenerateVeins(sketchOnly); } : GS2.VeinAlgorithmLibrary.Find(gsTheme.VeinSettings.Algorithm);
if (gsTheme.VegeSettings.Algorithm == "Vanilla")
vegeAlgo = p =>
{
// GS2.Log("GS2PlanetAlgorithm|Constructor|Vanilla Vege Algo Running");
if (!UIRoot.instance.backToMainMenu) baseAlgorithm.GenerateVegetables();
};
else
// GS2.Log("GS2PlanetAlgorithm|Constructor|GS Vege Algo Running");

vegeAlgo = GS2.VegeAlgorithmLibrary.Find(gsTheme.VegeSettings.Algorithm);
// GS2.Warn("NonstandardVegealgo");

//this.vegeAlgo = (gsTheme.VegeSettings.Algorithm == "Vanilla") ? (GSPlanet p) => {
// GS2.Log("GS2.VeinAlgorithmLibrary.Find(gsTheme.VegeSettings.Algorithm);")
// baseAlgorithm.GenerateVegetables();
//} : GS2.VegeAlgorithmLibrary.Find(gsTheme.VegeSettings.Algorithm);


//GS2.Log("GS2PlanetAlgorithm|Constructor|End");
}

public GSTheme gsTheme => GSSettings.ThemeLibrary.Find(gsPlanet.Theme);

public override void GenerateTerrain(double modX, double modY)
{
//GS2.Log("PlanetAlgorithm|GenerateTerrain|" + gsPlanet.Name);
if (gsPlanet != null) if (!UIRoot.instance.backToMainMenu) terrainAlgo(gsPlanet, modX, modY); //GS2.Log("PlanetAlgorithm|GenerateTerrain|End");

}

public override void GenerateVegetables()
{
//GS2.Log("PlanetAlgorithm|GenerateVegetables()");
if (gsPlanet != null) if (!UIRoot.instance.backToMainMenu) vegeAlgo(gsPlanet);
}

public override void GenerateVeins(bool sketchOnly)
{
// GS2.Log($"PlanetAlgorithm|GenerateVeins() for {gsPlanet.Name} {gsPlanet.Theme}");
if (gsPlanet != null) if (!UIRoot.instance.backToMainMenu) veinAlgo(gsPlanet, sketchOnly);
}

public static PlanetAlgorithm GetBaseAlgo(int algoId)
{
GS2.Log($"Getting Base Algo for AlgoID:{algoId}");
switch (algoId)
{
case 1: return new PlanetAlgorithm1();
case 2: return new PlanetAlgorithm2();
case 3: return new PlanetAlgorithm3();
case 4: return new PlanetAlgorithm4();
case 5: return new PlanetAlgorithm5();
case 6: return new PlanetAlgorithm6();
case 7: return new PlanetAlgorithm7();
case 8: return new PlanetAlgorithm8();
case 9 when GS2.Config.ScarletRevert: return new PlanetAlgorithm0();
case 9 when !GS2.Config.ScarletRevert: return new PlanetAlgorithm9();
case 10: return new PlanetAlgorithm10();
case 11: return new PlanetAlgorithm11();
case 12: return new PlanetAlgorithm12();
case 13: return new PlanetAlgorithm13();
case 14: return new PlanetAlgorithm14();
}
GS2.Log("Failed to get Algo! Returning Algo 0");
return new PlanetAlgorithm0();
}
}
}
5 changes: 0 additions & 5 deletions Scripts/Themes/FrozenTundra.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ public static partial class Themes
Habitable = false,
ModX = new Vector2(1f, 1f),
ModY = new Vector2(1f, 1f),
CustomGeneration = false,
TerrainSettings = new GSTerrainSettings
{
Algorithm = "Vanilla"
},
VeinSettings = new GSVeinSettings
{
Algorithm = "Vanilla",
Expand Down
5 changes: 0 additions & 5 deletions Scripts/Themes/PandoraSwamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ public static partial class Themes
Habitable = true,
ModX = new Vector2(1f, 1f),
ModY = new Vector2(3f, 3f),
CustomGeneration = false,
TerrainSettings = new GSTerrainSettings
{
Algorithm = "Vanilla"
},
VeinSettings = new GSVeinSettings
{
Algorithm = "Vanilla",
Expand Down
6 changes: 0 additions & 6 deletions Scripts/Themes/PandoraSwamp2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public static partial class Themes
DisplayName = "Pandora Swamp II".Translate(),
PlanetType = EPlanetType.Ocean,
ThemeType = EThemeType.Telluric,

LDBThemeId = 25,
Algo = 13,
MinRadius = 5,
Expand All @@ -23,11 +22,6 @@ public static partial class Themes
Habitable = true,
ModX = new Vector2(1f, 1f),
ModY = new Vector2(3f, 3f),
CustomGeneration = false,
TerrainSettings = new GSTerrainSettings
{
Algorithm = "Vanilla"
},
VeinSettings = new GSVeinSettings
{
Algorithm = "Vanilla",
Expand Down
4 changes: 2 additions & 2 deletions thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ schemaVersion = "0.0.1"
[package]
namespace = "Galactic_Scale"
name = "GalacticScale"
versionNumber = "2.5.15"
description = "v2.5.15 DSP Update New Planets"
versionNumber = "2.6.0"
description = "v2.6.0 BACKUP SAVES. Fixed planet generation bug that *may* destroy saves. You've been warned."
websiteUrl = "https://github.com/innominata/GalacticScale3"
containsNsfwContent = false

Expand Down

0 comments on commit cc27995

Please sign in to comment.