Skip to content

Commit 3d595d1

Browse files
author
Sander Hoksbergen
committed
2 parents 5808fe3 + 5adf962 commit 3d595d1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/RemoteTech2/RangeModel/RangeModelExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ public static double DistanceTo(this ISatellite a, NetworkLink<ISatellite> b)
4545

4646
public static bool HasLineOfSightWith(this ISatellite a, ISatellite b)
4747
{
48+
var aPos = a.Position;
49+
var bPos = b.Position;
4850
foreach (CelestialBody referenceBody in FlightGlobals.Bodies)
4951
{
50-
Vector3d bodyFromA = referenceBody.position - a.Position;
51-
Vector3d bFromA = b.Position - a.Position;
52+
Vector3d bodyFromA = referenceBody.position - aPos;
53+
Vector3d bFromA = bPos - aPos;
5254
if (Vector3d.Dot(bodyFromA, bFromA) <= 0) continue;
5355
Vector3d bFromAnorm = bFromA.normalized;
5456
if (Vector3d.Dot(bodyFromA, bFromAnorm) >= bFromA.magnitude) continue;

src/RemoteTech2/VesselSatellite.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ public bool HasLocalControl
2525
if (mLastFrame != Time.frameCount)
2626
{
2727
mLastFrame = Time.frameCount;
28-
return mLastLocalControl = SignalProcessor.Vessel.parts.Any(p => p.isControlSource && !p.FindModulesImplementing<ISignalProcessor>().Any());
28+
var vessel = SignalProcessor.Vessel;
29+
if (vessel.loaded)
30+
{
31+
return mLastLocalControl = vessel.parts.Any(p => p.isControlSource && (p.protoModuleCrew.Any() || !p.FindModulesImplementing<ISignalProcessor>().Any()));
32+
}
33+
else
34+
{
35+
return mLastLocalControl = vessel.parts.Any(p => p.isControlSource && (p.protoPartSnapshot.protoModuleCrew.Any() || !p.FindModulesImplementing<ISignalProcessor>().Any()));
36+
}
2937
}
3038
else
3139
{

0 commit comments

Comments
 (0)