Skip to content

Commit

Permalink
Add RT setting to turn on/off the signal relay feature (Issue #532)
Browse files Browse the repository at this point in the history
  • Loading branch information
KSP-TaxiService committed Nov 8, 2017
1 parent 30fd599 commit da574ae
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions GameData/RemoteTech/Default_Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ RemoteTechSettings
OmniConnectionColor = 0.552941203,0.517647088,0.407843113,1
ActiveConnectionColor = 0.65882349,1,0.0156862792,1
RemoteStationColorDot = 0.996078014,0,0,1
DirectConnectionColor = 0,0.749,0.952,1
SignalRelayEnabled = False
GroundStations
{
STATION
Expand Down
2 changes: 1 addition & 1 deletion src/RemoteTech/Modules/ProtoSignalProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
{
Vessel = v;
Powered = ppms.GetBool("IsRTPowered");
CanRelaySignal = ppms.HasValue("AllowSignalRelay")? ppms.GetBool("AllowSignalRelay") : true;
CanRelaySignal = RTSettings.Instance.SignalRelayEnabled? (ppms.HasValue("AllowSignalRelay")? ppms.GetBool("AllowSignalRelay") : true) : true;

// get the crew count from the vessel
var crewcount = v.GetVesselCrew().Count;
Expand Down
9 changes: 8 additions & 1 deletion src/RemoteTech/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,14 @@ public void FindPath(ISatellite start, IEnumerable<ISatellite> commandStations)
public IEnumerable<NetworkLink<ISatellite>> FindNeighbors(ISatellite s)
{
if (!s.Powered) return Enumerable.Empty<NetworkLink<ISatellite>>();
return Graph[s.Guid].Where(l => l.Target.Powered && l.Target.CanRelaySignal);
if (RTSettings.Instance.SignalRelayEnabled)
{
return Graph[s.Guid].Where(l => l.Target.Powered && l.Target.CanRelaySignal);
}
else
{
return Graph[s.Guid].Where(l => l.Target.Powered);
}
}

private void UpdateGraph(ISatellite a)
Expand Down
11 changes: 7 additions & 4 deletions src/RemoteTech/NetworkRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,13 @@ private Color CheckColor(BidirectionalEdge<ISatellite> edge)
}
}

var satA = RTCore.Instance.Satellites[edge.A.Guid];
var satB = RTCore.Instance.Satellites[edge.B.Guid];
if ((satA != null && !satA.CanRelaySignal) || (satB != null && !satB.CanRelaySignal))
return RTSettings.Instance.DirectConnectionColor;
if (RTSettings.Instance.SignalRelayEnabled)
{
var satA = RTCore.Instance.Satellites[edge.A.Guid];
var satB = RTCore.Instance.Satellites[edge.B.Guid];
if ((satA != null && !satA.CanRelaySignal) || (satB != null && !satB.CanRelaySignal))
return RTSettings.Instance.DirectConnectionColor;
}

if (edge.Type == LinkType.Omni)
return RTSettings.Instance.OmniConnectionColor;
Expand Down
3 changes: 2 additions & 1 deletion src/RemoteTech/RTSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class Settings
[Persistent] public Color OmniConnectionColor;
[Persistent] public Color ActiveConnectionColor;
[Persistent] public Color RemoteStationColorDot;
[Persistent] public Color DirectConnectionColor = new Color(0, 0.749f, 0.952f, 1); //TODO: remove this after some significant time - 7 Nov 2017
[Persistent] public Color DirectConnectionColor = new Color(0, 0.749f, 0.952f, 1); //TODO: remove two new values after some significant time - 7 Nov 2017
[Persistent] public bool SignalRelayEnabled = false;
[Persistent(collectionIndex = "STATION")] public List<MissionControlSatellite> GroundStations;
[Persistent(collectionIndex = "PRESETS")] public List<string> PreSets;

Expand Down
2 changes: 1 addition & 1 deletion src/RemoteTech/VesselSatellite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public bool Powered
/// <summary>Gets if the satellite is capable to forward other signals.</summary>
public bool CanRelaySignal
{
get { return SignalProcessors.Any(s => s.CanRelaySignal && !(s is ModuleSPUPassive)); }
get { return RTSettings.Instance.SignalRelayEnabled ? SignalProcessors.Any(s => s.CanRelaySignal && !(s is ModuleSPUPassive)) : true; }
}

/// <summary>Gets if the satellite is a RemoteTech command station.</summary>
Expand Down

0 comments on commit da574ae

Please sign in to comment.