private static void AddCommNetStation(GroundStation facility) { StaticInstance instance = facility.staticInstance; float antennaPower = facility.TrackingShort * 1000000; Log.Normal("Adding Groundstation: " + instance.Group); if (openCNStations.Contains(instance) == false) { KKCommNetHome commNetGroudStation = instance.gameObject.AddComponent <KKCommNetHome>(); commNetGroudStation.nodeName = instance.CelestialBody.name + ": " + instance.Group; #if !KSP12 commNetGroudStation.nodeName = instance.gameObject.name; commNetGroudStation.displaynodeName = instance.CelestialBody.name + ": " + instance.Group; #endif // force them to be enabled all the time //commNetGroudStation.isKSC = true; commNetGroudStation.comm = new CommNode(); commNetGroudStation.comm.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)"); } }
/// <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> /// 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.Where(fac => fac.facType == KKFacilityType.GroundStation).First() as GroundStation; // we use a messure of 1000km from the settings. if (myfacility.TrackingShort == 0f || instance.Group == "KSCUpgrades") { return; } // add CommNet Groundstations if (KerbalKonstructs.instance.enableCommNet) { AddCommNetStation(myfacility); } // Add RemoteTech Groundstation if (KerbalKonstructs.instance.enableRT) { AddRemoteTechStation(myfacility); } }
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); }