-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3f39db
commit cc27995
Showing
13 changed files
with
260 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters