From 383249a99fd3ed394bf764b506930e495c369cb4 Mon Sep 17 00:00:00 2001 From: innominata Date: Mon, 30 Aug 2021 23:14:07 +1200 Subject: [PATCH] 2.1.13 --- .../Generators/GS2Dev/Planets.cs | 2 +- .../Generators/GS2Dev/Stars.cs | 22 +++++++++++++------ .../Utils/HandleLocalStarPlanets.cs | 2 +- .../Scripts/GalacticScale2.0/Utils/Utils.cs | 11 +++++----- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs index bfc17d39..36862c2b 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Planets.cs @@ -134,7 +134,7 @@ private void GeneratePlanetsForStar(GSStar star) randomMoon.Moons.Add(mm); mm.genData.Add("hosttype", "moon"); mm.genData.Add("hostname", randomMoon.Name); - // GS2.Log($"Added {mm} to {randomMoon}"); + // GS2.Log($"Added {mm} {mm.Radius} to {randomMoon.Name}"); } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs index 2f722f82..05808316 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs @@ -135,7 +135,7 @@ private int GetStarMoonSize(GSStar star, int hostRadius, bool hostGas) max = Utils.ParsePlanetSize(hostRadius - 10); } - if (max <= min) return min; + if (max <= min) return ParsePlanetSize(min); float average = (max - min) / 2 + min; var range = max - min; var sd = (float) range / 4; @@ -146,7 +146,9 @@ private int GetStarMoonSize(GSStar star, int hostRadius, bool hostGas) //Warn($"MoonSize {size} selected for {star.Name} moon with host size {hostRadius} avg:{average} sd:{sd} max:{max} min:{min} range:{range} hostGas:{hostGas}"); // size = Utils.ParsePlanetSize(hostRadius - 10); //} - return ParsePlanetSize(size); + var result =ParsePlanetSize(size); + // Warn(result +$"is size for {star.Name} moon"); + return result; // return size; } private int GetStarPlanetSize(GSStar star) @@ -170,9 +172,10 @@ private int ParsePlanetSize(int size) if (preferences.GetBool("limitPlanetSize300", false)) sizes.Add(300); if (preferences.GetBool("limitPlanetSize400", false)) sizes.Add(400); if (preferences.GetBool("limitPlanetSize500", false)) sizes.Add(500); - // GS2.Log("Got List"); + // GS2.Log("Got List "+sizes.Count); var count = sizes.Count; if (count == 0) return size; + // Log("Count wasnt 0"); var largest = sizes[sizes.Count - 1]; var smallest = sizes[0]; // GS2.Warn($"Size:{size} Count:{sizes.Count}"); @@ -213,8 +216,12 @@ private FloatPair CalculateHabitableZone(GSStar star) } if (star.genData.Get("hasBinary", false)) { - min += star.genData.Get("binaryOffset", 1); - max += star.genData.Get("binaryOffset", 1); + // GS2.Warn($"{star.Name} Binary offset : {star.genData.Get("binaryOffset", 1f)}"); + // GS2.Warn($"Increasing by {star.genData.Get("binaryOffset", 1)*60f}"); + // GS2.Warn($"Star RadiusAU:{star.RadiusAU}"); + // GS2.WarnJson(GSSettings.Stars.Select(o=>(o.Name,o.RadiusAU)).ToList()); + min += (star.genData.Get("binaryOffset", 1f)*60f); + max += (star.genData.Get("binaryOffset", 1f)*60f); } star.genData.Set("minHZ", min); star.genData.Set("maxHZ", max); @@ -229,12 +236,13 @@ private float CalculateMinimumOrbit(GSStar star) var radius = star.RadiusAU; var lum = star.luminosity; var min = radius +( 0.2f * radius * Mathf.Sqrt(Mathf.Sqrt(lum))); - if (star.genData.Get("hasBinary", false)) min += star.genData.Get("binaryOffset", 1); + if (preferences.GetBool($"{sl}orbitOverride")) { var fp = preferences.GetFloatFloat($"{sl}orbits", new FloatPair(0.02f,20f)); min = fp.low; } + if (star.genData.Get("hasBinary", false)) min += (star.genData.Get("binaryOffset", 1f)*60f); min = Mathf.Clamp(min , radius * 1.1f, 100f); star.genData.Set("minOrbit", min); // Warn($"Getting Min Orbit for Star {star.Name} Min:{min}"); @@ -261,7 +269,7 @@ private float CalculateMaximumOrbit(GSStar star) max = fp.high; } // Warn($"Getting Max Orbit for Star {star.Name} HardCap:{star.MaxOrbit} MaxbyRadius({star.radius}):{maxOrbitByRadius} MaxbyPlanets({star.PlanetCount}):{maxByPlanetCount} MaxbyLum({lum}):{maxOrbitByLuminosity} MaxByHZ({hzMax}):{maxOrbitByHabitableZone} Max({max}):{max} HabitableZone:{star.genData.Get("minHZ")}:{hzMax}"); - if (star.genData.Get("hasBinary", false)) max += star.genData.Get("binaryOffset", 1); + if (star.genData.Get("hasBinary", false)) max += (star.genData.Get("binaryOffset", 1f)*60f); star.genData.Set("maxOrbit", max); return max; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs b/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs index 8a8cd241..50eda70b 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs @@ -143,7 +143,7 @@ public static bool Update() private static void EnsureStarStillLocal() { - LogStatus($"Ensure {closestStar.name} still local..."); + if (closestStar.loaded) LogStatus($"Ensure {closestStar.name} still local..."); if (!(DistanceTo(closestStar) > TransisionDistance(closestStar))) return; // GS2.Log( // $"Leaving star {closestStar.name} as its too far away {DistanceTo(closestStar) / 40000}AU < {TransisionDistance(closestStar) / 40000}AU"); diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs b/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs index 771f1c9b..75098d68 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs @@ -325,12 +325,13 @@ public static string GetStarDetail(StarData star) if (sa.Length > 50) { output = ""; + + output = "Luminosity: " + Math.Round(Math.Pow(star.luminosity, 0.33), 2); if (gsStar.BinaryCompanion != null) { var binary = GS2.GetGSStar(gsStar.BinaryCompanion); if ( binary != null) output += $"Binary Star ({binary.Type})\r\n"; } - output = "Luminosity: " + Math.Round(Math.Pow(star.luminosity, 0.33), 2); var sa1 = new string[50]; var sa2 = new string[sa.Length -50]; for (int i = 0; i < 50; i++) @@ -339,15 +340,15 @@ public static string GetStarDetail(StarData star) // GS2.Warn(i + " " + (j) + " "+sa.Length); if (sa.Length > (j)) { - GS2.Log(i.ToString() + " " + j.ToString()); + // GS2.Log(i.ToString() + " " + j.ToString()); var a = string.Format("{0,30}", sa[i]); - var b = string.Format("{0,30}", sa[j]); - output += $"\r\n{a} | {b}"; + var b = string.Format("{0,-30}", sa[j]); + output += $"\r\n{a} {b}"; } else { - GS2.Warn(i.ToString()); + // GS2.Warn(i.ToString()); output += $"\r\n{string.Format("{0,30}", sa[i])}"; } }