Skip to content

Commit

Permalink
2.1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Aug 30, 2021
1 parent ec39eb3 commit 383249a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}


Expand Down
22 changes: 15 additions & 7 deletions GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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}");
Expand Down Expand Up @@ -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);
Expand All @@ -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}");
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
11 changes: 6 additions & 5 deletions GalacticScale2/Scripts/GalacticScale2.0/Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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])}";
}
}
Expand Down

0 comments on commit 383249a

Please sign in to comment.