// A small wrapper to make sure the autopilot does not do anything when it shouldn't private void autoPilot(FlightCtrlState s) { debugString.Length = 0; if (!weaponManager || !vessel || !vessel.transform || vessel.packed || !vessel.mainBody) { return; } // nobody is controlling any more possibly due to G forces? if (!vessel.isCommandable) { if (vessel.Autopilot.Enabled) { Debug.Log("[BDArmory.BDGenericAIBase]: " + vessel.vesselName + " is not commandable, disabling autopilot."); } s.NeutralizeStick(); vessel.Autopilot.Disable(); return; } // generally other AI and guard mode expects this target to be engaged GetGuardTarget(); // get the guard target from weapon manager GetNonGuardTarget(); // if guard mode is off, get the UI target GetGuardNonTarget(); // pick a target if guard mode is on, but no target is selected, // though really targeting should be managed by the weaponManager, what if we pick an airplane while having only abrams cannons? :P // (this is another reason why target selection is hardcoded into the base class, so changing this later is less of a mess :) ) AutoPilot(s); }