Skip to content

Commit

Permalink
Replace stock SAS module readout
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinBischof committed Nov 14, 2020
1 parent c827704 commit 3610f06
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion GameData/SmartDockingAid/SDA.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"VERSION":
{
"MAJOR":1,
"MINOR":0,
"MINOR":1,
"PATCH":0,
"BUILD":0
},
Expand Down
Binary file modified GameData/SmartDockingAid/SmartDockingAid.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions Source/Extensions/OverwriteModuleText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace SmartDockingAid.Extensions
{
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class OverwriteModuleText : MonoBehaviour
{
public void Start()
{
List<AvailablePart> parts = PartLoader.LoadedPartsList.Where(p => p.partPrefab.Modules.GetModule<ModuleSAS>()).ToList();

foreach (AvailablePart part in parts)
{
ModuleSAS SASmodule = part.partPrefab.FindModuleImplementing<ModuleSAS>();
AvailablePart.ModuleInfo moduleInfo = part.moduleInfos.Where(m => m.moduleName == "SAS").First();
int serviceLevel = (SASmodule.SASServiceLevel + 1);
string moduleText = string.Empty;
for (int i = 0; i < serviceLevel; i++)
moduleText += $"{SASLevels[i]} \n";

if (part.partPrefab.HasModuleImplementing<ModuleDockingAid>())
moduleText += $"{SASLevels[4]} \n";

moduleInfo.info = moduleText;
}
}

private string[] SASLevels = new string[5]
{
$"S0: Stability Assist",
$"S1: Prograde / Retrograde",
$"S2: Radial / Normal",
$"S3: Maneuver / Target",
$"S{AssetLoader.minPilotLevel}: Parallel+ / Parallel-"
};
}
}
14 changes: 6 additions & 8 deletions Source/Modules/ModuleDockingAid.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

// Modifies DockingAidAutopilot to be active if this PartModule is presence on the current vessel

namespace SmartDockingAid
{
class ModuleDockingAid : PartModule
public class ModuleDockingAid : PartModule
{
public override string GetInfo()
{
string info = $"This Probe Core has the abillity to set following additonal SAS Modes: \n Parallel - \n Parallel +";
return info;
}
}

}
}

0 comments on commit 3610f06

Please sign in to comment.