From 15c92d2bb2acf1b28e24817ab830cabc68789b63 Mon Sep 17 00:00:00 2001 From: josuenos <67711422+josuenos@users.noreply.github.com> Date: Wed, 19 Jul 2023 09:25:24 -0400 Subject: [PATCH 1/2] Remove active vessel restriction from FSengineBladed Remove condition that vessel be the active vessel from FSengineBladed, this fixes these engines not working when not the active vessel (most noticeable during BDA dogfights where active vessel is switching). --- Firespitter/engine/FS engine modules/FSengineBladed.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firespitter/engine/FS engine modules/FSengineBladed.cs b/Firespitter/engine/FS engine modules/FSengineBladed.cs index 36f77bed..7543e4e5 100644 --- a/Firespitter/engine/FS engine modules/FSengineBladed.cs +++ b/Firespitter/engine/FS engine modules/FSengineBladed.cs @@ -221,7 +221,7 @@ private void setupBlades() public override void FixedUpdate() { - if (!HighLogic.LoadedSceneIsFlight || !flightStarted || vessel != FlightGlobals.ActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight || !flightStarted) return; float airDirection = getAirSpeed(); From 9c731b8defd7e46a70f8653b478485f251e8953d Mon Sep 17 00:00:00 2001 From: josuenos Date: Wed, 19 Jul 2023 10:38:12 -0400 Subject: [PATCH 2/2] Remove other extraneous active vessel checks. --- .gitignore | 2 ++ Firespitter/aero/FSairBrake.cs | 2 +- Firespitter/animation/FSanimatedAirIntake.cs | 2 +- Firespitter/cockpit/FSActionGroupSwitch.cs | 2 +- Firespitter/cockpit/FSinternalPropRotator.cs | 4 ++-- Firespitter/cockpit/FSmonitorScript.cs | 2 +- Firespitter/control/FSmoveCraftAtLaunch.cs | 2 +- Firespitter/engine/FS engine modules/FSengineBladed.cs | 2 +- Firespitter/engine/FSrotorTrim.cs | 2 +- Firespitter/engine/Stock based modules/FSVTOLrotator.cs | 2 +- Firespitter/engine/Stock based modules/FSengineHover.cs | 2 +- Firespitter/engine/Stock based modules/FShoverThrottle.cs | 2 +- Firespitter/engine/Stock based modules/FSmultiAxisEngine.cs | 2 +- .../engine/Stock based modules/FSpropellerAtmosphericNerf.cs | 2 +- Firespitter/engine/Stock based modules/FStailRotorThrust.cs | 2 +- .../engine/Stock based modules/FSthrottlePropSpinner.cs | 2 +- Firespitter/water/FSrudder.cs | 2 +- Firespitter/wheel/FSpartTurner.cs | 2 +- Firespitter/wheel/FSwheel.cs | 2 +- 19 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0f2f4434..b5971221 100644 --- a/.gitignore +++ b/.gitignore @@ -211,3 +211,5 @@ pip-log.txt #Mr Developer .mr.developer.cfg *.zip +/.vs/slnx.sqlite +/.vs/VSWorkspaceState.json diff --git a/Firespitter/aero/FSairBrake.cs b/Firespitter/aero/FSairBrake.cs index d3754bca..00812c54 100644 --- a/Firespitter/aero/FSairBrake.cs +++ b/Firespitter/aero/FSairBrake.cs @@ -86,7 +86,7 @@ public override void OnStart(PartModule.StartState state) public void FixedUpdate() { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; float angleChange = targetAngle - currentAngle; diff --git a/Firespitter/animation/FSanimatedAirIntake.cs b/Firespitter/animation/FSanimatedAirIntake.cs index 22c96ae1..8c508850 100644 --- a/Firespitter/animation/FSanimatedAirIntake.cs +++ b/Firespitter/animation/FSanimatedAirIntake.cs @@ -29,7 +29,7 @@ public override void OnStart(PartModule.StartState state) public override void OnFixedUpdate() { base.OnFixedUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; if (intakeMeshTransform != null && intakeModule != null) { float modifiedFlow = intakeModule.airFlow - flowAtAnimateStart; diff --git a/Firespitter/cockpit/FSActionGroupSwitch.cs b/Firespitter/cockpit/FSActionGroupSwitch.cs index c32014f9..ec392dcb 100644 --- a/Firespitter/cockpit/FSActionGroupSwitch.cs +++ b/Firespitter/cockpit/FSActionGroupSwitch.cs @@ -237,7 +237,7 @@ public void Update() if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA || CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.Internal) { - bool groupState = FlightGlobals.ActiveVessel.ActionGroups.groups[actionGroupNumber]; + bool groupState = vessel.ActionGroups.groups[actionGroupNumber]; if (switchTypeEnum == SwitchType.flipSwitch) { diff --git a/Firespitter/cockpit/FSinternalPropRotator.cs b/Firespitter/cockpit/FSinternalPropRotator.cs index 3ff28de0..5e38069f 100644 --- a/Firespitter/cockpit/FSinternalPropRotator.cs +++ b/Firespitter/cockpit/FSinternalPropRotator.cs @@ -82,9 +82,9 @@ public override void OnUpdate() { base.OnUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; - smoothBrake = Mathf.Lerp(smoothBrake, (FlightGlobals.ActiveVessel.ActionGroups.groups[brakeActionInt] ? 1 : 0), 0.1f); + smoothBrake = Mathf.Lerp(smoothBrake, (vessel.ActionGroups.groups[brakeActionInt] ? 1 : 0), 0.1f); if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA || CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.Internal) diff --git a/Firespitter/cockpit/FSmonitorScript.cs b/Firespitter/cockpit/FSmonitorScript.cs index a51cb835..aa199a80 100644 --- a/Firespitter/cockpit/FSmonitorScript.cs +++ b/Firespitter/cockpit/FSmonitorScript.cs @@ -138,7 +138,7 @@ public void createTextGrid() public override void OnUpdate() { base.OnUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; // Run once. (Must be run after all parts have been created, so it can't be in the OnAwake) if (!monitorDefaultStateSet) diff --git a/Firespitter/control/FSmoveCraftAtLaunch.cs b/Firespitter/control/FSmoveCraftAtLaunch.cs index 91576ee7..818cfab4 100644 --- a/Firespitter/control/FSmoveCraftAtLaunch.cs +++ b/Firespitter/control/FSmoveCraftAtLaunch.cs @@ -210,7 +210,7 @@ public void fixCraftLock() { if (this.hasLaunched) return; if (this.isDefaultPosition) return; - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; { //Debug.Log("FSmoveCraftAtLaunch: Launching vessel at " + positionDisplayName + ", lat " + latitude + ", long " + longitude + ", alt " + altitude); diff --git a/Firespitter/engine/FS engine modules/FSengineBladed.cs b/Firespitter/engine/FS engine modules/FSengineBladed.cs index 7543e4e5..fab646f1 100644 --- a/Firespitter/engine/FS engine modules/FSengineBladed.cs +++ b/Firespitter/engine/FS engine modules/FSengineBladed.cs @@ -314,7 +314,7 @@ public override void OnUpdate() { base.OnUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !flightStarted || vessel != FlightGlobals.ActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight || !flightStarted) return; getCollectiveInput(); diff --git a/Firespitter/engine/FSrotorTrim.cs b/Firespitter/engine/FSrotorTrim.cs index ae1a9e49..268a6ed3 100644 --- a/Firespitter/engine/FSrotorTrim.cs +++ b/Firespitter/engine/FSrotorTrim.cs @@ -144,7 +144,7 @@ public void FixedUpdate() { if (initialized) { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; FlightCtrlState ctrl = vessel.ctrlState; diff --git a/Firespitter/engine/Stock based modules/FSVTOLrotator.cs b/Firespitter/engine/Stock based modules/FSVTOLrotator.cs index fe60607d..4f9143ba 100644 --- a/Firespitter/engine/Stock based modules/FSVTOLrotator.cs +++ b/Firespitter/engine/Stock based modules/FSVTOLrotator.cs @@ -537,7 +537,7 @@ private void hideAllExternalPopups() public void FixedUpdate() // moved angle update to fixed update to make rotation speed indpendent of framerate { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; float angleChange = targetAngle - currentAngle; diff --git a/Firespitter/engine/Stock based modules/FSengineHover.cs b/Firespitter/engine/Stock based modules/FSengineHover.cs index 066e3cae..ae1cb7b6 100644 --- a/Firespitter/engine/Stock based modules/FSengineHover.cs +++ b/Firespitter/engine/Stock based modules/FSengineHover.cs @@ -98,7 +98,7 @@ public override void OnStart(PartModule.StartState state) public override void OnFixedUpdate() { base.OnFixedUpdate(); - if (HighLogic.LoadedSceneIsFlight && vessel == FlightGlobals.ActiveVessel) + if (HighLogic.LoadedSceneIsFlight) { if (hoverActive) { diff --git a/Firespitter/engine/Stock based modules/FShoverThrottle.cs b/Firespitter/engine/Stock based modules/FShoverThrottle.cs index b082738d..20a67511 100644 --- a/Firespitter/engine/Stock based modules/FShoverThrottle.cs +++ b/Firespitter/engine/Stock based modules/FShoverThrottle.cs @@ -156,7 +156,7 @@ public override void OnStart(PartModule.StartState state) public override void OnUpdate() { base.OnUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel || !engine.EngineIgnited) return; + if (!HighLogic.LoadedSceneIsFlight || !engine.EngineIgnited) return; double pqsAltitude = vessel.pqsAltitude; if (pqsAltitude < 0) pqsAltitude = 0; diff --git a/Firespitter/engine/Stock based modules/FSmultiAxisEngine.cs b/Firespitter/engine/Stock based modules/FSmultiAxisEngine.cs index 6e48bb0f..57e6eea7 100644 --- a/Firespitter/engine/Stock based modules/FSmultiAxisEngine.cs +++ b/Firespitter/engine/Stock based modules/FSmultiAxisEngine.cs @@ -238,7 +238,7 @@ public override void OnStart(PartModule.StartState state) public override void OnFixedUpdate() { base.OnFixedUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; FlightCtrlState ctrl = vessel.ctrlState; Vector3 steeringInput = new Vector3(0, 0, 0); diff --git a/Firespitter/engine/Stock based modules/FSpropellerAtmosphericNerf.cs b/Firespitter/engine/Stock based modules/FSpropellerAtmosphericNerf.cs index 4e577a87..6b0325be 100644 --- a/Firespitter/engine/Stock based modules/FSpropellerAtmosphericNerf.cs +++ b/Firespitter/engine/Stock based modules/FSpropellerAtmosphericNerf.cs @@ -49,7 +49,7 @@ public override void OnStart(PartModule.StartState state) public override void OnUpdate() { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; float atmosphericModifier = ((float)part.staticPressureAtm * thrustModifier); if ((atmosphericModifier > 1f && thrustModifier > 1f) || disableAtmosphericNerf) atmosphericModifier = 1f; // not setting modifier to 1 at thrustModifier 1 or lower allows for engine that are better than normal in atmospeheres above 1 float newThrust = fullThrottle * atmosphericModifier * engineModeModifier * steeringModifier; diff --git a/Firespitter/engine/Stock based modules/FStailRotorThrust.cs b/Firespitter/engine/Stock based modules/FStailRotorThrust.cs index d6774cad..f9ae9b1f 100644 --- a/Firespitter/engine/Stock based modules/FStailRotorThrust.cs +++ b/Firespitter/engine/Stock based modules/FStailRotorThrust.cs @@ -131,7 +131,7 @@ public void FixedUpdate() { if (initialized) { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; FlightCtrlState ctrl = vessel.ctrlState; Vector3 steeringInput = new Vector3(0, 0, 0); diff --git a/Firespitter/engine/Stock based modules/FSthrottlePropSpinner.cs b/Firespitter/engine/Stock based modules/FSthrottlePropSpinner.cs index 2f9adcbe..317cee03 100644 --- a/Firespitter/engine/Stock based modules/FSthrottlePropSpinner.cs +++ b/Firespitter/engine/Stock based modules/FSthrottlePropSpinner.cs @@ -15,7 +15,7 @@ public class FSthrottlePropSpinner : PartModule public override void OnUpdate() { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; var engine = part.Modules.OfType().FirstOrDefault(); diff --git a/Firespitter/water/FSrudder.cs b/Firespitter/water/FSrudder.cs index e7f861a3..6f78280d 100644 --- a/Firespitter/water/FSrudder.cs +++ b/Firespitter/water/FSrudder.cs @@ -138,7 +138,7 @@ public override void OnStart(PartModule.StartState state) public void FixedUpdate() { //base.OnFixedUpdate(); - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; if (firstRun) { diff --git a/Firespitter/wheel/FSpartTurner.cs b/Firespitter/wheel/FSpartTurner.cs index a46f7900..02ca282f 100644 --- a/Firespitter/wheel/FSpartTurner.cs +++ b/Firespitter/wheel/FSpartTurner.cs @@ -296,7 +296,7 @@ public override void OnStart(PartModule.StartState state) public override void OnUpdate() { - if (!HighLogic.LoadedSceneIsFlight || !vessel.isActiveVessel) return; + if (!HighLogic.LoadedSceneIsFlight) return; FlightCtrlState ctrl = vessel.ctrlState; int reverseModifier = 1; diff --git a/Firespitter/wheel/FSwheel.cs b/Firespitter/wheel/FSwheel.cs index 2d64da97..68834c18 100644 --- a/Firespitter/wheel/FSwheel.cs +++ b/Firespitter/wheel/FSwheel.cs @@ -805,7 +805,7 @@ public void FixedUpdate() #region Active vessel code - if (vessel.isActiveVessel && base.vessel.IsControllable) + if (base.vessel.IsControllable) { disableColliders();