Skip to content
Permalink
Browse files

Add the relay functionality (off by default) for probe cores (Issue #532

)
  • Loading branch information...
KSP-TaxiService committed Nov 7, 2017
1 parent e3aaf4d commit 30fd599f1592620d3dcaf2ec64104d59e4195399
@@ -36,5 +36,7 @@ public interface ISatellite
/// <summary>Called on connection refresh to update the connections.</summary>
/// <param name="routes">List of network routes.</param>
void OnConnectionRefresh(List<NetworkRoute<ISatellite>> routes);
/// <summary>Gets if the satellite is capable to forward other signals.</summary>
bool CanRelaySignal { get; }
}
}
@@ -16,6 +16,7 @@ public interface ISignalProcessor
bool Powered { get; }
bool IsCommandStation { get; }
bool IsMaster { get; }
bool CanRelaySignal { get; }

// Reserved for Flight Computer
FlightComputer.FlightComputer FlightComputer { get; }
@@ -34,13 +34,15 @@ public string VesselName
public FlightComputer.FlightComputer FlightComputer { get; private set; }
public Vessel Vessel => vessel;
public bool IsMaster => Satellite != null && ReferenceEquals(Satellite.SignalProcessor, this);
public bool CanRelaySignal => AllowSignalRelay;

/* KSP fields */
[KSPField(isPersistant = true)] public bool IsRTPowered;
[KSPField(isPersistant = true)] public bool IsRTSignalProcessor = true;
[KSPField(isPersistant = true)] public bool IsRTCommandStation = false;
[KSPField(isPersistant = true)] public int RTCommandMinCrew = 6;
[KSPField(isPersistant = true)] public bool AlwaysAllowLocalControl = false;
[KSPField(isPersistant = true)] public bool AllowSignalRelay = true;

[KSPField] public bool ShowGUI_Status = true;
[KSPField] public bool ShowEditor_Type = true;
@@ -27,6 +27,7 @@ public string VesselName
public FlightComputer.FlightComputer FlightComputer => null;
public Vessel Vessel => vessel;
public bool IsMaster => false;
public bool CanRelaySignal => true;

[KSPField(isPersistant = true)] public bool IsRTPowered;
[KSPField(isPersistant = true)] public bool IsRTSignalProcessor = true;
@@ -21,11 +21,13 @@ public string VesselName
public Vessel Vessel { get; }
public FlightComputer.FlightComputer FlightComputer => null;
public bool IsMaster => true;
public bool CanRelaySignal { get; }

public ProtoSignalProcessor(ProtoPartModuleSnapshot ppms, Vessel v)
{
Vessel = v;
Powered = ppms.GetBool("IsRTPowered");
CanRelaySignal = ppms.HasValue("AllowSignalRelay")? ppms.GetBool("AllowSignalRelay") : true;

// get the crew count from the vessel
var crewcount = v.GetVesselCrew().Count;
@@ -112,7 +112,7 @@ 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);
return Graph[s.Guid].Where(l => l.Target.Powered && l.Target.CanRelaySignal);
}

private void UpdateGraph(ISatellite a)
@@ -245,6 +245,7 @@ public sealed class MissionControlSatellite : ISatellite, IPersistenceLoad
CelestialBody ISatellite.Body { get { return FlightGlobals.Bodies[Body]; } }
Color ISatellite.MarkColor { get { return MarkColor; } }
IEnumerable<IAntenna> ISatellite.Antennas { get { return Antennas; } }
bool ISatellite.CanRelaySignal { get { return true; } } //not sure if should relay signal. Mission Control can "do" everything isnt it?

public Guid mGuid { get; private set; }
public IEnumerable<IAntenna> MissionControlAntennas { get { return Antennas; } }
@@ -324,6 +324,12 @@ private Color CheckColor(BidirectionalEdge<ISatellite> edge)
return RTSettings.Instance.ActiveConnectionColor;
}
}

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;
if (edge.Type == LinkType.Dish)
@@ -69,6 +69,7 @@ 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(collectionIndex = "STATION")] public List<MissionControlSatellite> GroundStations;
[Persistent(collectionIndex = "PRESETS")] public List<string> PreSets;

@@ -1,4 +1,5 @@
using RemoteTech.SimpleTypes;
using RemoteTech.Modules;
using RemoteTech.SimpleTypes;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -42,6 +43,12 @@ public bool Powered
get { return SignalProcessors.Any(s => s.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)); }
}

/// <summary>Gets if the satellite is a RemoteTech command station.</summary>
public bool IsCommandStation
{

0 comments on commit 30fd599

Please sign in to comment.
You can’t perform that action at this time.