From e6b5d772e5980a5fb0b2e3f59e5bd38ee73d2160 Mon Sep 17 00:00:00 2001 From: KSP-TaxiService Date: Tue, 19 Jan 2021 23:44:41 +0800 Subject: [PATCH] Fix issue of vessels connecting to ground stations not built yet --- .../CommNetLayer/CNCCommNetHome.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs b/src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs index 7eef624..d62f5d7 100644 --- a/src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs +++ b/src/CommNetConstellation/CommNetLayer/CNCCommNetHome.cs @@ -446,7 +446,7 @@ public static Texture2D getGroundStationTexture(int techLevel) /// Comment: Subclassing GameVariables.Instance.GetDSNRange to just change the ranges is too excessive at this point. public double GetDSNRange(short level) { - double power; + double power = 0.0; if (this.CommNetHome.isKSC) { power = CNCSettings.Instance.KSCStationPowers[level - 1]; @@ -455,7 +455,7 @@ public double GetDSNRange(short level) { if (level == 0) { - power = 0; + power = 0.0; } else { @@ -471,6 +471,12 @@ public double GetDSNRange(short level) /// protected override void Update() { + if (HighLogic.CurrentGame == null) + return; + + if (!(HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.TRACKSTATION)) + return; + if (this.comm != null && this.body != null) { this.comm.precisePosition = this.body.GetWorldSurfacePosition(this.latitude, this.longitude, this.altitude); @@ -481,6 +487,8 @@ protected override void Update() { this.CommNetHome.nodeTransform.position = this.comm.precisePosition; } + + this.refresh(); } }