Skip to content

Commit

Permalink
Doot
Browse files Browse the repository at this point in the history
  • Loading branch information
innominata committed Sep 6, 2021
1 parent e84568e commit 02b73c0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 68 deletions.
10 changes: 5 additions & 5 deletions GalacticScale2/Scripts/Bootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Bootstrap : BaseUnityPlugin
internal void Awake()
{
var v = Assembly.GetExecutingAssembly().GetName().Version;
GS2.Version = $"2.1b{v.Build}.{v.Revision}";
GS2.Version = $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision}";
BCE.Console.Init();
var _ = new Harmony("dsp.galactic-scale.2");
Logger = new ManualLogSource("GS2");
Expand Down Expand Up @@ -96,10 +96,10 @@ internal void Awake()

private void FixedUpdate()
{
// if (VFInput.alt)
// {
// if (GameMain.localPlanet != null && GameMain.mainPlayer != null) GS2.Warn((GameMain.localPlanet.uPosition - GameMain.mainPlayer.uPosition).magnitude + " distance");
// }
if (VFInput.alt && VFInput.control && VFInput._openMechLight)
{
GS2.WarnJson(HandleLocalStarPlanets.TransitionRadii);
}
if (VFInput.control && VFInput.alt && VFInput.shift && VFInput._moveRight) GS2.Config.EnableDevMode();

if (GS2.Config.Dev && VFInput.control && VFInput.shift && VFInput._rotate && GameMain.localPlanet != null)
Expand Down
2 changes: 1 addition & 1 deletion GalacticScale2/Scripts/GalacticScale2.0/Init.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace GalacticScale
{
public static partial class GS2
{
public static string Version = "2.0.0a50";
public static string Version = "2.2.1";
private static readonly string AssemblyPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(GS2)).Location);
private static readonly string OldDataDir = Path.Combine(AssemblyPath, "config");
public static readonly string DataDir = Path.Combine(Paths.ConfigPath, "GalacticScale2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public GS2PlanetAlgorithm(GSPlanet gsPlanet)
if (gsPlanet.veinSettings.Algorithm == "Vanilla")
veinAlgo = (p, sketchOnly) =>
{
GS2.WarnJson(gsPlanet);
GS2.WarnJson(gsPlanet.GsTheme);
// GS2.WarnJson(gsPlanet);
// GS2.WarnJson(gsPlanet.GsTheme);
// GS2.Log("GS2PlanetAlgorithm|Constructor|Vanilla Vein Algo Running");
baseAlgorithm.GenerateVeins(sketchOnly);
};
Expand Down Expand Up @@ -108,7 +108,7 @@ public override void GenerateVegetables()

public override void GenerateVeins(bool sketchOnly)
{
GS2.Log($"PlanetAlgorithm|GenerateVeins() for {gsPlanet.Name} {gsPlanet.Theme}");
// GS2.Log($"PlanetAlgorithm|GenerateVeins() for {gsPlanet.Name} {gsPlanet.Theme}");
veinAlgo(gsPlanet, sketchOnly);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class HandleLocalStarPlanets
private static string lastStatus = "";
private static StarData closestStar;
private static PlanetData closestPlanet;
private static readonly Dictionary<PlanetData, double> TransitionRadii = new Dictionary<PlanetData, double>();
public static readonly Dictionary<PlanetData, double> TransitionRadii = new Dictionary<PlanetData, double>();

private static void LogStatus(string incoming = "")
{
Expand Down Expand Up @@ -208,50 +208,50 @@ private static double TransisionDistance(StarData star)
{
return (star.systemRadius + 2) * 40000;
}

private static void CheckTransitionDistanceOfMoon(GSPlanet moon)
{
Log($"Checking TransitionDistanceOfMoon {moon.Name}");
var currentDistance = TransitionRadii[moon.planetData];
var host = moon.planetData.orbitAroundPlanet;
if (host.orbitAroundPlanet == null) return; //If the host is the main planet return
var gsHost = GetGSPlanet(host);

//Ensure the transitiondistance doesn't interfere with the host planet
var distanceBetweenMoonAndHost = moon.OrbitRadius * 40000f;
// var distanceBetweenSurfaces = distanceBetweenMoonAndHost - host.realRadius - moon.planetData.realRadius;
var calcDistanceForMoon = distanceBetweenMoonAndHost / 2 - 100f;
if (calcDistanceForMoon < currentDistance)
//GS2.Log($"1 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
TransitionRadii[moon.planetData] = calcDistanceForMoon;
if (gsHost.MoonCount > 1)
{
//Ensure the transitiondistance doesn't interfere with the other moons
var index = gsHost.Moons.IndexOf(moon);
if (index > 0)
{
var prevMoon = gsHost.Moons[index - 1];
var prvMoonSystemOrbit = (prevMoon.OrbitRadius + prevMoon.SystemRadius) * 40000f;
var differenceBetweenPreviousMoon = moon.OrbitRadius - prvMoonSystemOrbit;
calcDistanceForMoon = differenceBetweenPreviousMoon / 2 - 100f;
if (calcDistanceForMoon < currentDistance)
//GS2.Log($"2 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
TransitionRadii[moon.planetData] = calcDistanceForMoon;
}

if (index < gsHost.MoonCount - 1)
{
//I dont think this should ever be called? Maybe if I use this function for moons that aren't most distant satellite
var nextMoon = gsHost.Moons[index + 1];
var nextMoonSystemOrbit = (nextMoon.SystemRadius - nextMoon.OrbitRadius) * 40000f;
var differenceBetweenNextMoon = nextMoonSystemOrbit - moon.OrbitRadius;
calcDistanceForMoon = differenceBetweenNextMoon / 2 - 100f;
if (calcDistanceForMoon < currentDistance)
//GS2.Log($"3 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
TransitionRadii[moon.planetData] = calcDistanceForMoon;
}
}
}
//
// private static void CheckTransitionDistanceOfMoon(GSPlanet moon)
// {
// Log($"Checking TransitionDistanceOfMoon {moon.Name}");
// var currentDistance = TransitionRadii[moon.planetData];
// var host = moon.planetData.orbitAroundPlanet;
// if (host.orbitAroundPlanet == null) return; //If the host is the main planet return
// var gsHost = GetGSPlanet(host);
//
// //Ensure the transitiondistance doesn't interfere with the host planet
// var distanceBetweenMoonAndHost = moon.OrbitRadius * 40000f;
// // var distanceBetweenSurfaces = distanceBetweenMoonAndHost - host.realRadius - moon.planetData.realRadius;
// var calcDistanceForMoon = distanceBetweenMoonAndHost / 2 - 100f;
// if (calcDistanceForMoon < currentDistance)
// //GS2.Log($"1 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
// TransitionRadii[moon.planetData] = calcDistanceForMoon;
// if (gsHost.MoonCount > 1)
// {
// //Ensure the transitiondistance doesn't interfere with the other moons
// var index = gsHost.Moons.IndexOf(moon);
// if (index > 0)
// {
// var prevMoon = gsHost.Moons[index - 1];
// var prvMoonSystemOrbit = (prevMoon.OrbitRadius + prevMoon.SystemRadius) * 40000f;
// var differenceBetweenPreviousMoon = moon.OrbitRadius - prvMoonSystemOrbit;
// calcDistanceForMoon = differenceBetweenPreviousMoon / 2 - 100f;
// if (calcDistanceForMoon < currentDistance)
// //GS2.Log($"2 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
// TransitionRadii[moon.planetData] = calcDistanceForMoon;
// }
//
// if (index < gsHost.MoonCount - 1)
// {
// //I dont think this should ever be called? Maybe if I use this function for moons that aren't most distant satellite
// var nextMoon = gsHost.Moons[index + 1];
// var nextMoonSystemOrbit = (nextMoon.SystemRadius - nextMoon.OrbitRadius) * 40000f;
// var differenceBetweenNextMoon = nextMoonSystemOrbit - moon.OrbitRadius;
// calcDistanceForMoon = differenceBetweenNextMoon / 2 - 100f;
// if (calcDistanceForMoon < currentDistance)
// GS2.Log($"3 Adjusting TransitionDistance of {moon.Name} to {calcDistanceForMoon}");
// // TransitionRadii[moon.planetData] = calcDistanceForMoon;
// }
// }
// }

/// <summary>
/// Calculates a transition distance for a planet, ensuring it is less than the orbit of the first moon, in order to
Expand Down Expand Up @@ -294,10 +294,12 @@ private static double TransisionDistance(PlanetData planet)
{
//First Child's Inner System Radius - Self.RadiusAU
var distanceAU = gsPlanet.Moons[0].OrbitInnermostSystemRadiusAU - gsPlanet.RadiusAU;
//Log($"Distance to first moons Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
Log($"Distance to first moons Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU *20000f -100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}
else if (planet.orbitAroundPlanet != null) //If this is a moon
{
Expand All @@ -308,30 +310,36 @@ private static double TransisionDistance(PlanetData planet)
var index = Host.Moons.IndexOf(gsPlanet);
var PreviousSibling = Host.Moons[index - 1];
var distanceAU = gsPlanet.OrbitInnermostSurfaceRadiusAU - PreviousSibling.OrbitOutermostSystemRadiusAU;
//Log($"Distance to previous siblings Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
Log($"Distance to previous siblings Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU *20000f -100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}
else if (Host.MoonCount > 1)
{
// Check Self.OrbitInnermostSurfaceRadiusAU - Host.RadiusAU
var distanceAU = gsPlanet.OrbitInnermostSurfaceRadiusAU - Host.RadiusAU;
//Log($"Distance to hosts surface from {planet.name} surface is {distanceAU* 40000f}");
Log($"Distance to hosts surface from {planet.name} surface is {distanceAU* 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU *20000f -100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}

if (Host.MoonCount > 1 && Host.Moons.IndexOf(gsPlanet) < Host.Moons.Count - 1)
{
var index = Host.Moons.IndexOf(gsPlanet);
var NextSibling = Host.Moons[index + 1];
var distanceAU = NextSibling.OrbitInnermostSystemRadiusAU - gsPlanet.OrbitOutermostSurfaceRadiusAU;
//Log($"Distance to Next Siblings Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
Log($"Distance to Next Siblings Last Satellite's Surface from {planet.name} surface is {distanceAU* 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU *20000f -100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
//NextSibling.OrbitInnermostSystemRadiusAU - OPrbitOutermostSurfaceRadiusAU
}
}
Expand All @@ -346,21 +354,25 @@ private static double TransisionDistance(PlanetData planet)
if (PreviousSibling.OrbitRadius != gsPlanet.OrbitRadius)
{
var distanceAU = gsPlanet.OrbitInnermostSurfaceRadiusAU - PreviousSibling.OrbitOutermostSystemRadiusAU;
//Log($"Distance to previous siblings Last Satellite's Surface from {planet.name} surface is {distanceAU * 40000f}");
Log($"Distance to previous siblings Last Satellite's Surface from {planet.name} surface is {distanceAU * 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}
}
else if (Host.PlanetCount > 1)
{
// Check Self.OrbitInnermostSurfaceRadiusAU - Host.RadiusAU

var distanceAU = gsPlanet.OrbitInnermostSurfaceRadiusAU - Host.RadiusAU;
//Log($"Distance to hosts surface from {planet.name} surface is {distanceAU* 40000f}");
Log($"Distance to hosts surface from {planet.name} surface is {distanceAU* 40000f}");
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU *20000f -100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}

if (Host.PlanetCount > 1 && Host.Planets.IndexOf(gsPlanet) < Host.Planets.Count - 1)
Expand All @@ -370,11 +382,13 @@ private static double TransisionDistance(PlanetData planet)
if (NextSibling.OrbitRadius != gsPlanet.OrbitRadius)
{
var distanceAU = NextSibling.OrbitInnermostSystemRadiusAU - gsPlanet.OrbitOutermostSurfaceRadiusAU;
//Log($"Distance to Next Siblings Last Satellite's Surface from {planet.name} surface is {distanceAU * 40000f}");
Log($"Distance to Next Siblings Last Satellite's Surface from {planet.name} surface is {distanceAU * 40000f}");
//NextSibling.OrbitInnermostSystemRadiusAU - OPrbitOutermostSurfaceRadiusAU
if (distanceAU * 20000f - 100f < transitionDistance)
//Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
{
Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}");
transitionDistance = distanceAU * 20000f - 100f;
}
}
}
}
Expand Down

0 comments on commit 02b73c0

Please sign in to comment.