Skip to content

Commit

Permalink
.27
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Jan 29, 2022
1 parent 9a70852 commit e00212c
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 21 deletions.
2 changes: 1 addition & 1 deletion GalacticScale2/Scripts/Bootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class GS2
[BepInDependency(NebulaAPI.NebulaModAPI.API_GUID)]
public class Bootstrap : BaseUnityPlugin
{
public const string VERSION = "2.2.0.26";
public const string VERSION = "2.2.0.27";

public new static ManualLogSource Logger;

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

Expand Down Expand Up @@ -74,6 +75,20 @@ public static GSStars Stars

public static int StarCount => Stars.Count;

public static int PrimaryStarCount()
{
int count = 0;
// var companions = new List<
for (int i = 0; i < Stars.Count; i++)
{
// var companion = Stars[i].BinaryCompanion;
if (!Stars[i].genData.ContainsKey("binary") || !Stars[i].genData["binary"]) count++;
// if (companion == string.Empty || companion == null) count++;
}

return count;
}

public static GSPlanet BirthPlanet
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,17 @@ public static bool UpdateUIDisplay(ref UIGalaxySelect __instance, GalaxyData gal
if (galaxy.stars == null) return false;

__instance.seedInput.text = galaxy.seed.ToString("0000 0000");
__instance.starCountSlider.value = galaxy.starCount;
__instance.starCountText.text = galaxy.starCount.ToString();
if (GS2.Vanilla)
{
__instance.starCountSlider.value = galaxy.starCount;
__instance.starCountText.text = galaxy.starCount.ToString();
}
else
{
__instance.starCountSlider.value = GSSettings.PrimaryStarCount();
__instance.starCountText.text = GSSettings.PrimaryStarCount().ToString();
}

var M = 0;
var K = 0;
var G = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using HarmonyLib;
using System;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

namespace GalacticScale
Expand All @@ -10,22 +12,68 @@ public partial class PatchOnUIGameLoadingSplash
public static void Update(ref Text ___promptText)
{
var status = "WARNING - Galactic Scale savegames can be broken by updates.Read the FAQ @ http://customizing.space\r\n".Translate();
if (GameMain.localStar != null && !GameMain.localStar.loaded)
status += "Loading Planets: ".Translate();
// GS2.Warn("A");
status += $"{HandleLocalStarPlanets.GetStarLoadingStatus(GameMain.localStar)}";
// GS2.Warn("B");
if (GameMain.localStar != null && HandleLocalStarPlanets.GetLoadedPlanetCount(GameMain.localStar) >= GameMain.localStar.planets.Length || GS2.Vanilla) return;
// GS2.Warn("C");
var loadingPlanet = GameMain.localStar?.planets[HandleLocalStarPlanets.GetLoadedPlanetCount(GameMain.localStar)];
// GS2.Warn("D");
status += $" {loadingPlanet?.name}, a size {loadingPlanet?.realRadius} {GS2.GetGSPlanet(loadingPlanet)?.GsTheme?.DisplayName} ";
// GS2.Warn("E");
if (loadingPlanet?.orbitAroundPlanet != null) status += "Moon " ;
else status += "Planet ";
//status += $"with a {loadingPlanet.orbitRadius}AU Orbit";
// GS2.Warn("F");

if (!GS2.Vanilla && GameMain.localStar != null && !GameMain.localStar.loaded && GameMain.localStar.planets != null && GameMain.localStar.planets.Length > 0)
{
GetStatusText(ref status, GameMain.localStar);
}
// else
// {
// // GS2.Warn("Fail");
// }

if (___promptText != null) ___promptText.text = status;
}

private static void GetStatusText(ref string status, StarData star)
{
// GS2.Warn("A");
var SLS = GetStarLoadingStatus(star);
var LPC = GetLoadedPlanetCount(star);
status += "Loading Planets: ".Translate();
status += SLS;
if (GameMain.localStar != null && LPC >= star.planets?.Length) return;
var loadingPlanet = GetLoadingPlanet(star);
var planetSize = GetPlanetSize(loadingPlanet);
var planetName = GetPlanetName(loadingPlanet);
var planetTheme = GetPlanetGSThemeName(loadingPlanet);
status += $" {planetName}, {"a size".Translate()} {planetSize} {planetTheme} ";
if (IsMoon(loadingPlanet)) status += "Moon ".Translate() ;
else status += "Planet ".Translate();
}

private static bool IsMoon(PlanetData planet) => planet?.orbitAroundPlanet != null;
private static int GetLoadedPlanetCount(StarData star) => HandleLocalStarPlanets.GetLoadedPlanetCount(star);
private static string GetStarLoadingStatus(StarData star) => HandleLocalStarPlanets.GetStarLoadingStatus(star);

private static string GetPlanetName(PlanetData planet)
{
var name = planet.displayName;
if (name == String.Empty || name == null) name = "Error getting Planet Name";
return name;
}
private static int GetPlanetSize(PlanetData planet)
{
var size = Mathf.RoundToInt(planet.realRadius);
return size;
}
private static string GetPlanetGSThemeName(PlanetData planet)
{
var GSPlanetTheme = GetPlanetGSTheme(planet);
return GSPlanetTheme.DisplayName;
}
private static PlanetData GetLoadingPlanet(StarData star)
{
var loadingPlanetCount = HandleLocalStarPlanets.GetLoadedPlanetCount(star);
var planet = star.planets[loadingPlanetCount];
return planet;
}

private static GSTheme GetPlanetGSTheme(PlanetData planet)
{
GSTheme theme = GS2.GetGSPlanet(planet)?.GsTheme;
if (theme == null) return new GSTheme() { DisplayName = "Error Loading Theme" };
return theme;
}
}
}
Binary file added Galactic_Scale-GalacticScale-2.2.27.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions Package/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# DSP Galactic Scale 2.0 Mod
- Version 2.2.0.27 - Hotfix for rare loading issue

- Version 2.2.0.26 - Hopefully Geothermal is working on every planet now :)

- Version 2.2.0.25 - Fixed Geothermal for Vanilla, Fixed Error on New Game. Added Debug Option to revert Scarlet Ice Lake
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.2.26"
description = "v2.2.0.26 Geothermal Fix (Hopefully the last one)"
versionNumber = "2.2.27"
description = "v2.2.0.27 Loading Fix (Hopefully)"
websiteUrl = "https://github.com/Touhma/DSP_Plugins"
containsNsfwContent = false

Expand Down

0 comments on commit e00212c

Please sign in to comment.