/// <summary> /// Removes all GroundStations from an Static Object. /// </summary> /// <param name="instance"></param> internal static void DetachGroundStation(StaticInstance instance) { if (KerbalKonstructs.instance.enableCommNet) { CloseCommNetStation(instance); } if (KerbalKonstructs.instance.enableRT) { RemoteTechAddon.RemoveGroundStation(openRTStations[instance]); openRTStations.Remove(instance); } }
/// <summary> /// iterates through all potential open TrackingStations and attaches GroundStations /// </summary> internal static void LoadGroundStations() { if (HighLogic.LoadedScene == GameScenes.MAINMENU || HighLogic.LoadedScene == GameScenes.LOADING) { return; } // only remove the Stock Stations if we should do it. if (KerbalKonstructs.instance.dontRemoveStockCommNet || KerbalKonstructs.instance.enableCommNet == false) { RestoreStockCommNet(); } else { RemoveStockStations(); } // needed as long the Groundstation list is still not saved in persestence layer. if (KerbalKonstructs.instance.enableRT) { // just remove all groundstations and add them later RemoteTechAddon.CloseAllStations(); } foreach (StaticInstance instance in StaticDatabase.allStaticInstances) { if (instance.facilityType != KKFacilityType.GroundStation && instance.facilityType != KKFacilityType.TrackingStation) { continue; } // we check here for the gamemode etc if (!instance.myFacilities[0].isOpen) { continue; } if (openRTStations.ContainsKey(instance) || openCNStations.Contains(instance)) { continue; } // Don't revreal hidden bases if (instance.myFacilities[0].OpenCost == 0f && instance.groupCenter.isHidden) { continue; } AttachGroundStation(instance); } }
/// <summary> /// Attaches A CommNet or RemoteTech Groundstation to a Static Object instance /// </summary> /// <param name="instance"></param> internal static void AttachGroundStation(StaticInstance instance) { GroundStation myfacility = instance.myFacilities[0] as GroundStation; // we use a messure of 1000km from the settings. float antennaPower = myfacility.TrackingShort * 1000000; if (antennaPower == 0f || instance.Group == "KSCUpgrades") { return; } // add CommNet Groundstations if (KerbalKonstructs.instance.enableCommNet) { Log.Normal("Adding Groundstation: " + instance.Group); if (openCNStations.Contains(instance) == false) { KKCommNetHome commNetGroudStation = instance.gameObject.AddComponent <KKCommNetHome>(); commNetGroudStation.nodeName = instance.CelestialBody.name + " " + instance.Group; commNetGroudStation.comm = new CommNode(); var commNode = commNetGroudStation.comm; commNode.antennaTransmit.power = antennaPower; //commNetGroudStation.enabled = true; openCNStations.Add(instance); CommNet.CommNetNetwork.Reset(); } else { Log.UserError("Adding GroundStations should never be here: (instance allready added when open was called)"); } } // Add RemoteTech Groundstation if (KerbalKonstructs.instance.enableRT) { Guid stationID = RemoteTechAddon.GetGroundStationGuid((instance.CelestialBody.name) + " " + instance.Group); if (stationID == Guid.Empty) { double lng, lat, alt; alt = instance.CelestialBody.pqsController.GetSurfaceHeight(instance.RadialPosition) - instance.CelestialBody.pqsController.radius + 15; var objectPos = instance.CelestialBody.transform.InverseTransformPoint(instance.gameObject.transform.position); lng = KKMath.GetLongitudeInDeg(objectPos); lat = KKMath.GetLatitudeInDeg(objectPos); stationID = RemoteTechAddon.AddGroundstation((instance.CelestialBody.name) + " " + instance.Group, lat, lng, alt, instance.CelestialBody); Log.Normal("Got RTStationID: " + stationID); } openRTStations.Add(instance, stationID); RemoteTechAddon.ChangeGroundStationRange(stationID, antennaPower); } }
/// <summary> /// Removes all custom Stations added by KK /// </summary> internal static void ResetAll() { var openRTStationsArray = openRTStations.Values.ToArray(); var openCommNetStations = openCNStations.ToArray(); foreach (var rtStation in openRTStationsArray) { RemoteTechAddon.RemoveGroundStation(rtStation); } openRTStations.Clear(); foreach (var commnetStation in openCommNetStations) { CloseCommNetStation(commnetStation); } openCNStations.Clear(); }
/// <summary> /// Removes all GroundStations from an Static Object. /// </summary> /// <param name="instance"></param> internal static void DetachGroundStation(StaticInstance instance) { if (KerbalKonstructs.instance.enableCommNet) { CloseCommNetStation(instance); } if (KerbalKonstructs.instance.enableRT) { if (openRTStations.ContainsKey(instance)) { openRTStations.Remove(instance); RemoteTechAddon.RemoveGroundStation(openRTStations[instance]); } else { Log.Warning("Trying To close a GroundStation that was never opened by us: " + instance.groupCenterName + ":" + instance.gameObject.name); } } }
/// <summary> /// Removes all GroundStations from an Static Object. /// </summary> /// <param name="instance"></param> internal static void DetachGroundStation(StaticInstance instance) { if (KerbalKonstructs.instance.enableCommNet) { if (openCNStations.Contains(instance)) { Log.Normal("Closing Antenna for " + instance.Group); CommNetHome commNetGroundStation = instance.gameObject.GetComponent <CommNetHome>(); //commNetGroundStation.enabled = false; UnityEngine.Object.Destroy(commNetGroundStation); openCNStations.Remove(instance); } } if (KerbalKonstructs.instance.enableRT) { RemoteTechAddon.RemoveGroundStation(openRTStations[instance]); openRTStations.Remove(instance); } }
private static void AddRemoteTechStation(GroundStation facility) { float antennaPower = facility.TrackingShort * 1000000; StaticInstance instance = facility.staticInstance; Guid stationID = RemoteTechAddon.GetGroundStationGuid((instance.CelestialBody.name) + " " + instance.Group); if (stationID == Guid.Empty) { //double lng, lat, alt; //alt = instance.CelestialBody.pqsController.GetSurfaceHeight(instance.RadialPosition) - instance.CelestialBody.pqsController.radius + 15; //Vector3 objectPos = instance.CelestialBody.transform.InverseTransformPoint(instance.gameObject.transform.position); //lng = KKMath.GetLongitudeInDeg(objectPos); //lat = KKMath.GetLatitudeInDeg(objectPos); //stationID = RemoteTechAddon.AddGroundstation((instance.CelestialBody.name) + " " + instance.Group, lat, lng, alt, instance.CelestialBody); double altitude = instance.CelestialBody.pqsController.GetSurfaceHeight(instance.RadialPosition) - instance.CelestialBody.Radius + 15; stationID = RemoteTechAddon.AddGroundstation((instance.CelestialBody.name) + " " + instance.Group, instance.RefLatitude, instance.RefLongitude, altitude, instance.CelestialBody); Log.Normal("Got RTStationID: " + stationID); } openRTStations.Add(instance, stationID); RemoteTechAddon.ChangeGroundStationRange(stationID, antennaPower); }