Skip to content

Commit

Permalink
2.1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Aug 27, 2021
1 parent 383129f commit d26553c
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 29 deletions.
7 changes: 4 additions & 3 deletions GalacticScale2/Scripts/Bootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class GS2
// [BepInDependency("nebula.api", BepInDependency.DependencyFlags.HardDependency)]
public class Bootstrap : BaseUnityPlugin
{
public const string VERSION = "2.1.9.0";
public const string VERSION = "2.1.10.0";

public new static ManualLogSource Logger;

Expand Down Expand Up @@ -103,9 +103,10 @@ private void FixedUpdate()
GameMain.Pause();
UIRoot.instance.uiGame.escMenu._Open();
}

GameMain.Pause();
UIRoot.instance.OpenOptionWindow();
GS2.Config.LoadJsonGalaxy("Pasta");
GS2.Warn($"********* Loading {GS2.Config.ImportFilename}");
GS2.Config.LoadJsonGalaxy(GS2.Config.ImportFilename);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
using UnityEngine;

namespace GalacticScale
{
Expand All @@ -12,7 +13,7 @@ public static void CreateStarPlanetsAstroPoses(Random random)
galaxy.astroPoses = new AstroPose[gSize];
Log("Creating Stars");
for (var i = 0; i < GSSettings.StarCount; i++) galaxy.stars[i] = CreateStar(i, random);

if (!GSSettings.Instance.imported)
foreach (var star in GSSettings.Stars)
{
if (star.BinaryCompanion != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static GalaxyData ProcessGalaxy(GameDesc desc, bool sketchOnly = false)
//Warn("Cleared");
Log("Loading Data from Generator : " + ActiveGenerator.Name);
ActiveGenerator.Generate(gameDesc.starCount);
GSSettings.Instance.generatorGUID = ActiveGenerator.GUID;
Log("Final Seed = " + GSSettings.Seed);
//Log("End");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GSSettings

private static int birthPlanetId = -1; // this is a vanilla id, not a GS Index!
private static string birthPlanetName;

public string generatorGUID = null;

[SerializeField] public GSGalaxyParams galaxyParams = new GSGalaxyParams();

Expand Down
23 changes: 23 additions & 0 deletions GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,30 @@ namespace GalacticScale
{
public class PatchOnWhatever
{
[HarmonyPrefix, HarmonyPatch(typeof(UIVeinDetail), "SetInspectPlanet")]
public static bool SetInspectPlanet(ref UIVeinDetail __instance, PlanetData planet)
{
__instance.inspectPlanet = planet;
for (int i = 0; i < __instance.allTips.Count; i++)
{
if (__instance.allTips[i] != null)
{
__instance.allTips[i]._Free();
__instance.allTips[i].inspectPlanet = __instance.inspectPlanet;
}
}
if (__instance.inspectPlanet != null)
{
var veinTipConfig = GS2.Config.VeinTips;
for (int j = 0; j < planet.veinGroups.Length; j++)
{
var typeNum = (int)planet.veinGroups[j].type;
if (veinTipConfig.ContainsKey(typeNum) && veinTipConfig[typeNum]) __instance.CreateOrOpenATip(planet, j);
}
}

return false;
}
// [HarmonyPostfix, HarmonyPatch(typeof(UIDysonBrush_Shell), "_OnInit")]
// public static void _OnInit(UIDysonBrush_Shell __instance)
// {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,14 @@ public static void ModelingCoroutine()
catch (Exception message)
{
Error(message.ToString());
currentModelingPlanet.Unload();
currentModelingPlanet.factoryLoaded = false;
currentModelingPlanet = null;
currentModelingStage = 0;
currentModelingSeamNormal = 0;
if (currentModelingPlanet != null)
{
currentModelingPlanet.Unload();
currentModelingPlanet.factoryLoaded = false;
currentModelingPlanet = null;
currentModelingStage = 0;
currentModelingSeamNormal = 0;
}
}
}
}
Expand Down
97 changes: 80 additions & 17 deletions GalacticScale2/Scripts/GalacticScale2.0/SettingsUI/MainSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using System.Linq;
using GalacticScale.Generators;
using GSSerializer;

using ScenarioRTL;
using static GalacticScale.GS2;
namespace GalacticScale
{
public class GS2MainSettings : iConfigurableGenerator
Expand All @@ -20,6 +21,7 @@ public class GS2MainSettings : iConfigurableGenerator
public bool ForceRare => Preferences.GetBool("Force Rare Spawn");
public bool DebugMode => Preferences.GetBool("Debug Log");
public bool Dev => Preferences.GetBool("Dev");
public string ImportFilename => Preferences.GetString("Import Filename", "");
public bool SkipPrologue => Preferences.GetBool("Skip Prologue", true);
public bool SkipTutorials => Preferences.GetBool("Skip Tutorials");
public bool CheatMode => Preferences.GetBool("Cheat Mode");
Expand All @@ -40,6 +42,20 @@ public bool MinifyJson
public bool FixCopyPaste => true; //Preferences.GetBool("Fix CopyPaste", true);
public string GeneratorID => Preferences.GetString("Generator ID", "space.customizing.generators.vanilla");
public bool UseExternalThemes => Preferences.GetBool("Use External Themes");

public Dictionary<int, bool> VeinTips
{
get
{
var veintips = new Dictionary<int, bool>();
for (var i = 1; i < 15; i++)
{
veintips.Add(i, Preferences.GetBool($"veinTip{i}", true));
}

return veintips;
}
}
public float ResourceMultiplier => Preferences.GetFloat("Resource Multiplier", 1f);
public float LogisticsShipMulti => Preferences.GetFloat("Logistics Ship Multi", 1f);
public List<string> ExternalThemeNames => Preferences.GetStringList("External Themes", new List<string>());
Expand Down Expand Up @@ -89,41 +105,88 @@ public void Init()
_generatorsCombobox = Options.Add(GSUI.Combobox("Generator".Translate(), _generatorNames, 0, "Generator",
GeneratorCallback, "Try them all!".Translate()));
RefreshFileNames();
Options.Add(GSUI.Checkbox("Skip Prologue".Translate(), true, "Skip Prologue"));
Options.Add(GSUI.Checkbox("Skip Tutorials".Translate(), false, "Skip Tutorials"));

// Options.Add(GSUI.Checkbox("Vanilla Grid (200r)".Translate(), false, "Vanilla Grid", VanillaGridCheckboxCallback, "Use the vanilla grid for 200 size planets".Translate()));


var VeinOptions = new GSOptions();
VeinOptions.Add(GSUI.Spacer());
VeinOptions.Add(GSUI.Checkbox("Show Iron Vein Labels".Translate(), true, "veinTip1", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Copper Vein Labels".Translate(), true, "veinTip2", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Silicon Vein Labels".Translate(), true, "veinTip3", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Titanium Vein Labels".Translate(), true, "veinTip4", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Stone Vein Labels".Translate(), true, "veinTip5", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Coal Vein Labels".Translate(), true, "veinTip6", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Oil Vein Labels".Translate(), true, "veinTip7", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Fire Ice Vein Labels".Translate(), true, "veinTip8", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Kimberlite Labels".Translate(), true, "veinTip9", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Fractal Silicon Vein Labels".Translate(), true, "veinTip10", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Organic Crystal Vein Labels".Translate(), true, "veinTip11", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Optical Grating Vein Labels".Translate(), true, "veinTip12", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Spiriform Vein Labels".Translate(), true, "veinTip13", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Checkbox("Show Unipolar Vein Labels".Translate(), true, "veinTip14", UpdateVeinDetail, "When show vein markers is enabled".Translate()));
VeinOptions.Add(GSUI.Spacer());

var GameOptions = new GSOptions();
GameOptions.Add(GSUI.Spacer());
GameOptions.Add(GSUI.Checkbox("Skip Prologue".Translate(), true, "Skip Prologue"));
GameOptions.Add(GSUI.Checkbox("Skip Tutorials".Translate(), false, "Skip Tutorials"));
GameOptions.Add(GSUI.Group("Show/Hide Vein Labels".Translate(), VeinOptions, "Useful for finding veins".Translate()));
GameOptions.Add(GSUI.Spacer());
Options.Add(GSUI.Group("Quality of Life".Translate(), GameOptions, "Useful settings".Translate()));
Options.Add(GSUI.Spacer());

var DebugOptions = new GSOptions();
// DebugOptions.Add(GSUI.Button("Debug", "Go", (o) => { GS2.Warn(GameMain.localPlanet.runtimePosition + " " + GameMain.localStar.uPosition); }, null, null));
DebugOptions.Add(GSUI.Spacer());
DebugOptions.Add(GSUI.Checkbox("Debug Log".Translate(), false, "Debug Log", null, "Print extra logs to BepInEx console".Translate()));
DebugOptions.Add(GSUI.Checkbox("Force Rare Spawn".Translate(), false, "Force Rare Spawn", null, "Ignore randomness/distance checks".Translate()));
_cheatModeCheckbox = DebugOptions.Add(GSUI.Checkbox("Cheat Mode".Translate(), false, "Cheat Mode", null, "All Research, TP by ctrl-click nav arrow".Translate()));
DebugOptions.Add(GSUI.Slider("Ship Speed Multiplier".Translate(), 1f, 1f, 100f, "Logistics Ship Multi", null, "Multiplier for Warp Speed of Ships".Translate()));
DebugOptions.Add(GSUI.Button("Fix Binary Star Position".Translate(), "Now", ResetBinaryStars, null, "Will need to be saved and loaded to apply".Translate()));
DebugOptions.Add(GSUI.Spacer());
Options.Add(GSUI.Group("Debug Options".Translate(), DebugOptions, "Useful for testing galaxies/themes".Translate()));
Options.Add(GSUI.Spacer());

var JsonOptions = new GSOptions();
DebugOptions.Add(GSUI.Spacer());
JsonOptions.Add(GSUI.Input("Export Filename".Translate(), "My First Custom Galaxy", "Export Filename", null, "Excluding .json".Translate()));
JsonOptions.Add(GSUI.Checkbox("Minify Exported JSON".Translate(), false, "Minify JSON", null, "Only save changes".Translate()));
_exportButton = JsonOptions.Add(GSUI.Button("Export Custom Galaxy".Translate(), "Export".Translate(), ExportJsonGalaxy, null, "Save Galaxy to File".Translate()));
JsonGalaxies = JsonOptions.Add(GSUI.Combobox("Custom Galaxy".Translate(), filenames, CustomFileSelectorCallback, CustomFileSelectorPostfix));
JsonOptions.Add(GSUI.Button("Load Custom Galaxy".Translate(), "Load", LoadJsonGalaxy, null,
"Will end current game".Translate()));

JsonOptions.Add(GSUI.Button("Load Custom Galaxy".Translate(), "Load", LoadJsonGalaxy, null, "Will end current game".Translate()));
DebugOptions.Add(GSUI.Spacer());

Options.Add(GSUI.Group("Custom Galaxy Export/Import".Translate(), JsonOptions, "Export available once in game".Translate()));
}

// private void VanillaGridCheckboxCallback(Val o)
// {
// if (GameMain.isPaused) return;
// if (GS2.keyedLUTs.ContainsKey(200)) GS2.keyedLUTs.Remove(200);
// if (PatchOnUIBuildingGrid.LUT512.ContainsKey(200))
// {
// PatchOnUIBuildingGrid.LUT512.Remove(200);
// }
// }

public void ResetBinaryStars(Val o)
{
var random = new GS2.Random(GSSettings.Seed);
foreach (var star in GSSettings.Stars)
{
if (star.BinaryCompanion != null)
{

var binary = GS2.GetGSStar(star.BinaryCompanion);
if (binary == null)
{
Error($"Could not find Binary Companion:{star.BinaryCompanion}");
continue;
}
var offset = star.genData.Get("binaryOffset", (star.RadiusLY + binary.RadiusLY) * random.NextFloat(1.1f, 1.3f));
binary.position = new VectorLF3(offset, 0, 0);
Log($"Moving Companion Star {star.BinaryCompanion} who has offset {binary.position}");
// GS2.Warn("Setting Binary Star Position");
galaxy.stars[binary.assignedIndex].position = binary.position = star.position + binary.position;
galaxy.stars[binary.assignedIndex].uPosition = galaxy.stars[binary.assignedIndex].position * 2400000.0;
GS2.Log($"Host ({star.Name})Position:{star.position} . Companion ({binary.Name}) Position {binary.position }");
}
}
}
public void UpdateVeinDetail(Val o)
{
if (GameMain.isRunning && !DSPGame.IsMenuDemo && GameMain.localPlanet != null && UIRoot.instance?.uiGame?.veinDetail != null) UIRoot.instance.uiGame.veinDetail.SetInspectPlanet(GameMain.localPlanet);
}
public void SetResourceMultiplier(float val)
{
Preferences.Set("Resource Multiplier", val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ public static partial class TerrainAlgorithms
{
public static void GenerateTerrain00(GSPlanet gsPlanet, double modX = 0.0, double modY = 0.0)
{
if (gsPlanet == null) {GS2.Warn("gsPlanet Null");return;}
GS2.Log($"USING GSTA00 FOR {gsPlanet.Name}");
if (gsPlanet.planetData == null) {GS2.Warn("gsPlanet.planetData Null");return;}
var data = gsPlanet.planetData.data;
for (var i = 0; i < data.dataLength; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public static partial class TerrainAlgorithms
{
public static void GenerateTerrain1(GSPlanet gsPlanet, double modX = 0.0, double modY = 0.0)
{
if (gsPlanet == null) {GS2.Warn("gsPlanet Null");return;}
random = new GS2.Random(gsPlanet.Seed);
GS2.Log($"USING GSTA1 FOR {gsPlanet.Name} with seed {GSSettings.Seed}");
var t = gsPlanet.GsTheme.TerrainSettings;
Expand All @@ -14,6 +15,7 @@ public static void GenerateTerrain1(GSPlanet gsPlanet, double modX = 0.0, double
var seed2 = random.Next();
var simplexNoise1 = new SimplexNoise(seed1);
var simplexNoise2 = new SimplexNoise(seed2);
if (gsPlanet.planetData == null) {GS2.Warn("gsPlanet.planetData Null");return;}
var data = gsPlanet.planetData.data;
//GS2.Log("GenerateTerrain1|" + gsPlanet.Name + "|"+(data == null));
var maxHD = -999;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public static partial class TerrainAlgorithms
{
public static void GenerateTerrain3(GSPlanet gsPlanet, double modX = 0.0, double modY = 0.0)
{
if (gsPlanet == null) {GS2.Warn("gsPlanet Null");return;}
random = new GS2.Random(gsPlanet.Seed);
GS2.Log($"USING GSTA3 FOR {gsPlanet.Name} with seed {GSSettings.Seed}");
var t = gsPlanet.GsTheme.TerrainSettings;
var t = gsPlanet?.GsTheme.TerrainSettings;
//GS2.Log("Generate Terrain for " + gsPlanet.Name + " 3 ");
var planet = gsPlanet.planetData;
if (planet == null) {GS2.Warn("planet Null");return;}
var num1 = 0.007;
var num2 = 0.007;
var num3 = 0.007;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static partial class TerrainAlgorithms

public static void GenerateTerrain5(GSPlanet gsPlanet, double modX = 0.0, double modY = 0.0)
{
if (gsPlanet == null) {GS2.Warn("gsPlanet Null");return;}
random = new GS2.Random(gsPlanet.Seed);
GS2.Log($"USING GSTA5 FOR {gsPlanet.Name} with seed {GSSettings.Seed}");
var t = gsPlanet.GsTheme.TerrainSettings;
Expand All @@ -17,6 +18,7 @@ public static void GenerateTerrain5(GSPlanet gsPlanet, double modX = 0.0, double
var seed2 = random.Next();
var simplexNoise = new SimplexNoise(seed);
var simplexNoise2 = new SimplexNoise(seed2);
if (gsPlanet.planetData == null) {GS2.Warn("gsPlanet.planetData Null");return;}
var data = gsPlanet.planetData.data;
for (var i = 0; i < data.dataLength; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static partial class TerrainAlgorithms
{
public static void GenerateTerrain6(GSPlanet gsPlanet, double modX = 0.0, double modY = 0.0)
{
if (gsPlanet == null) {GS2.Warn("gsPlanet Null");return;}
random = new GS2.Random(gsPlanet.Seed);
// GS2.Log($"USING GSTA6 FOR {gsPlanet.Name} with seed {GSSettings.Seed}");
var t = gsPlanet.GsTheme.TerrainSettings;
Expand All @@ -26,6 +27,7 @@ public static void GenerateTerrain6(GSPlanet gsPlanet, double modX = 0.0, double
var seed2 = random.Next();
var simplexNoise1 = new SimplexNoise(seed1);
var simplexNoise2 = new SimplexNoise(seed2);
if (gsPlanet.planetData == null) {GS2.Warn("gsPlanet.planetData Null");return;}
var data = gsPlanet.planetData.data;
float radius = gsPlanet.Radius;
var planet = gsPlanet.planetData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public static bool Update()

if (localStar != null && !localStar.loaded)
{
EnsureStarStillLocal();
if (closestStar == null)
{
LogStatus("Left Star...Searching");
SearchStar();
}
//We assume the star is still loading, so wait.
LogStatus(
$"Star {localStar.name} loading {GetStarLoadingStatus(localStar)} localPlanet:{localPlanet?.name}");
Expand Down

0 comments on commit d26553c

Please sign in to comment.