public Link(Relay transmitter, Relay relay) { relayA = transmitter; relayB = relay; maxRange = AHUtil.GetRange(relayA.relayPower, relayB.relayPower); }
private IEnumerator StartSecond() { while (Time.time < timeAtStart + HighLogic.CurrentGame.Parameters.CustomParams <AntennaHelperSettings> ().startDelay /*1f*/) { yield return(timers [0]); } vessel = FlightGlobals.ActiveVessel; // possible fix for AH not always working, see forum around 16.05.2018 if (vessel == null) { Debug.Log("[AH] active vessel is null, shouldn't happen..."); ReStartSecond(); } vesselPower = AHUtil.GetActualVesselPower(vessel); vesselPowerRelay = AHUtil.GetActualVesselPower(vessel, true); dsnRange = AHUtil.GetRange(vesselPower, dsnPower); SetDeployableAntennaList(); SetRelayList(); SetActiveConnect(); yield return(SetMarkerList()); AddToolbarButton(); StartCoroutine("UpdateCommNet"); }
private AHMapMarker CreateMapMarkerRelay(Vessel relay) { double realSignal = relays [relay].endRelaySignalStrength; //AHUtil.GetREALSignal (relay.Connection.ControlPath); double range = AHUtil.GetDistanceAt0 (AHUtil.GetRange(vesselPower, relays [relay].endRelayPower)); AHMapMarker marker = new GameObject().AddComponent <AHMapMarker> (); marker.SetUp(range, vessel, relay.mapObject.trf, false, realSignal); return(marker); }
private IEnumerator StartSecond() { while (Time.time < timeAtStart + 1f) { yield return(timers [0]); } vessel = FlightGlobals.ActiveVessel; vesselPower = AHUtil.GetActualVesselPower(vessel); vesselPowerRelay = AHUtil.GetActualVesselPower(vessel, true); dsnRange = AHUtil.GetRange(vesselPower, dsnPower); SetDeployableAntennaList(); SetRelayList(); SetActiveConnect(); yield return(SetMarkerList()); AddToolbarButton(); StartCoroutine("UpdateCommNet"); }
private void SetActiveConnect() { if (vessel.Connection == null || !vessel.Connection.IsConnected) { connectedToDSN = false; connectedTo = null; targetPower = 0; targetMaxRange = 0; targetDistance = 0; sSToTarget = 0; sSTargetToDSN = 0; sSToDSN = 0; } else if (vessel.Connection.ControlPath [0].b.isHome) { connectedToDSN = true; connectedTo = null; targetPower = dsnPower; targetMaxRange = dsnRange; targetDistance = Vector3.Distance(vessel.GetWorldPos3D(), Relay.DSN.position) - Relay.DSN.distanceOffset; targetDistance = (targetDistance < 0) ? 0 : targetDistance; sSToTarget = AHUtil.GetSignalStrength(targetMaxRange, targetDistance); sSTargetToDSN = 0; sSToDSN = sSToTarget; } else { connectedToDSN = false; connectedTo = vessel.Connection.ControlPath [0].b.transform.GetComponent <Vessel> (); targetPower = relays [connectedTo].linkList [0].relayA.relayPower; targetMaxRange = AHUtil.GetRange(vesselPower, relays [connectedTo].endRelayPower); targetDistance = Vector3.Distance(vessel.vesselTransform.position, connectedTo.vesselTransform.position); sSToTarget = AHUtil.GetSignalStrength(targetMaxRange, targetDistance); sSTargetToDSN = relays [connectedTo].endRelaySignalStrength; sSToDSN = sSToTarget * sSTargetToDSN; } }
private void CreateMarkers() { listMarkers = new Dictionary <string, Dictionary <string, List <GameObject> > > (); foreach (KeyValuePair <string, Dictionary <string, string> > vesselPairInfo in listShipTransmitter) { // Debug.Log ("[AH] creating marker for vessel : " + vesselPairInfo.Value ["name"]); listMarkers.Add(vesselPairInfo.Key, new Dictionary <string, List <GameObject> > ()); double vesselPower, maxRange, realSignal; Vessel transmiter; bool editorShip; bool isHome; Transform relay; AHMapMarker marker; vesselPower = AHUtil.TruePower(Double.Parse(vesselPairInfo.Value ["powerTotal"])); if ((vesselPairInfo.Value ["type"] == "VAB") || (vesselPairInfo.Value ["type"] == "SPH")) { transmiter = null; editorShip = true; } else { transmiter = FlightGlobals.Vessels.Find(v => v.id.ToString() == vesselPairInfo.Key); editorShip = false; } // Debug.Log ("[AH] vessel power computed"); // Active Connection : if (vesselPairInfo.Value ["connectedTo"] == "") { // the active connection is to the DSN or isn't set maxRange = AHUtil.GetRange(vesselPower, dsnPower); realSignal = 1d; isHome = true; relay = Planetarium.fetch.Home.MapObject.trf; } else { // active connection going trough a relay maxRange = AHUtil.GetRange(vesselPower, AHUtil.TruePower(Double.Parse(listShipRelay [vesselPairInfo.Value ["connectedTo"]] ["powerRelay"]))); realSignal = Double.Parse(listShipRelay [vesselPairInfo.Value ["connectedTo"]] ["realSignal"]); isHome = false; relay = FlightGlobals.Vessels.Find(v => v.id.ToString() == vesselPairInfo.Value ["connectedTo"]).mapObject.trf; } maxRange = AHUtil.GetDistanceAt0(maxRange); listMarkers [vesselPairInfo.Key].Add("ACTIVE", new List <GameObject> ()); listMarkers [vesselPairInfo.Key] ["ACTIVE"].Add(new GameObject()); marker = listMarkers [vesselPairInfo.Key] ["ACTIVE"] [0].AddComponent <AHMapMarker> (); marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip); // Debug.Log ("[AH] active connection done"); // DSN Connection : maxRange = AHUtil.GetRange(vesselPower, dsnPower); maxRange = AHUtil.GetDistanceAt0(maxRange); realSignal = 1d; isHome = true; relay = Planetarium.fetch.Home.MapObject.trf; listMarkers [vesselPairInfo.Key].Add("DSN", new List <GameObject> ()); listMarkers [vesselPairInfo.Key] ["DSN"].Add(new GameObject()); marker = listMarkers [vesselPairInfo.Key] ["DSN"] [0].AddComponent <AHMapMarker> (); marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip); // Debug.Log ("[AH] dsn connection done"); // Relay(s) Connection : List <GameObject> listRelayMarkers = new List <GameObject> (); foreach (KeyValuePair <string, Dictionary <string, string> > relayPairInfo in listShipRelay) { if (relayPairInfo.Key == vesselPairInfo.Key) { continue; } maxRange = AHUtil.GetRange(vesselPower, AHUtil.TruePower(Double.Parse(relayPairInfo.Value ["powerRelay"]))); maxRange = AHUtil.GetDistanceAt0(maxRange); realSignal = Double.Parse(relayPairInfo.Value ["realSignal"]); isHome = false; relay = FlightGlobals.Vessels.Find(v => v.id.ToString() == relayPairInfo.Key).mapObject.trf; listRelayMarkers.Add(new GameObject()); marker = listRelayMarkers [listRelayMarkers.Count - 1].AddComponent <AHMapMarker> (); marker.SetUp(maxRange, transmiter, relay, isHome, realSignal, editorShip); } listMarkers [vesselPairInfo.Key].Add("RELAY", listRelayMarkers); // Debug.Log ("[AH] relays connections done"); } }
public void DoTheMath() { // Direct antenna (not-relay) nbDirectAntenna = directAntennaList.Count; nbDirectCombAntenna = directCombAntennaList.Count; // Direct combinable : if (nbDirectCombAntenna > 0) { rawDirectCombPower = AHUtil.GetVesselPower(directCombAntennaList, false); directCombPower = AHUtil.TruePower(rawDirectCombPower); //AHUtil.GetVesselPower (directCombAntennaList); directCombRange = AHUtil.GetRange(directCombPower, targetPower); } else { rawDirectCombPower = 0; directCombPower = 0; directCombRange = 0; } // Direct straight : if (nbDirectAntenna > 0) { ModuleDataTransmitter bigDirect = null; foreach (ModuleDataTransmitter antenna in directAntennaList) { if (bigDirect == null || bigDirect.antennaPower < antenna.antennaPower) { bigDirect = antenna; } } rawDirectPower = bigDirect.antennaPower; directPower = AHUtil.TruePower(rawDirectPower); //AHUtil.TruePower (bigDirect.antennaPower); directRange = AHUtil.GetRange(directPower, targetPower); directAntennaName = bigDirect.part.partInfo.title; } else { rawDirectPower = 0; directPower = 0; directRange = 0; directAntennaName = "No Antenna"; } // Relay antenna : nbRelayAntenna = relayAntennaList.Count; nbRelayCombAntenna = relayCombAntennaList.Count; // Relay combinable : if (nbRelayCombAntenna > 0) { rawRelayCombPower = AHUtil.GetVesselPower(relayCombAntennaList, false); relayCombPower = AHUtil.TruePower(rawRelayCombPower); //AHUtil.GetVesselPower (relayCombAntennaList); relayCombRange = AHUtil.GetRange(relayCombPower, targetPower); } else { rawRelayCombPower = 0; relayCombPower = 0; relayCombRange = 0; } // Relay straight : if (nbRelayAntenna > 0) { ModuleDataTransmitter bigRelay = null; foreach (ModuleDataTransmitter antenna in relayAntennaList) { if (bigRelay == null || bigRelay.antennaPower < antenna.antennaPower) { bigRelay = antenna; } } rawRelayPower = bigRelay.antennaPower; relayPower = AHUtil.TruePower(rawRelayPower); //AHUtil.TruePower (bigRelay.antennaPower); relayRange = AHUtil.GetRange(relayPower, targetPower); relayAntennaName = bigRelay.part.partInfo.title; } else { rawRelayPower = 0; relayPower = 0; relayRange = 0; relayAntennaName = "No Antenna"; } FetchBetterAntennas(); FetchAntennaStatus(); SetPerPlanetList(); directDistanceAt100 = AHUtil.GetDistanceAt100(directBetterRange); directDistanceAt75 = AHUtil.GetDistanceAt75(directBetterRange); directDistanceAt50 = AHUtil.GetDistanceAt50(directBetterRange); directDistanceAt25 = AHUtil.GetDistanceAt25(directBetterRange); relayDistanceAt100 = AHUtil.GetDistanceAt100(relayBetterRange); relayDistanceAt75 = AHUtil.GetDistanceAt75(relayBetterRange); relayDistanceAt50 = AHUtil.GetDistanceAt50(relayBetterRange); relayDistanceAt25 = AHUtil.GetDistanceAt25(relayBetterRange); }