Skip to content

Commit

Permalink
orbitDisplayMode is now an array, fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Jan 2, 2019
1 parent 3127424 commit a24e11f
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions CustomGameVariables.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using UniLinq;
using System.Text;
Expand Down Expand Up @@ -115,7 +115,7 @@ public class CustomGameVariables : GameVariables
public float[] upgradesTracking;
public int[] upgradesVisualTracking;
private float unlockedSpaceObjectDiscovery = 0.6f;
private float orbitDisplayMode = -1;
private int[] orbitDisplayMode;
private int[] patchesAheadLimit;
private int[] trackedObjectLimit;
private double[] DSNRange;
Expand Down Expand Up @@ -279,7 +279,23 @@ public void Load(GameVariables orig)
LoadValue(node, "upgrades", ref upgradesTracking);
LoadValue(node, "upgradesVisual", ref upgradesVisualTracking);
LoadValue(node, "unlockedSpaceObjectDiscovery", ref unlockedSpaceObjectDiscovery);
LoadValue(node, "orbitDisplayMode", ref orbitDisplayMode);

// Import 1.1.18 and older orbitDisplayMode single value config
float odm = 0;
if (node.HasValue("orbitDisplayMode") && node.TryGetValue("orbitDisplayMode", ref odm))
{
orbitDisplayMode = new int[levelsTracking];

for (int i = 0; i < levelsTracking; i++)
{
orbitDisplayMode[i] = i < odm - 1 ? 2 : 3;
}
}
else
{
LoadValue(node, "orbitDisplayMode", ref orbitDisplayMode);
}

LoadValue(node, "patchesAheadLimit", ref patchesAheadLimit);
LoadValue(node, "trackedObjectLimit", ref trackedObjectLimit);
LoadValue(node, "DSNRange", ref DSNRange);
Expand Down Expand Up @@ -666,16 +682,13 @@ public override bool UnlockedSpaceObjectDiscovery(float tsNormLevel)

public override OrbitDisplayMode GetOrbitDisplayMode(float tsNormLevel)
{
if (orbitDisplayMode < 0)
if (orbitDisplayMode == null || orbitDisplayMode.Length != levelsTracking)
{
debugLog("orbitDisplayMode wrong size");
return original.GetOrbitDisplayMode(tsNormLevel);
}

if (tsNormLevel < (orbitDisplayMode - 1.1) / (levelsTracking - 1))
{
return OrbitDisplayMode.AllOrbits;
}
return OrbitDisplayMode.PatchedConics;
return (OrbitDisplayMode)NormLevelToArrayValue(tsNormLevel, orbitDisplayMode);
}

public override string ToString()
Expand Down Expand Up @@ -751,7 +764,7 @@ public override string ToString()
sb.AppendLine("upgradesTracking " + DumpArray(upgradesTracking));
sb.AppendLine("upgradesVisualTracking " + DumpArray(upgradesVisualTracking));
sb.AppendLine("unlockedSpaceObjectDiscovery " + unlockedSpaceObjectDiscovery.ToString("F2"));
sb.AppendLine("orbitDisplayMode " + orbitDisplayMode.ToString("F2"));
sb.AppendLine("orbitDisplayMode " + DumpArray(orbitDisplayMode));
sb.AppendLine("patchesAheadLimit " + DumpArray(patchesAheadLimit));
sb.AppendLine("trackedObjectLimit " + DumpArray(trackedObjectLimit));
sb.AppendLine("DSNRange " + DumpArray(DSNRange));
Expand Down

0 comments on commit a24e11f

Please sign in to comment.