public override string GetInfo() { var info = new StringBuilder(); if (ShowEditor_OmniRange && Mode1OmniRange > 0) { info.AppendFormat("Omni range: {0} / {1}", RTUtil.FormatSI(Mode0OmniRange * RangeMultiplier, "m"), RTUtil.FormatSI(Mode1OmniRange * RangeMultiplier, "m")).AppendLine(); } if (ShowEditor_DishRange && Mode1DishRange > 0) { info.AppendFormat("Dish range: {0} / {1}", RTUtil.FormatSI(Mode0DishRange * RangeMultiplier, "m"), RTUtil.FormatSI(Mode1DishRange * RangeMultiplier, "m")).AppendLine(); } if (ShowEditor_EnergyReq && EnergyCost > 0) { info.AppendFormat("Energy req.: {0}", RTUtil.FormatConsumption(EnergyCost * ConsumptionMultiplier)).AppendLine(); } if (ShowEditor_DishAngle && CanTarget) { info.AppendFormat("Cone angle: {0} degrees", DishAngle.ToString("F2")).AppendLine(); } if (IsRTActive) { info.AppendLine("Activated by default"); } if (MaxQ > 0) { info.AppendLine("Snaps under high dynamic pressure"); } return(info.ToString().TrimEnd(Environment.NewLine.ToCharArray())); }
private void UpdateContext() { GUI_OmniRange = RTUtil.FormatSI(Omni, "m"); GUI_DishRange = RTUtil.FormatSI(Dish, "m"); GUI_EnergyReq = RTUtil.FormatConsumption(Consumption); Events["EventTarget"].guiName = RTUtil.TargetName(Target); }
public override string GetInfo() { var info = new StringBuilder(); if (ShowEditor_OmniRange && Unlocked) { info.AppendFormat("Integrated Omni: {1} always-on", RTUtil.FormatSI(OmniRange, "m"), RTUtil.FormatSI(OmniRange, "m")); } return(info.ToString()); }
public void GetDescription(StringBuilder s) { switch (mode) { case DriveMode.Coord: s.Append("Drive to: "); s.Append(new Vector2(target, target2).ToString("0.000")); s.Append(" @ "); s.Append(RTUtil.FormatSI(Math.Abs(speed), "m/s")); break; case DriveMode.Distance: s.Append("Drive: "); s.Append(RTUtil.FormatSI(target, "m")); if (speed > 0) { s.Append(" forwards @"); } else { s.Append(" backwards @"); } s.Append(RTUtil.FormatSI(Math.Abs(speed), "m/s")); break; case DriveMode.Turn: s.Append("Turn: "); s.Append(target.ToString("0.0")); if (steering < 0) { s.Append("° right @"); } else { s.Append("° left @"); } s.Append(Math.Abs(steering).ToString("P")); s.Append(" steering"); break; case DriveMode.DistanceHeading: s.Append("Drive: "); s.Append(RTUtil.FormatSI(target, "m")); s.Append(", Hdg: "); s.Append(target2.ToString("0")); s.Append("° @ "); s.Append(RTUtil.FormatSI(Math.Abs(speed), "m/s")); break; case DriveMode.Off: s.Append("Turn rover computer off"); break; } }
public override void OnStart(StartState state) { if (RTCore.Instance != null) { GameEvents.onVesselWasModified.Add(OnVesselModified); GameEvents.onPartUndock.Add(OnPartUndock); mRegisteredId = vessel.id; RTCore.Instance.Antennas.Register(vessel.id, this); SetState(true); GUI_OmniRange = RTUtil.FormatSI(Omni, "m"); } }
public override string GetInfo() { var info = new StringBuilder(); if (ShowEditor_Class && Mode0OmniRange + Mode1OmniRange + Mode0DishRange + Mode1DishRange > 0) { info.AppendLine("Class: " + RTUtil.FormatClass(Math.Max(Math.Max(Mode0DishRange, Mode1DishRange), Math.Max(Mode0OmniRange, Mode1OmniRange)))); } if (ShowEditor_OmniRange && Mode1OmniRange > 0) { info.Append("Omni range: "); info.Append(RTUtil.FormatSI(Mode0OmniRange, "m")); info.Append(" / "); info.AppendLine(RTUtil.FormatSI(Mode1OmniRange, "m")); } if (ShowEditor_DishRange && Mode1DishRange > 0) { info.Append("Dish range: "); info.Append(RTUtil.FormatSI(Mode0DishRange, "m")); info.Append(" / "); info.AppendLine(RTUtil.FormatSI(Mode1DishRange, "m")); } if (ShowEditor_EnergyReq && EnergyCost > 0) { info.Append("Energy req.: "); info.Append(RTUtil.FormatConsumption(EnergyCost)); } if (ShowEditor_AllEnergyReq) { float AllEnergyReq = 0; foreach (ModuleRTAntenna m in part.Modules.OfType <ModuleRTAntenna>()) { AllEnergyReq += m.EnergyCost; } if (AllEnergyReq > 0) { info.Append("Energy req.: "); info.Append(RTUtil.FormatConsumption(AllEnergyReq)); } } return(info.ToString().TrimEnd('\n')); }
public override string GetInfo() { var info = new StringBuilder(); if (ShowEditor_Class) { info.AppendFormat("Class: {0}", RTUtil.FormatClass(Math.Max(Math.Max(Mode0DishRange, Mode1DishRange), Math.Max(Mode0OmniRange, Mode1OmniRange)))).AppendLine(); } if (ShowEditor_OmniRange && Mode1OmniRange > 0) { info.AppendFormat("Omni range: {0} / {1}", RTUtil.FormatSI(Mode0OmniRange, "m"), RTUtil.FormatSI(Mode1OmniRange, "m")).AppendLine(); } if (ShowEditor_DishRange && Mode1DishRange > 0) { info.AppendFormat("Dish range: {0} / {1}", RTUtil.FormatSI(Mode0DishRange, "m"), RTUtil.FormatSI(Mode1DishRange, "m")).AppendLine(); } if (ShowEditor_EnergyReq && EnergyCost > 0) { info.AppendFormat("Energy req.: {0}", RTUtil.FormatConsumption(EnergyCost)).AppendLine(); } return(info.ToString().TrimEnd(Environment.NewLine.ToCharArray())); }
public void OnGUI() { if (Event.current.type == EventType.Repaint && MapView.MapIsEnabled) { foreach (ISatellite s in RTCore.Instance.Satellites.FindCommandStations().Concat(RTCore.Instance.Network.GroundStations.Values)) { bool showOnMapview = true; var worldPos = ScaledSpace.LocalToScaledSpace(s.Position); if (MapView.MapCamera.transform.InverseTransformPoint(worldPos).z < 0f) { continue; } Vector3 pos = PlanetariumCamera.Camera.WorldToScreenPoint(worldPos); var screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16); // Hide the current ISatellite if it is behind its body if (RTSettings.Instance.HideGroundStationsBehindBody && IsOccluded(s.Position, s.Body)) { showOnMapview = false; } if (RTSettings.Instance.HideGroundStationsOnDistance && !IsOccluded(s.Position, s.Body) && this.IsCamDistanceToWide(s.Position)) { showOnMapview = false; } // orbiting remote stations are always shown if (s.isVessel && !s.parentVessel.Landed) { showOnMapview = true; } if (showOnMapview) { Color pushColor = GUI.color; // tint the white mark.png into the defined color GUI.color = s.MarkColor; // draw the mark.png GUI.DrawTexture(screenRect, mTexMark, ScaleMode.ScaleToFit, true); GUI.color = pushColor; // Show Mouse over informations to the ground station if (RTSettings.Instance.ShowMouseOverInfoGroundStations && s is MissionControlSatellite && screenRect.ContainsMouse()) { Rect headline = screenRect; Vector2 nameDim = this.smallStationHead.CalcSize(new GUIContent(s.Name)); headline.x -= nameDim.x + 10; headline.y -= 3; headline.width = nameDim.x; headline.height = 14; // draw headline of the station GUI.Label(headline, s.Name, this.smallStationHead); // loop antennas String antennaRanges = String.Empty; foreach (var antenna in s.Antennas) { if (antenna.Omni > 0) { antennaRanges += "Omni: " + RTUtil.FormatSI(antenna.Omni, "m") + Environment.NewLine; } if (antenna.Dish > 0) { antennaRanges += "Dish: " + RTUtil.FormatSI(antenna.Dish, "m") + Environment.NewLine; } } if (!antennaRanges.Equals(String.Empty)) { Rect antennas = screenRect; GUIContent content = new GUIContent(antennaRanges); Vector2 antennaDim = this.smallStationText.CalcSize(content); float maxHeight = this.smallStationText.CalcHeight(content, antennaDim.x); antennas.y += headline.height - 3; antennas.x -= antennaDim.x + 10; antennas.width = antennaDim.x; antennas.height = maxHeight; // draw antenna infos of the station GUI.Label(antennas, antennaRanges, this.smallStationText); } } } } } }
/// <summary>Tests whether an antenna can connect to a target</summary> /// <returns>The range to the target, or a diagnostic error message. Returns the /// empty string if target is invalid.</returns> /// <param name="antenna">The antenna attempting to make a connection.</param> /// <param name="target">The Guid to which it is trying to connect.</param> public static KeyValuePair <string, UnityEngine.Color> tryConnection(IAntenna antenna, Guid target) { String status = "ok"; // What kind of target? if (RTCore.Instance != null && RTCore.Instance.Network != null && target != Guid.Empty && target != NetworkManager.ActiveVesselGuid) { bool warning = false, error = false; ISatellite mySat = RTCore.Instance.Network[antenna.Guid]; if (mySat == null) { return(new KeyValuePair <string, UnityEngine.Color>("", UnityEngine.Color.white)); } List <string> conditions = new List <string>(); // Most probably a satellite ISatellite targetSat = RTCore.Instance.Network[target]; if (targetSat != null) { if (!RangeModelExtensions.HasLineOfSightWith(mySat, targetSat)) { status = "No line of sight"; error = true; } double dist = RangeModelExtensions.DistanceTo(mySat, targetSat); // Only standard model supported for now, RangeModel isn't designed for this problem double maxDist = Math.Max(antenna.Omni, antenna.Dish); conditions.Add("Current distance:" + RTUtil.FormatSI(dist, "m")); conditions.Add("Antenna range:" + RTUtil.FormatSI(maxDist, "m")); if (dist > maxDist) { status = "Target not in range"; error = true; } } try { CelestialBody targetPlanet = RTCore.Instance.Network.Planets[target]; double dist = Vector3d.Distance(mySat.Position, targetPlanet.position); double maxDist = Math.Max(antenna.Omni, antenna.Dish); double spread = 2.0 * dist * Math.Sqrt(1 - antenna.CosAngle * antenna.CosAngle); int numTargets = countInCone(antenna, target); if (spread < 2.0 * targetPlanet.Radius) { // WHAT does this info? // conditions.Add("Small Cone"); warning = true; } conditions.Add("Current distance:" + RTUtil.FormatSI(dist, "m")); conditions.Add("Antenna range:" + RTUtil.FormatSI(maxDist, "m")); if (dist <= maxDist) { conditions.Add(String.Format("Info:{0} beam covers {1} targets)", RTUtil.FormatSI(spread, "m"), numTargets )); } else { status = "Target not in range"; error = true; } if (numTargets <= 0) { warning = true; } } catch (KeyNotFoundException) {} conditions.Add("Status:" + status); return(new KeyValuePair <string, UnityEngine.Color>( String.Join("; ", conditions.ToArray()), error ? UnityEngine.Color.red : (warning ? UnityEngine.Color.yellow : UnityEngine.Color.white) )); } // Default behavior return(new KeyValuePair <string, UnityEngine.Color>("", UnityEngine.Color.white)); }
private String Format(DelayedCommand dc) { StringBuilder s = new StringBuilder(); if (dc.AttitudeCommand != null) { switch (dc.AttitudeCommand.Mode) { case FlightMode.Off: s.Append("Mode: Off"); break; case FlightMode.KillRot: s.Append("Mode: Kill rotation"); break; case FlightMode.AttitudeHold: s.Append("Mode: Hold, "); switch (dc.AttitudeCommand.Attitude) { case FlightAttitude.Prograde: s.Append("Prograde"); break; case FlightAttitude.Retrograde: s.Append("Retrograde"); break; case FlightAttitude.NormalPlus: s.Append("Normal +"); break; case FlightAttitude.NormalMinus: s.Append("Normal -"); break; case FlightAttitude.RadialPlus: s.Append("Radial +"); break; case FlightAttitude.RadialMinus: s.Append("Radial -"); break; case FlightAttitude.Surface: s.Append(dc.AttitudeCommand.Orientation.eulerAngles.x.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.y.ToString("F1")); s.Append(", "); s.Append(dc.AttitudeCommand.Orientation.eulerAngles.z.ToString("F1")); break; } break; case FlightMode.AltitudeHold: s.Append("Mode: Hold, "); s.Append(RTUtil.FormatSI(dc.AttitudeCommand.Altitude, "m")); break; } } else if (dc.ActionGroupCommand != null) { s.Append("Toggle "); s.Append(dc.ActionGroupCommand.ActionGroup.ToString()); } else if (dc.BurnCommand != null) { s.Append("Burn "); s.Append(dc.BurnCommand.Throttle.ToString("P2")); if (dc.BurnCommand.Duration != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.Duration.ToString("F2")); s.Append("s"); } if (dc.BurnCommand.DeltaV != Single.NaN) { s.Append(", "); s.Append(dc.BurnCommand.DeltaV.ToString("F2")); s.Append("m/s"); } } else if (dc.DriveCommand != null) { dc.DriveCommand.GetDescription(s); } else if (dc.Event != null) { s.Append(dc.Event.BaseEvent.listParent.part.partInfo.title); s.Append(": "); s.Append(dc.Event.BaseEvent.GUIName); } double delay = Math.Max(dc.TimeStamp - RTUtil.GetGameTime(), 0); if (delay > 0 || dc.ExtraDelay > 0) { s.AppendLine(); s.Append("Signal delay: "); s.Append(delay.ToString("F2")); s.Append("s"); if (dc.ExtraDelay > 0) { s.Append(" (+"); s.Append(dc.ExtraDelay.ToString("F2")); s.Append("s)"); } } return(s.ToString()); }