public Link(Relay transmitter, Relay relay) { relayA = transmitter; relayB = relay; maxRange = AHUtil.GetRange(relayA.relayPower, relayB.relayPower); }
public void SetScale(double sS) { scaleGreen = 0; scaleYellow = 0; scaleOrange = 0; scaleRed = AHUtil.GetMapScale(maxRange); if (sS >= .25d) { // draw orange circle scaleOrange = AHUtil.GetMapScale(AHUtil.GetDistanceFor(.25d * (1d / sS), maxRange)); } if (sS >= .5d) { // draw yellow circle scaleYellow = AHUtil.GetMapScale(AHUtil.GetDistanceFor(.5d * (1d / sS), maxRange)); } if (sS >= .75d) { // draw green circle scaleGreen = AHUtil.GetMapScale(AHUtil.GetDistanceFor(.75d * (1d / sS), maxRange)); } if (sS == 1d) { scaleGreen = AHUtil.GetMapScale(AHUtil.GetDistanceFor(75, maxRange)); scaleYellow = AHUtil.GetMapScale(AHUtil.GetDistanceFor(50, maxRange)); scaleOrange = AHUtil.GetMapScale(AHUtil.GetDistanceFor(25, maxRange)); } scale = sS; }
public static void ComputeRealSignal(Vessel v) { // yield return new WaitForSeconds (1f); // Debug.Log ("[AH] Computing real signal for vessel : " + v.GetName ()); if (listFlyingVessel.ContainsKey(v.id.ToString())) { // Debug.Log ("[AH] " + v.GetName () + " is in the list"); listFlyingVessel[v.id.ToString()]["connectedTo"] = ""; if (v.Connection.IsConnected) { listFlyingVessel[v.id.ToString()]["realSignal"] = AHUtil.GetRealSignalForTrackingStation(v.Connection.ControlPath).ToString(); if (!v.Connection.ControlPath[0].b.isHome) { listFlyingVessel[v.id.ToString()]["connectedTo"] = v.Connection.ControlPath[0].b.transform.GetComponent <Vessel>().id.ToString(); } } else { listFlyingVessel[v.id.ToString()]["realSignal"] = "0"; } // Debug.Log ("[AH] its real signal = " + listFlyingVessel [v.id.ToString ()] ["realSignal"]); } else { // Debug.Log ("[AH] " + v.GetName () + " is not in the list"); } // Debug.Log ("[AH] (Re-)Computing signal for vessel : " + v.GetName () + " : " + listFlyingVessel [v.id.ToString ()] ["realSignal"]); }
public static void ParseFlyingVessel(bool doRealSignalNow = false) { listFlyingVessel = new Dictionary <string, Dictionary <string, string> >(); for (int i = 0; i < FlightGlobals.Vessels.Count; i++) { var v = FlightGlobals.Vessels[i]; //foreach (Vessel v in FlightGlobals.Vessels) { if ((v.vesselType != VesselType.EVA) && (v.vesselType != VesselType.Flag) && (v.vesselType != VesselType.SpaceObject) && (v.vesselType != VesselType.Unknown) && (v.vesselType != VesselType.Debris) /* && * (v.parts.Count > 0)*/) { string pid = v.id.ToString(); double vesselPower = AHUtil.GetActualVesselPower(v, false, true, false); double vesselRelayPower = AHUtil.GetActualVesselPower(v, true, true, false); listFlyingVessel.Add(pid, new Dictionary <string, string>()); listFlyingVessel[pid].Add("name", v.GetName()); listFlyingVessel[pid].Add("type", v.vesselType.ToString()); listFlyingVessel[pid].Add("powerTotal", vesselPower.ToString()); listFlyingVessel[pid].Add("powerRelay", vesselRelayPower.ToString()); listFlyingVessel[pid].Add("saveDate", ""); listFlyingVessel[pid].Add("realSignal", ""); listFlyingVessel[pid].Add("connectedTo", ""); if (doRealSignalNow) { ComputeRealSignal(v); } } } }
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"); }
public static Dictionary <string, Dictionary <string, string> > GetShipList(bool editorShip, bool flyingShip, bool applyMod = false) { Debug.Log("GetShipList, editorShip: " + editorShip + ", flyingShip: " + flyingShip + ", applyMod: " + applyMod); Dictionary <string, Dictionary <string, string> > returnList = new Dictionary <string, Dictionary <string, string> >(); if (editorShip) { foreach (KeyValuePair <string, Dictionary <string, string> > kvp in listEditorVessel) { returnList.Add(kvp.Key, kvp.Value); if (applyMod) { returnList[kvp.Key]["powerTotal"] = AHUtil.TruePower(Double.Parse(returnList[kvp.Key]["powerTotal"])).ToString("N0"); returnList[kvp.Key]["powerRelay"] = AHUtil.TruePower(Double.Parse(returnList[kvp.Key]["powerRelay"])).ToString("N0"); } } } if (flyingShip) { foreach (KeyValuePair <string, Dictionary <string, string> > kvp in listFlyingVessel) { returnList.Add(kvp.Key, kvp.Value); } } return(returnList); }
public RelayVessel(Vessel v) { vessel = v; relayPower = AHUtil.GetActualVesselPower(v, true); directPower = AHUtil.GetActualVesselPower(v); // isConnected = vessel.Connection.IsConnected; name = vessel.GetName(); }
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); }
public static void UpdateRelayVessels() { potentialRelays = new List <RelayVessel> (); foreach (Vessel v in FlightGlobals.Vessels.FindAll(v => (v.Connection != null))) { double relayPower = AHUtil.GetActualVesselPower(v, true); if (relayPower > 0) { potentialRelays.Add(new RelayVessel(v)); } } }
public static List <Vessel> GetFlyingRelays() { List <Vessel> flyingRelays = new List <Vessel>(); foreach (Vessel v in GetAllFlyingVessel()) { if (AHUtil.GetActualVesselPower(v, true) > 0) { flyingRelays.Add(v); } } return(flyingRelays); }
private void VesselModified(Vessel v = null) { double actualPower = AHUtil.GetActualVesselPower(FlightGlobals.ActiveVessel); if (actualPower != vesselPower) { hasStarted = false; StopAllCoroutines(); DestroyMarkers(); timeAtStart = Time.time; StartCoroutine("StartSecond"); } }
public static void TargetWindowShipFlight(int id) { GUIStyle guiStyleLabel; GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label")); GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label")); guiStyleLabelBold.fontStyle = FontStyle.Bold; // Close Button if (GUI.Button(new Rect(AHEditor.rectTargetShipFlightWindow.size.x - 20, 2, 18, 18), "X")) { AHEditor.CloseTargetShipFlightWindow(); } GUILayout.BeginVertical(); scrollVectorFlight = GUILayout.BeginScrollView(scrollVectorFlight); foreach (Dictionary <string, string> vesselInfo in AHEditor.guiExternListShipFlight) { if (vesselInfo ["type"] != "Relay") { continue; } GUILayout.BeginHorizontal(); if (GUILayout.Button(/*Select*/ Localizer.Format("#autoLOC_AH_0022"), GUILayout.Width(60f))) { AHEditor.SetTarget(vesselInfo ["pid"]); } if (AHEditor.targetPid == vesselInfo ["pid"]) { guiStyleLabel = guiStyleLabelBold; } else { guiStyleLabel = guiStyleLabelNorm; } GUILayout.Label( "(" + AHUtil.TruePower(Double.Parse(vesselInfo ["powerRelay"])).ToString("N0") + ") " + vesselInfo ["name"], guiStyleLabel); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); }
private void SetPerPlanetList() { signalMinDirect = new List <double> (); signalMaxDirect = new List <double> (); signalMinRelay = new List <double> (); signalMaxRelay = new List <double> (); foreach (MyTuple planet in AHUtil.signalPlanetList) { signalMinDirect.Add(AHUtil.GetSignalStrength(directBetterRange, planet.item2)); signalMaxDirect.Add(AHUtil.GetSignalStrength(directBetterRange, planet.item3)); signalMinRelay.Add(AHUtil.GetSignalStrength(relayBetterRange, planet.item2)); signalMaxRelay.Add(AHUtil.GetSignalStrength(relayBetterRange, planet.item3)); } }
private void MainWindow(int id) { GUILayout.BeginVertical(); string transmitterName = ""; if (targetPid != "" && listShipTransmitter.ContainsKey(targetPid)) { transmitterName = listShipTransmitter [targetPid] ["name"]; } GUILayout.Label(Localizer.Format("#autoLOC_AH_0050", new string[] { transmitterName })); GUILayout.Label(Localizer.Format("#autoLOC_AH_0051", new string[] { AHUtil.FormatCircleSelect(circleTypeSelected) })); GUILayout.Space(3f); if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0045"))) { circleTypeSelected = GUICircleSelection.ACTIVE; ShowCircles(); } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0046"))) { circleTypeSelected = GUICircleSelection.DSN; ShowCircles(); } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0048"))) { circleTypeSelected = GUICircleSelection.RELAY; ShowCircles(); } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0047"))) { circleTypeSelected = GUICircleSelection.DSN_AND_RELAY; ShowCircles(); } GUILayout.Space(10f); if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0044"))) { editorShipWindowOn = !editorShipWindowOn; } GUILayout.EndVertical(); GUI.DragWindow(); }
public static void UpdateTargetPartPower() { List <ModuleDataTransmitter> antennas = new List <ModuleDataTransmitter> (); double bestAntenna = 0; foreach (ModuleDataTransmitter antenna in AHShipList.listAntennaPart) { if (!listAntennaPart.ContainsKey(antenna)) { continue; } if (listAntennaPart [antenna] <= 0) { listAntennaPart [antenna] = 0; continue; } if (antenna.antennaPower > bestAntenna) { bestAntenna = antenna.antennaPower; } for (int i = 0; i < listAntennaPart [antenna]; i++) { antennas.Add(antenna); } } double combPower = AHUtil.GetVesselPower(antennas, true); bestAntenna = AHUtil.TruePower(bestAntenna); if (combPower > bestAntenna) { targetPartPower = combPower; } else { targetPartPower = bestAntenna; } SetTargetAsPart(); }
public void Start() { if (!HighLogic.CurrentGame.Parameters.CustomParams <AntennaHelperSettings> ().enableInEditor) { Destroy(this); return; } if (HighLogic.CurrentGame.Mode == Game.Modes.MISSION_BUILDER) { if (Component.FindObjectOfType <AHUtil> () == null) { AHUtil util = gameObject.AddComponent <AHUtil> (); util.Start(); } AHShipList.UpdateLoadedGame(); AHShipList.ParseFlyingVessel(); } instance = this; trackingStationLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation); targetPower = GameVariables.Instance.GetDSNRange(trackingStationLevel); targetName = Localizer.Format("#autoLOC_AH_0015") + " " + (int)(trackingStationLevel * 2 + 1); GetShipList(); GetAntennaPartList(); CreateAntennaList(); DoTheMath(); GameEvents.onGUIApplicationLauncherReady.Add(AddToolbarButton); GameEvents.onGUIApplicationLauncherDestroyed.Add(RemoveToolbarButton); GameEvents.onEditorLoad.Add(VesselLoad); GameEvents.onEditorPartEvent.Add(PartEvent); GameEvents.onEditorPodPicked.Add(PodPicked); GameEvents.onEditorPodDeleted.Add(PodDeleted); GameEvents.onGameSceneSwitchRequested.Add(QuitEditor); }
private void SetPerPlanetList() { signalMinDirect = new List <double> (); signalMaxDirect = new List <double> (); signalMinRelay = new List <double> (); signalMaxRelay = new List <double> (); //for (int p = AHUtil.signalPlanetList.Count - 1; p >= 0; p--) for (int p = 0; p < AHUtil.signalPlanetList.Count; p++) { var planet = AHUtil.signalPlanetList[p]; //foreach (MyTuple planet in AHUtil.signalPlanetList) { signalMinDirect.Add(AHUtil.GetSignalStrength(directBetterRange, planet.item2)); signalMaxDirect.Add(AHUtil.GetSignalStrength(directBetterRange, planet.item3)); signalMinRelay.Add(AHUtil.GetSignalStrength(relayBetterRange, planet.item2)); signalMaxRelay.Add(AHUtil.GetSignalStrength(relayBetterRange, planet.item3)); } }
public static void SetTarget(string pid) { Dictionary <string, string> targetDict; if (externListShipEditor.ContainsKey(pid)) { targetDict = externListShipEditor [pid]; targetType = AHEditorTargetType.EDITOR; } else { targetDict = externListShipFlight [pid]; targetType = AHEditorTargetType.FLIGHT; } targetPower = AHUtil.TruePower(Double.Parse(targetDict ["powerRelay"])); targetName = Localizer.Format("#autoLOC_AH_0039") + " : " + targetDict ["name"]; targetPid = pid; instance.DoTheMath(); }
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"); }
public static void ComputeAllSignal() { Debug.Log("[AH] Computing real signal for all vessels"); foreach (Vessel v in FlightGlobals.Vessels) { if (listFlyingVessel.ContainsKey(v.id.ToString())) { listFlyingVessel[v.id.ToString()]["connectedTo"] = ""; listFlyingVessel[v.id.ToString()]["realSignal"] = "0"; if (v.Connection.IsConnected) { listFlyingVessel[v.id.ToString()]["realSignal"] = AHUtil.GetRealSignalForTrackingStation(v.Connection.ControlPath).ToString(); if (!v.Connection.ControlPath[0].b.isHome) { listFlyingVessel[v.id.ToString()]["connectedTo"] = v.Connection.ControlPath[0].b.transform.GetComponent <Vessel>().id.ToString(); } } Debug.Log("[AH] " + v.GetName() + " is connected to " + listFlyingVessel[v.id.ToString()]["connectedTo"] + " with a signal of " + listFlyingVessel[v.id.ToString()]["realSignal"]); } } }
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; } }
static Relay() { home = FlightGlobals.GetHomeBody(); _dsn = new Relay(); _dsn.relayPower = GameVariables.Instance.GetDSNRange (ScenarioUpgradeableFacilities.GetFacilityLevel (SpaceCenterFacility.TrackingStation)); _dsn.directPower = _dsn.relayPower; _dsn.isDSN = true; _dsn.distanceOffset = home.Radius; _dsn.name = /*"DSN"*/ Localizer.Format("#autoLOC_AH_0014"); potentialRelays = new List <RelayVessel> (); foreach (Vessel v in FlightGlobals.Vessels.FindAll(v => (v.Connection != null) && (v != FlightGlobals.ActiveVessel))) { double relayPower = AHUtil.GetActualVesselPower(v, true); if (relayPower > 0) { potentialRelays.Add(new RelayVessel(v)); } } // Debug.Log ("[AH] dsn distance offset : " + _dsn.distanceOffset); // Debug.Log ("[AH] static dsn relay constructed"); }
public static void TargetWindowPart(int id) { GUIStyle guiStyleLabel; GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label")); GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label")); guiStyleLabelBold.fontStyle = FontStyle.Bold; GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button")); guiStyleButtonBold.fontStyle = FontStyle.Bold; // Close Button if (GUI.Button(new Rect(AHEditor.rectTargetPartWindow.size.x - 20, 2, 18, 18), "X")) { AHEditor.CloseTargetPartWindow(); } GUILayout.BeginVertical(); scrollVectorPart = GUILayout.BeginScrollView(scrollVectorPart); foreach (ModuleDataTransmitter antenna in AHShipList.listAntennaPart) { if (antenna.antennaType != AntennaType.RELAY) { continue; } if (AHEditor.listAntennaPart [antenna] > 0) { guiStyleLabel = guiStyleLabelBold; } else { guiStyleLabel = guiStyleLabelNorm; } GUILayout.BeginHorizontal(); GUILayout.Label(AHEditor.listAntennaPart [antenna].ToString(), guiStyleLabel, GUILayout.Width(15f)); if (GUILayout.Button("+", guiStyleButtonBold, GUILayout.Width(20f))) { AHEditor.listAntennaPart [antenna]++; AHEditor.UpdateTargetPartPower(); } if (GUILayout.Button("-", guiStyleButtonBold, GUILayout.Width(20f))) { AHEditor.listAntennaPart [antenna]--; AHEditor.UpdateTargetPartPower(); } GUILayout.Label( "(" + AHUtil.TruePower(antenna.antennaPower).ToString("N0") + ") " + antenna.part.partInfo.title, guiStyleLabel); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Space(10f); GUILayout.BeginHorizontal(); GUILayout.Label(/*Power*/ Localizer.Format("#autoLOC_AH_0009") + " : " + AHEditor.targetPartPower.ToString("N0")); if (GUILayout.Button(/*Set As Target*/ Localizer.Format("#autoLOC_AH_0023"))) { AHEditor.SetTargetAsPart(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
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 static void CalcCustomDistance() { signalCustomDistanceDirect = AHUtil.GetSignalStrength(directBetterRange, Double.Parse(customDistance)); signalCustomDistanceRelay = AHUtil.GetSignalStrength(relayBetterRange, Double.Parse(customDistance)); }
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); }
private void EditorShipListWindow(int id) { GUIStyle guiStyleLabel; GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label")); GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label")); guiStyleLabelBold.fontStyle = FontStyle.Bold; GUIStyle guiStyleButton; GUIStyle guiStyleButtonNorm = new GUIStyle(GUI.skin.GetStyle("Button")); GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button")); guiStyleButtonBold.fontStyle = FontStyle.Bold; // Close Button if (GUI.Button(new Rect(rectEditorShipWindow.size.x - 22, 2, 20, 20), "X")) { editorShipWindowOn = false; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (editorShipVab) { guiStyleButton = guiStyleButtonBold; } else { guiStyleButton = guiStyleButtonNorm; } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0019"), guiStyleButton)) { editorShipVab = true; } if (editorShipVab) { guiStyleButton = guiStyleButtonNorm; } else { guiStyleButton = guiStyleButtonBold; } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0020"), guiStyleButton)) { editorShipVab = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(35f); if (editorShipRelay) { guiStyleButton = guiStyleButtonNorm; } else { guiStyleButton = guiStyleButtonBold; } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0021"), guiStyleButton)) { editorShipRelay = false; } if (editorShipRelay) { guiStyleButton = guiStyleButtonBold; } else { guiStyleButton = guiStyleButtonNorm; } if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0003"), guiStyleButton)) { editorShipRelay = true; } GUILayout.Space(35f); GUILayout.EndHorizontal(); if (editorShipVab) { if (editorShipRelay) { guiListEditorShipDisplay = guiListEditorShipVabRelay; } else { guiListEditorShipDisplay = guiListEditorShipVabAll; } } else { if (editorShipRelay) { guiListEditorShipDisplay = guiListEditorShipSphRelay; } else { guiListEditorShipDisplay = guiListEditorShipSphAll; } } scrollerEditorShipWindow = GUILayout.BeginScrollView(scrollerEditorShipWindow); foreach (Dictionary <string, string> vesselInfo in guiListEditorShipDisplay) { GUILayout.BeginHorizontal(); if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0022"), GUILayout.Width(60f))) { targetPid = vesselInfo ["pid"]; ShowCircles(); } if (targetPid == vesselInfo ["pid"]) { guiStyleLabel = guiStyleLabelBold; } else { guiStyleLabel = guiStyleLabelNorm; } string power; if (editorShipRelay) { power = AHUtil.TruePower(Double.Parse(vesselInfo ["powerRelay"])).ToString(); } else { power = AHUtil.TruePower(Double.Parse(vesselInfo ["powerTotal"])).ToString(); } GUILayout.Label("(" + power + ") " + vesselInfo ["name"], guiStyleLabel); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUI.DragWindow(); }
private double _signalStrength() { return(AHUtil.GetSignalStrength(maxRange, distance)); }
public static void TargetWindowShipEditor(int id) { GUIStyle guiStyleLabel; GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label")); GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label")); guiStyleLabelBold.fontStyle = FontStyle.Bold; GUIStyle guiStyleButton; GUIStyle guiStyleButtonNorm = new GUIStyle(GUI.skin.GetStyle("Button")); GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button")); guiStyleButtonBold.fontStyle = FontStyle.Bold; GUIStyle guiStyleButtonRed = new GUIStyle(GUI.skin.GetStyle("Button")); guiStyleButtonRed.fontStyle = FontStyle.Bold; guiStyleButtonRed.normal.textColor = Color.red; guiStyleButtonRed.hover.textColor = Color.red; // Close Button if (GUI.Button(new Rect(AHEditor.rectTargetShipEditorWindow.size.x - 20, 2, 18, 18), "X")) { AHEditor.CloseTargetShipEditorWindow(); } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); if (vab) { guiStyleButton = guiStyleButtonBold; } else { guiStyleButton = guiStyleButtonNorm; } if (GUILayout.Button(/*VAB*/ Localizer.Format("#autoLOC_AH_0019"), guiStyleButton)) { vab = true; } if (vab) { guiStyleButton = guiStyleButtonNorm; } else { guiStyleButton = guiStyleButtonBold; } if (GUILayout.Button(/*SPH*/ Localizer.Format("#autoLOC_AH_0020"), guiStyleButton)) { vab = false; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(35f); if (relay) { guiStyleButton = guiStyleButtonNorm; } else { guiStyleButton = guiStyleButtonBold; } if (GUILayout.Button(/*All*/ Localizer.Format("#autoLOC_AH_0021"), guiStyleButton)) { relay = false; } if (relay) { guiStyleButton = guiStyleButtonBold; } else { guiStyleButton = guiStyleButtonNorm; } if (GUILayout.Button(/*Relay*/ Localizer.Format("#autoLOC_AH_0003"), guiStyleButton)) { relay = true; } GUILayout.Space(35f); GUILayout.EndHorizontal(); scrollVectorEditor = GUILayout.BeginScrollView(scrollVectorEditor); if (vab) { if (relay) { displayList = AHEditor.guiExternListShipEditorVabRelay; } else { displayList = AHEditor.guiExternListShipEditorVabAll; } } else { if (relay) { displayList = AHEditor.guiExternListShipEditorSphRelay; } else { displayList = AHEditor.guiExternListShipEditorSphAll; } } foreach (Dictionary <string, string> vesselInfo in displayList) { if ((vab && (vesselInfo ["type"] != "VAB")) || (!vab && (vesselInfo ["type"] != "SPH"))) { continue; } GUILayout.BeginHorizontal(); if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0022"), GUILayout.Width(60f))) { AHEditor.SetTarget(vesselInfo ["pid"]); } if (AHEditor.targetPid == vesselInfo ["pid"]) { guiStyleLabel = guiStyleLabelBold; } else { guiStyleLabel = guiStyleLabelNorm; } GUILayout.Label( "(" + AHUtil.TruePower(Double.Parse(vesselInfo ["powerRelay"])).ToString("N0") + ") " + vesselInfo ["name"], guiStyleLabel); if (GUILayout.Button("X", guiStyleButtonRed, GUILayout.Width(22f))) { AHEditor.RemoveShipFromShipList(vesselInfo ["pid"]); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.EndVertical(); }