void Awake() { if (axisBindings == null) { DiscoverAxisBindings(); DiscoverButtonBindings(); } instance = this; onVesselChange = new EventData <Vessel>("onVesselChange"); GameEvents.onVesselChange.Add(OnVesselChange); GameEvents.onInputLocksModified.Add(OnInputLocksModified); ctrlState = new FlightCtrlState(); kerbalState = new KerbalCtrlState(); devices = new List <Device> (); prevMainThrottle = -2; prevMainThrottle = -2; }
static void Postfix(KerbalEVA __instance, ref Vector3 ___tgtFwd, ref Vector3 ___tgtUp, ref Vector3 ___tgtRpos, ref Vector3 ___ladderTgtRPos, ref Vector3 ___packTgtRPos, ref Vector3 ___cmdRot, ref Vector3 ___parachuteInput, ref bool ___manualAxisControl) { Vessel vessel = __instance.vessel; if (vessel.state != Vessel.State.ACTIVE || vessel.packed) { return; } // Get here only if the kerbal is the active vessel, in which // case AI_FlightControl vessel control hook is not called, so // need to check input ourselves AI_FlightControl.instance.CheckInput(); Transform transform = __instance.transform; KerbalCtrlState ctrl = AI_FlightControl.instance.kerbalState; if (ctrl.translation != Vector3.zero) { var trans = new Vector2(ctrl.translation.x, ctrl.translation.z).normalized; if (__instance.CharacterFrameMode) { ___tgtRpos = transform.forward * trans.y; ___tgtRpos += transform.right * trans.x; } else { ___tgtRpos = __instance.fFwd * trans.y; ___tgtRpos += __instance.fRgt * trans.x; } ___ladderTgtRPos = transform.up * ctrl.translation.z; ___ladderTgtRPos += transform.right * ctrl.translation.x; ___packTgtRPos = transform.right * ctrl.translation.x; ___packTgtRPos += transform.up * ctrl.translation.y; ___packTgtRPos += transform.forward * ctrl.translation.z; } if (ctrl.rotation != Vector3.zero) { ___cmdRot = -transform.right * ctrl.rotation.x; ___cmdRot += transform.up * ctrl.rotation.y; ___cmdRot -= transform.forward * ctrl.rotation.z; ___manualAxisControl = true; } if (ctrl.angularBrake > 0) { Vector3 w = __instance.part.Rigidbody.angularVelocity; float W = Vector3.Dot(w, w); if (W > 1) { w /= Mathf.Sqrt(W); } ___cmdRot += -w * ctrl.angularBrake; } if (ctrl.parachute != Vector2.zero) { ___parachuteInput.x = ctrl.parachute.x; ___parachuteInput.y = ctrl.parachute.y; } if (vessel.LandedOrSplashed) { ___manualAxisControl = false; } if (!___manualAxisControl && (GameSettings.EVA_ROTATE_ON_MOVE || vessel.LandedOrSplashed) && ctrl.translation != Vector3.zero) { ___manualAxisControl = false; if (__instance.CharacterFrameMode) { ___tgtFwd = __instance.fFwd; ___tgtUp = __instance.fUp; } else { ___tgtFwd = ___tgtRpos; ___tgtUp = __instance.fUp; } } }