private static void InvokePartAction(BaseField baseField, bool ignoreDelay) { var field = (baseField as UIPartActionMenuPatcher.WrappedField); if (field == null) { return; } var v = FlightGlobals.ActiveVessel; if (v == null || v.isEVA || RTCore.Instance == null) { field.Invoke(); return; } VesselSatellite vs = null; if (RTCore.Instance != null) { vs = RTCore.Instance.Satellites[v]; } if (vs == null || vs.HasLocalControl) { field.Invoke(); } else if (FieldWhiteList.Contains(baseField.name)) { field.Invoke(); } else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed) { if (ignoreDelay) { field.Invoke(); } else { // queue command into FC vs.SignalProcessor.FlightComputer.Enqueue(PartActionCommand.Field(baseField, field.NewValue)); } } else if (field.host is PartModule && ((PartModule)field.host).part.Modules.OfType <IAntenna>().Any() && !((PartModule)field.host).part.Modules.OfType <ModuleRTAntennaPassive>().Any() && RTSettings.Instance.ControlAntennaWithoutConnection) { field.Invoke(); } else { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#RT_ModuleUI_SPU_Msg"), 4.0f, ScreenMessageStyle.UPPER_LEFT));//"No connection to send command on." } }
/* * UIPartActionMenuPatcher actions */ private static void InvokeEvent(BaseEvent baseEvent, bool ignoreDelay) { // note: this gets called when the event is invoked through: // RemoteTech.FlightComputer.UIPartActionMenuPatcher.Wrapper.Invoke() var v = FlightGlobals.ActiveVessel; if (v == null || v.isEVA || RTCore.Instance == null) { baseEvent.Invoke(); return; } VesselSatellite vs = null; if (RTCore.Instance != null) { vs = RTCore.Instance.Satellites[v]; } if (vs == null || vs.HasLocalControl) { baseEvent.Invoke(); } else if (EventWhiteList.Contains(baseEvent.name)) { baseEvent.Invoke(); } else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed) { if (ignoreDelay) { baseEvent.Invoke(); } else { vs.SignalProcessor.FlightComputer.Enqueue(EventCommand.Event(baseEvent)); } } else if (baseEvent.listParent.part.Modules.OfType <IAntenna>().Any() && !baseEvent.listParent.part.Modules.OfType <ModuleRTAntennaPassive>().Any() && RTSettings.Instance.ControlAntennaWithoutConnection) { baseEvent.Invoke(); } else { ScreenMessages.PostScreenMessage(new ScreenMessage(Localizer.Format("#RT_ModuleUI_SPU_Msg"), 4.0f, ScreenMessageStyle.UPPER_LEFT));//"No connection to send command on." } }
public void HookPartMenus() { UIPartActionMenuPatcher.Wrap(vessel, (e, ignoreDelay) => { var v = FlightGlobals.ActiveVessel; if (v == null || v.isEVA || RTCore.Instance == null) { e.Invoke(); return; } VesselSatellite vs = null; if (RTCore.Instance != null) { vs = RTCore.Instance.Satellites[v]; } if (vs == null || vs.HasLocalControl) { e.Invoke(); } else if (eventWhiteList.Contains(e.name)) { e.Invoke(); } else if (vs.FlightComputer != null && vs.FlightComputer.InputAllowed) { if (ignoreDelay) { e.Invoke(); } else { vs.SignalProcessor.FlightComputer.Enqueue(EventCommand.Event(e)); } } else if (e.listParent.part.Modules.OfType <IAntenna>().Any() && !e.listParent.part.Modules.OfType <ModuleRTAntennaPassive>().Any() && RTSettings.Instance.ControlAntennaWithoutConnection) { e.Invoke(); } else { ScreenMessages.PostScreenMessage(new ScreenMessage("No connection to send command on.", 4.0f, ScreenMessageStyle.UPPER_LEFT)); } }); }
/// <summary> /// Whether this vessel meets the parameter condition. /// </summary> /// <param name="vessel">Vessel to check</param> /// <returns>Whether the vessel meets the parameter condition(s).</returns> protected override bool VesselMeetsCondition(Vessel vessel) { LoggingUtil.LogVerbose(this, "Checking VesselMeetsCondition: " + vessel.id); // Get all the antennae VesselSatellite sat = RTCore.Instance.Satellites[vessel.id]; IEnumerable <IAntenna> antennas = sat != null ? sat.Antennas : new List <IAntenna>(); // If we're a VesselParameterGroup child, only do actual state change if we're the tracked vessel bool checkOnly = false; if (Parent is VesselParameterGroup) { checkOnly = ((VesselParameterGroup)Parent).TrackedVessel != vessel; } return(ParameterDelegate <IAntenna> .CheckChildConditions(this, antennas, checkOnly)); }
public void Draw() { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; foreach (VesselSatellite sat in RTCore.Instance.Satellites) { if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel) { continue; } String text = sat.Name.Truncate(25); RTUtil.StateButton(text, mSelection == sat ? 1 : 0, 1, s => { mSelection = (s > 0) ? sat : null; if (mSelection != null) { Vessel vessel = sat.SignalProcessor.Vessel; ScaledMovement scaledMovement = new GameObject().AddComponent<ScaledMovement>(); scaledMovement.tgtRef = vessel.transform; scaledMovement.name = sat.Name; scaledMovement.transform.parent = ScaledSpace.Instance.transform; scaledMovement.vessel = vessel; scaledMovement.type = MapObject.MapObjectType.VESSEL; var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement)); PlanetariumCamera.fetch.targets.Remove(scaledMovement); this.resetTarget(); } else { // go back to the active vessel PlanetariumCamera.fetch.SetTarget(this.resetTarget()); } }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); }
public void Draw() { mScrollPosition = GUILayout.BeginScrollView(mScrollPosition, AbstractWindow.Frame); { Color pushColor = GUI.contentColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; foreach (VesselSatellite sat in RTCore.Instance.Satellites) { if ((sat.parentVessel != null && !MapViewFiltering.CheckAgainstFilter(sat.parentVessel)) || FlightGlobals.ActiveVessel == sat.parentVessel) { continue; } String text = sat.Name.Truncate(25); RTUtil.StateButton(text, mSelection == sat ? 1 : 0, 1, s => { mSelection = (s > 0) ? sat : null; if (mSelection != null) { Vessel vessel = sat.SignalProcessor.Vessel; ScaledMovement scaledMovement = new GameObject().AddComponent <ScaledMovement>(); scaledMovement.tgtRef = vessel.transform; scaledMovement.name = sat.Name; scaledMovement.transform.parent = ScaledSpace.Instance.transform; scaledMovement.vessel = vessel; scaledMovement.type = MapObject.MapObjectType.VESSEL; var success = PlanetariumCamera.fetch.SetTarget(PlanetariumCamera.fetch.AddTarget(scaledMovement)); PlanetariumCamera.fetch.targets.Remove(scaledMovement); this.resetTarget(); } else { // go back to the active vessel PlanetariumCamera.fetch.SetTarget(this.resetTarget()); } }); } GUI.skin.button.alignment = pushAlign; GUI.contentColor = pushColor; } GUILayout.EndScrollView(); }
private void OnRemoteTechUpdate(VesselSatellite s) { Initialize(); // Don't care about unpowered satellites or satellites that don't call home if (!s.Powered || !API.HasConnectionToKSC(s.Guid)) { return; } // Get info about the body being orbited CelestialBodyInfo orbitedCBI = celestialBodies[s.parentVessel.mainBody]; // Find active foreach (IAntenna a in s.Antennas.Where(a => a.Activated)) { // Targetting active vessel if (a.Omni > 0.0 || a.Target == NetworkManager.ActiveVesselGuid) { orbitedCBI.activeRange = Math.Max(orbitedCBI.activeRange, Math.Max(a.Omni, a.Dish)); } } }
/// <summary> /// Whether this vessel meets the parameter condition. /// </summary> /// <param name="vessel">The vessel to check</param> /// <returns>Whether the vessel meets the condition</returns> protected override bool VesselMeetsCondition(Vessel vessel) { LoggingUtil.LogVerbose(this, "Checking VesselMeetsCondition: " + vessel.id); // Check vessels Vessel vessel2 = ContractVesselTracker.Instance.GetAssociatedVessel(vesselKey); if (vessel == null || vessel2 == null) { return(false); } // Get satellites VesselSatellite sat1 = RTCore.Instance.Satellites[vessel.id]; VesselSatellite sat2 = RTCore.Instance.Satellites[vessel2.id]; if (sat1 == null || sat2 == null) { return(false); } // Check if there is a link return(NetworkManager.GetLink(sat1, sat2) != null); }
protected void OnRemoteTechUpdate(VesselSatellite s) { CheckVessel(s.parentVessel); }
/// <summary> /// This method resets the current selected state button on the FocusFragment. /// Should be called by enter map view. /// </summary> public void resetSelection() { // reset the selection set before mSelection = null; }