From b38187d6efaaa4dda450326b7d739070983aed64 Mon Sep 17 00:00:00 2001 From: SDraw Date: Sun, 18 Aug 2024 15:47:39 +0300 Subject: [PATCH] Remote gestures handlers components creation based on current settings Methods renames --- ml_amt/GameEvents.cs | 4 +- ml_amt/MotionTweaker.cs | 30 ++++++------ ml_amt/Settings.cs | 4 +- ml_asl/Settings.cs | 4 +- ml_bft/FingerSystem.cs | 16 +++---- ml_bft/GameEvents.cs | 8 ++-- ml_bft/HandHandler.cs | 4 +- ml_bft/HandHandlerVR.cs | 4 +- ml_bft/InputHandler.cs | 8 ++-- ml_bft/Settings.cs | 4 +- ml_dht/GameEvents.cs | 12 ++--- ml_dht/HeadTracked.cs | 36 +++++++------- ml_dht/Settings.cs | 4 +- ml_lme/GameEvents.cs | 8 ++-- ml_lme/LeapInput.cs | 24 +++++----- ml_lme/LeapManager.cs | 8 ++-- ml_lme/LeapTracked.cs | 24 +++++----- ml_lme/LeapTracking.cs | 44 ++++++++--------- ml_lme/Settings.cs | 4 +- ml_pam/ArmMover.cs | 44 ++++++++--------- ml_pam/GameEvents.cs | 12 ++--- ml_pam/Settings.cs | 4 +- ml_pin/Main.cs | 6 +-- ml_pin/Settings.cs | 4 +- ml_pmc/GameEvents.cs | 4 +- ml_pmc/ModUi.cs | 6 +-- ml_pmc/PoseCopycat.cs | 24 +++++----- ml_pmc/Settings.cs | 4 +- ml_prm/GameEvents.cs | 8 ++-- ml_prm/Main.cs | 13 +---- ml_prm/ModUi.cs | 6 +-- ml_prm/RagdollController.cs | 88 +++++++++++++++++----------------- ml_prm/RemoteGestureHandler.cs | 6 +-- ml_prm/RemoteGestureManager.cs | 79 ++++++++++++++++++++++++++++++ ml_prm/Settings.cs | 4 +- ml_vei/Settings.cs | 4 +- 36 files changed, 317 insertions(+), 249 deletions(-) create mode 100644 ml_prm/RemoteGestureManager.cs diff --git a/ml_amt/GameEvents.cs b/ml_amt/GameEvents.cs index 5682d1e..fcb5bcd 100644 --- a/ml_amt/GameEvents.cs +++ b/ml_amt/GameEvents.cs @@ -10,8 +10,8 @@ static class GameEvents internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } diff --git a/ml_amt/MotionTweaker.cs b/ml_amt/MotionTweaker.cs index 857d42c..2234054 100644 --- a/ml_amt/MotionTweaker.cs +++ b/ml_amt/MotionTweaker.cs @@ -52,14 +52,14 @@ void Start() OnCrouchLimitChanged(Settings.CrouchLimit); OnProneLimitChanged(Settings.ProneLimit); - Settings.OnCrouchLimitChanged.AddHandler(this.OnCrouchLimitChanged); - Settings.OnProneLimitChanged.AddHandler(this.OnProneLimitChanged); - Settings.OnMassCenterChanged.AddHandler(this.OnMassCenterChanged); - - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarReuse.AddHandler(this.OnAvatarReuse); - GameEvents.OnPlayspaceScale.AddHandler(this.OnPlayspaceScale); + Settings.OnCrouchLimitChanged.AddListener(this.OnCrouchLimitChanged); + Settings.OnProneLimitChanged.AddListener(this.OnProneLimitChanged); + Settings.OnMassCenterChanged.AddListener(this.OnMassCenterChanged); + + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); + GameEvents.OnPlayspaceScale.AddListener(this.OnPlayspaceScale); } void OnDestroy() @@ -68,14 +68,14 @@ void OnDestroy() m_ikLimits = null; m_parameters.Clear(); - Settings.OnCrouchLimitChanged.RemoveHandler(this.OnCrouchLimitChanged); - Settings.OnProneLimitChanged.RemoveHandler(this.OnProneLimitChanged); - Settings.OnMassCenterChanged.RemoveHandler(this.OnMassCenterChanged); + Settings.OnCrouchLimitChanged.RemoveListener(this.OnCrouchLimitChanged); + Settings.OnProneLimitChanged.RemoveListener(this.OnProneLimitChanged); + Settings.OnMassCenterChanged.RemoveListener(this.OnMassCenterChanged); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarReuse.RemoveHandler(this.OnAvatarReuse); - GameEvents.OnPlayspaceScale.RemoveHandler(this.OnPlayspaceScale); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); + GameEvents.OnPlayspaceScale.RemoveListener(this.OnPlayspaceScale); } void Update() diff --git a/ml_amt/Settings.cs b/ml_amt/Settings.cs index e4d2236..fa77574 100644 --- a/ml_amt/Settings.cs +++ b/ml_amt/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_asl/Settings.cs b/ml_asl/Settings.cs index 53e5339..d79e650 100644 --- a/ml_asl/Settings.cs +++ b/ml_asl/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_bft/FingerSystem.cs b/ml_bft/FingerSystem.cs index 0909558..b198387 100644 --- a/ml_bft/FingerSystem.cs +++ b/ml_bft/FingerSystem.cs @@ -82,10 +82,10 @@ internal FingerSystem() m_pose = new HumanPose(); m_lastValues = new float[40]; - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarReuse.AddHandler(this.OnAvatarReuse); - GameEvents.OnIKSystemLateUpdate.AddHandler(this.OnIKSystemLateUpdate); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); + GameEvents.OnIKSystemLateUpdate.AddListener(this.OnIKSystemLateUpdate); } internal void Cleanup() { @@ -96,10 +96,10 @@ internal void Cleanup() m_rightFingerOffsets.Clear(); m_ready = false; - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarReuse.RemoveHandler(this.OnAvatarReuse); - GameEvents.OnIKSystemLateUpdate.RemoveHandler(this.OnIKSystemLateUpdate); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); + GameEvents.OnIKSystemLateUpdate.RemoveListener(this.OnIKSystemLateUpdate); } internal void OnAvatarSetup() diff --git a/ml_bft/GameEvents.cs b/ml_bft/GameEvents.cs index d281644..9a5c342 100644 --- a/ml_bft/GameEvents.cs +++ b/ml_bft/GameEvents.cs @@ -12,15 +12,15 @@ static class GameEvents internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_objA, T2 p_objB) => m_action?.Invoke(p_objA, p_objB); } diff --git a/ml_bft/HandHandler.cs b/ml_bft/HandHandler.cs index 8c42546..fede1c8 100644 --- a/ml_bft/HandHandler.cs +++ b/ml_bft/HandHandler.cs @@ -18,7 +18,7 @@ protected HandHandler(bool p_left) m_localRotations = new List(); m_renderers = new List(); - Settings.OnShowHandsChanged.AddHandler(this.OnShowHandsChanged); + Settings.OnShowHandsChanged.AddListener(this.OnShowHandsChanged); } public virtual void Cleanup() @@ -31,7 +31,7 @@ public virtual void Cleanup() m_localRotations.Clear(); m_renderers.Clear(); - Settings.OnShowHandsChanged.RemoveHandler(this.OnShowHandsChanged); + Settings.OnShowHandsChanged.RemoveListener(this.OnShowHandsChanged); } public virtual void Update() diff --git a/ml_bft/HandHandlerVR.cs b/ml_bft/HandHandlerVR.cs index 299add1..fe2163e 100644 --- a/ml_bft/HandHandlerVR.cs +++ b/ml_bft/HandHandlerVR.cs @@ -78,7 +78,7 @@ public HandHandlerVR(Transform p_root, bool p_left) : base(p_left) base.OnShowHandsChanged(Settings.ShowHands); OnMotionRangeChanged(Settings.MotionRange); - Settings.OnMotionRangeChanged.AddHandler(this.OnMotionRangeChanged); + Settings.OnMotionRangeChanged.AddListener(this.OnMotionRangeChanged); } public override void Cleanup() @@ -87,7 +87,7 @@ public override void Cleanup() m_skeletonAction = null; - Settings.OnMotionRangeChanged.RemoveHandler(this.OnMotionRangeChanged); + Settings.OnMotionRangeChanged.RemoveListener(this.OnMotionRangeChanged); } public override void Update() diff --git a/ml_bft/InputHandler.cs b/ml_bft/InputHandler.cs index c25c35a..533019a 100644 --- a/ml_bft/InputHandler.cs +++ b/ml_bft/InputHandler.cs @@ -28,9 +28,9 @@ internal InputHandler() VRModeSwitchEvents.OnInitializeXR.AddListener(this.OnSwitchToVR); VRModeSwitchEvents.OnDeinitializeXR.AddListener(this.OnSwitchToDesktop); - Settings.OnSkeletalInputChanged.AddHandler(this.OnSkeletalInputChanged); + Settings.OnSkeletalInputChanged.AddListener(this.OnSkeletalInputChanged); - GameEvents.OnInputUpdate.AddHandler(this.OnInputUpdate); + GameEvents.OnInputUpdate.AddListener(this.OnInputUpdate); } internal void Cleanup() { @@ -39,9 +39,9 @@ internal void Cleanup() RemoveHandlers(); - Settings.OnSkeletalInputChanged.RemoveHandler(this.OnSkeletalInputChanged); + Settings.OnSkeletalInputChanged.RemoveListener(this.OnSkeletalInputChanged); - GameEvents.OnInputUpdate.RemoveHandler(this.OnInputUpdate); + GameEvents.OnInputUpdate.RemoveListener(this.OnInputUpdate); } void SetupHandlers() diff --git a/ml_bft/Settings.cs b/ml_bft/Settings.cs index c1caa6b..d437663 100644 --- a/ml_bft/Settings.cs +++ b/ml_bft/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_dht/GameEvents.cs b/ml_dht/GameEvents.cs index 48a9269..d5a469b 100644 --- a/ml_dht/GameEvents.cs +++ b/ml_dht/GameEvents.cs @@ -16,22 +16,22 @@ internal class EventResult internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_objA, T2 p_objB) => m_action?.Invoke(p_objA, p_objB); } diff --git a/ml_dht/HeadTracked.cs b/ml_dht/HeadTracked.cs index 42d8595..fdcd5d5 100644 --- a/ml_dht/HeadTracked.cs +++ b/ml_dht/HeadTracked.cs @@ -51,28 +51,28 @@ void Start() OnHeadTrackingChanged(Settings.HeadTracking); OnSmoothingChanged(Settings.Smoothing); - Settings.OnEnabledChanged.AddHandler(this.OnEnabledChanged); - Settings.OnHeadTrackingChanged.AddHandler(this.OnHeadTrackingChanged); - Settings.OnSmoothingChanged.AddHandler(this.OnSmoothingChanged); - - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.AddHandler(this.OnAvatarReuse); - GameEvents.OnEyeControllerUpdate.AddHandler(this.OnEyeControllerUpdate); - GameEvents.OnFaceTrackingUpdate.AddHandler(this.UpdateFaceTracking); + Settings.OnEnabledChanged.AddListener(this.OnEnabledChanged); + Settings.OnHeadTrackingChanged.AddListener(this.OnHeadTrackingChanged); + Settings.OnSmoothingChanged.AddListener(this.OnSmoothingChanged); + + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); + GameEvents.OnEyeControllerUpdate.AddListener(this.OnEyeControllerUpdate); + GameEvents.OnFaceTrackingUpdate.AddListener(this.UpdateFaceTracking); } void OnDestroy() { - Settings.OnEnabledChanged.RemoveHandler(this.OnEnabledChanged); - Settings.OnHeadTrackingChanged.RemoveHandler(this.OnHeadTrackingChanged); - Settings.OnSmoothingChanged.RemoveHandler(this.OnSmoothingChanged); - - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.RemoveHandler(this.OnAvatarReuse); - GameEvents.OnEyeControllerUpdate.RemoveHandler(this.OnEyeControllerUpdate); - GameEvents.OnFaceTrackingUpdate.RemoveHandler(this.UpdateFaceTracking); + Settings.OnEnabledChanged.RemoveListener(this.OnEnabledChanged); + Settings.OnHeadTrackingChanged.RemoveListener(this.OnHeadTrackingChanged); + Settings.OnSmoothingChanged.RemoveListener(this.OnSmoothingChanged); + + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); + GameEvents.OnEyeControllerUpdate.RemoveListener(this.OnEyeControllerUpdate); + GameEvents.OnFaceTrackingUpdate.RemoveListener(this.UpdateFaceTracking); } void Update() diff --git a/ml_dht/Settings.cs b/ml_dht/Settings.cs index d854276..7cbb906 100644 --- a/ml_dht/Settings.cs +++ b/ml_dht/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_lme/GameEvents.cs b/ml_lme/GameEvents.cs index 2c518cc..bb2a6e8 100644 --- a/ml_lme/GameEvents.cs +++ b/ml_lme/GameEvents.cs @@ -11,15 +11,15 @@ static class GameEvents internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj); } diff --git a/ml_lme/LeapInput.cs b/ml_lme/LeapInput.cs index 5a488f0..70e8634 100644 --- a/ml_lme/LeapInput.cs +++ b/ml_lme/LeapInput.cs @@ -92,13 +92,13 @@ public override void ModuleAdded() VRModeSwitchEvents.OnInitializeXR.AddListener(OnModeSwitch); VRModeSwitchEvents.OnDeinitializeXR.AddListener(OnModeSwitch); - Settings.OnEnabledChanged.AddHandler(this.OnEnableChanged); - Settings.OnInteractionChanged.AddHandler(this.OnInteractionChanged); - Settings.OnGesturesChanged.AddHandler(this.OnGesturesChanged); - Settings.OnFingersOnlyChanged.AddHandler(this.OnFingersOnlyChanged); + Settings.OnEnabledChanged.AddListener(this.OnEnableChanged); + Settings.OnInteractionChanged.AddListener(this.OnInteractionChanged); + Settings.OnGesturesChanged.AddListener(this.OnGesturesChanged); + Settings.OnFingersOnlyChanged.AddListener(this.OnFingersOnlyChanged); - GameEvents.OnRayScale.AddHandler(this.OnRayScale); - GameEvents.OnPickupGrab.AddHandler(this.OnPickupGrab); + GameEvents.OnRayScale.AddListener(this.OnRayScale); + GameEvents.OnPickupGrab.AddListener(this.OnPickupGrab); } IEnumerator WaitForSettings() @@ -156,13 +156,13 @@ public override void ModuleDestroyed() VRModeSwitchEvents.OnInitializeXR.RemoveListener(OnModeSwitch); VRModeSwitchEvents.OnDeinitializeXR.RemoveListener(OnModeSwitch); - Settings.OnEnabledChanged.RemoveHandler(this.OnEnableChanged); - Settings.OnInteractionChanged.RemoveHandler(this.OnInteractionChanged); - Settings.OnGesturesChanged.RemoveHandler(this.OnGesturesChanged); - Settings.OnFingersOnlyChanged.RemoveHandler(this.OnFingersOnlyChanged); + Settings.OnEnabledChanged.RemoveListener(this.OnEnableChanged); + Settings.OnInteractionChanged.RemoveListener(this.OnInteractionChanged); + Settings.OnGesturesChanged.RemoveListener(this.OnGesturesChanged); + Settings.OnFingersOnlyChanged.RemoveListener(this.OnFingersOnlyChanged); - GameEvents.OnRayScale.RemoveHandler(this.OnRayScale); - GameEvents.OnPickupGrab.RemoveHandler(this.OnPickupGrab); + GameEvents.OnRayScale.RemoveListener(this.OnRayScale); + GameEvents.OnPickupGrab.RemoveListener(this.OnPickupGrab); } public override void UpdateInput() diff --git a/ml_lme/LeapManager.cs b/ml_lme/LeapManager.cs index 8ccceed..3d9e5e8 100644 --- a/ml_lme/LeapManager.cs +++ b/ml_lme/LeapManager.cs @@ -41,8 +41,8 @@ void Start() m_leapController.Connect += this.OnLeapServiceConnect; m_leapController.Disconnect += this.OnLeapServiceDisconnect; - Settings.OnEnabledChanged.AddHandler(this.OnEnableChanged); - Settings.OnTrackingModeChanged.AddHandler(this.OnTrackingModeChanged); + Settings.OnEnabledChanged.AddListener(this.OnEnableChanged); + Settings.OnTrackingModeChanged.AddListener(this.OnTrackingModeChanged); m_leapTracking = new GameObject("[LeapTrackingRoot]").AddComponent(); m_leapTracking.transform.parent = this.transform; @@ -84,8 +84,8 @@ void OnDestroy() } m_leapInput = null; - Settings.OnEnabledChanged.RemoveHandler(this.OnEnableChanged); - Settings.OnTrackingModeChanged.RemoveHandler(this.OnTrackingModeChanged); + Settings.OnEnabledChanged.RemoveListener(this.OnEnableChanged); + Settings.OnTrackingModeChanged.RemoveListener(this.OnTrackingModeChanged); } IEnumerator WaitForObjects() diff --git a/ml_lme/LeapTracked.cs b/ml_lme/LeapTracked.cs index 9c0a470..4121ac7 100644 --- a/ml_lme/LeapTracked.cs +++ b/ml_lme/LeapTracked.cs @@ -139,13 +139,13 @@ void Start() OnFingersOnlyChanged(Settings.FingersOnly); OnTrackElbowsChanged(Settings.TrackElbows); - Settings.OnEnabledChanged.AddHandler(this.OnEnabledChanged); - Settings.OnFingersOnlyChanged.AddHandler(this.OnFingersOnlyChanged); - Settings.OnTrackElbowsChanged.AddHandler(this.OnTrackElbowsChanged); + Settings.OnEnabledChanged.AddListener(this.OnEnabledChanged); + Settings.OnFingersOnlyChanged.AddListener(this.OnFingersOnlyChanged); + Settings.OnTrackElbowsChanged.AddListener(this.OnTrackElbowsChanged); - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.AddHandler(this.OnAvatarReuse); + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); } void OnDestroy() @@ -165,13 +165,13 @@ void OnDestroy() m_vrIK = null; - Settings.OnEnabledChanged.RemoveHandler(this.OnEnabledChanged); - Settings.OnFingersOnlyChanged.RemoveHandler(this.OnFingersOnlyChanged); - Settings.OnTrackElbowsChanged.RemoveHandler(this.OnTrackElbowsChanged); + Settings.OnEnabledChanged.RemoveListener(this.OnEnabledChanged); + Settings.OnFingersOnlyChanged.RemoveListener(this.OnFingersOnlyChanged); + Settings.OnTrackElbowsChanged.RemoveListener(this.OnTrackElbowsChanged); - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.RemoveHandler(this.OnAvatarReuse); + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); } void Update() diff --git a/ml_lme/LeapTracking.cs b/ml_lme/LeapTracking.cs index 5e1a0d4..89ee4b9 100644 --- a/ml_lme/LeapTracking.cs +++ b/ml_lme/LeapTracking.cs @@ -76,17 +76,17 @@ void Start() VRModeSwitchEvents.OnInitializeXR.AddListener(this.OnAvatarSetup); VRModeSwitchEvents.OnDeinitializeXR.AddListener(this.OnAvatarSetup); - Settings.OnDesktopOffsetChanged.AddHandler(this.OnDesktopOffsetChanged); - Settings.OnModelVisibilityChanged.AddHandler(this.OnModelVisibilityChanged); - Settings.OnVisualHandsChanged.AddHandler(this.OnVisualHandsChanged); - Settings.OnTrackingModeChanged.AddHandler(this.OnTrackingModeChanged); - Settings.OnRootAngleChanged.AddHandler(this.OnRootAngleChanged); - Settings.OnHeadAttachChanged.AddHandler(this.OnHeadAttachChanged); - Settings.OnHeadOffsetChanged.AddHandler(this.OnHeadOffsetChanged); - - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnPlayspaceScale.AddHandler(this.OnPlayspaceScale); + Settings.OnDesktopOffsetChanged.AddListener(this.OnDesktopOffsetChanged); + Settings.OnModelVisibilityChanged.AddListener(this.OnModelVisibilityChanged); + Settings.OnVisualHandsChanged.AddListener(this.OnVisualHandsChanged); + Settings.OnTrackingModeChanged.AddListener(this.OnTrackingModeChanged); + Settings.OnRootAngleChanged.AddListener(this.OnRootAngleChanged); + Settings.OnHeadAttachChanged.AddListener(this.OnHeadAttachChanged); + Settings.OnHeadOffsetChanged.AddListener(this.OnHeadOffsetChanged); + + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnPlayspaceScale.AddListener(this.OnPlayspaceScale); } IEnumerator WaitForLocalPlayer() @@ -123,17 +123,17 @@ void OnDestroy() VRModeSwitchEvents.OnInitializeXR.RemoveListener(this.OnAvatarSetup); VRModeSwitchEvents.OnDeinitializeXR.RemoveListener(this.OnAvatarSetup); - Settings.OnDesktopOffsetChanged.RemoveHandler(this.OnDesktopOffsetChanged); - Settings.OnModelVisibilityChanged.RemoveHandler(this.OnModelVisibilityChanged); - Settings.OnVisualHandsChanged.RemoveHandler(this.OnVisualHandsChanged); - Settings.OnTrackingModeChanged.RemoveHandler(this.OnTrackingModeChanged); - Settings.OnRootAngleChanged.RemoveHandler(this.OnRootAngleChanged); - Settings.OnHeadAttachChanged.RemoveHandler(this.OnHeadAttachChanged); - Settings.OnHeadOffsetChanged.RemoveHandler(this.OnHeadOffsetChanged); - - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnPlayspaceScale.RemoveHandler(this.OnPlayspaceScale); + Settings.OnDesktopOffsetChanged.RemoveListener(this.OnDesktopOffsetChanged); + Settings.OnModelVisibilityChanged.RemoveListener(this.OnModelVisibilityChanged); + Settings.OnVisualHandsChanged.RemoveListener(this.OnVisualHandsChanged); + Settings.OnTrackingModeChanged.RemoveListener(this.OnTrackingModeChanged); + Settings.OnRootAngleChanged.RemoveListener(this.OnRootAngleChanged); + Settings.OnHeadAttachChanged.RemoveListener(this.OnHeadAttachChanged); + Settings.OnHeadOffsetChanged.RemoveListener(this.OnHeadOffsetChanged); + + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnPlayspaceScale.RemoveListener(this.OnPlayspaceScale); } void Update() diff --git a/ml_lme/Settings.cs b/ml_lme/Settings.cs index 5e87a58..a2d4fd1 100644 --- a/ml_lme/Settings.cs +++ b/ml_lme/Settings.cs @@ -10,8 +10,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_pam/ArmMover.cs b/ml_pam/ArmMover.cs index fa31524..51afdea 100644 --- a/ml_pam/ArmMover.cs +++ b/ml_pam/ArmMover.cs @@ -78,17 +78,17 @@ void Start() m_enabled = Settings.Enabled; - Settings.OnEnabledChanged.AddHandler(this.OnEnabledChanged); - Settings.OnGrabOffsetChanged.AddHandler(this.OnGrabOffsetChanged); - Settings.OnLeadingHandChanged.AddHandler(this.OnLeadingHandChanged); - Settings.OnHandsExtensionChanged.AddHandler(this.OnHandsExtensionChanged); - - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.AddHandler(this.OnAvatarReuse); - GameEvents.OnPlayspaceScale.AddHandler(this.OnPlayspaceScale); - GameEvents.OnPickupGrab.AddHandler(this.OnPickupGrab); - GameEvents.OnPickupDrop.AddHandler(this.OnPickupDrop); + Settings.OnEnabledChanged.AddListener(this.OnEnabledChanged); + Settings.OnGrabOffsetChanged.AddListener(this.OnGrabOffsetChanged); + Settings.OnLeadingHandChanged.AddListener(this.OnLeadingHandChanged); + Settings.OnHandsExtensionChanged.AddListener(this.OnHandsExtensionChanged); + + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse); + GameEvents.OnPlayspaceScale.AddListener(this.OnPlayspaceScale); + GameEvents.OnPickupGrab.AddListener(this.OnPickupGrab); + GameEvents.OnPickupDrop.AddListener(this.OnPickupDrop); } void OnDestroy() @@ -108,17 +108,17 @@ void OnDestroy() m_pickup = null; m_vrIK = null; - Settings.OnEnabledChanged.RemoveHandler(this.OnEnabledChanged); - Settings.OnGrabOffsetChanged.RemoveHandler(this.OnGrabOffsetChanged); - Settings.OnLeadingHandChanged.RemoveHandler(this.OnLeadingHandChanged); - Settings.OnHandsExtensionChanged.RemoveHandler(this.OnHandsExtensionChanged); - - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarReuse.RemoveHandler(this.OnAvatarReuse); - GameEvents.OnPlayspaceScale.RemoveHandler(this.OnPlayspaceScale); - GameEvents.OnPickupGrab.RemoveHandler(this.OnPickupGrab); - GameEvents.OnPickupDrop.RemoveHandler(this.OnPickupDrop); + Settings.OnEnabledChanged.RemoveListener(this.OnEnabledChanged); + Settings.OnGrabOffsetChanged.RemoveListener(this.OnGrabOffsetChanged); + Settings.OnLeadingHandChanged.RemoveListener(this.OnLeadingHandChanged); + Settings.OnHandsExtensionChanged.RemoveListener(this.OnHandsExtensionChanged); + + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse); + GameEvents.OnPlayspaceScale.RemoveListener(this.OnPlayspaceScale); + GameEvents.OnPickupGrab.RemoveListener(this.OnPickupGrab); + GameEvents.OnPickupDrop.RemoveListener(this.OnPickupDrop); } void Update() diff --git a/ml_pam/GameEvents.cs b/ml_pam/GameEvents.cs index c7a365e..2baae54 100644 --- a/ml_pam/GameEvents.cs +++ b/ml_pam/GameEvents.cs @@ -12,22 +12,22 @@ static class GameEvents internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_objA, T2 p_objB) => m_action?.Invoke(p_objA, p_objB); } diff --git a/ml_pam/Settings.cs b/ml_pam/Settings.cs index c59e4f2..222af5b 100644 --- a/ml_pam/Settings.cs +++ b/ml_pam/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_pin/Main.cs b/ml_pin/Main.cs index 079766f..26d93ba 100644 --- a/ml_pin/Main.cs +++ b/ml_pin/Main.cs @@ -107,9 +107,9 @@ void OnPlayerLeave(CVRPlayerEntity p_player) bool ShouldNotifyInCurrentInstance() { - bool l_isInPublic = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Public") && Settings.NotifyInPublic); - bool l_isInFriends = (MetaPort.Instance.CurrentInstancePrivacy.Contains("Friends") && Settings.NotifyInFriends); - bool l_isInPrivate = (MetaPort.Instance.CurrentInstancePrivacy.Contains("invite") && Settings.NotifyInPrivate); + bool l_isInPublic = ((MetaPort.Instance.CurrentInstancePrivacyType == MetaPort.InstancePrivacy.Public) && Settings.NotifyInPublic); + bool l_isInFriends = (((MetaPort.Instance.CurrentInstancePrivacyType == MetaPort.InstancePrivacy.Friends) || (MetaPort.Instance.CurrentInstancePrivacyType == MetaPort.InstancePrivacy.FriendsOfFriends)) && Settings.NotifyInFriends); + bool l_isInPrivate = (((MetaPort.Instance.CurrentInstancePrivacyType == MetaPort.InstancePrivacy.EveryoneCanInvite) || (MetaPort.Instance.CurrentInstancePrivacyType == MetaPort.InstancePrivacy.OwnerMustInvite)) && Settings.NotifyInPrivate); return (l_isInPublic || l_isInFriends || l_isInPrivate); } } diff --git a/ml_pin/Settings.cs b/ml_pin/Settings.cs index 76b8682..36468bc 100644 --- a/ml_pin/Settings.cs +++ b/ml_pin/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_pmc/GameEvents.cs b/ml_pmc/GameEvents.cs index 502807d..02dd1ae 100644 --- a/ml_pmc/GameEvents.cs +++ b/ml_pmc/GameEvents.cs @@ -10,8 +10,8 @@ static class GameEvents internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } diff --git a/ml_pmc/ModUi.cs b/ml_pmc/ModUi.cs index de98fc9..d1f0c33 100644 --- a/ml_pmc/ModUi.cs +++ b/ml_pmc/ModUi.cs @@ -12,8 +12,8 @@ static class ModUi internal class UiEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } @@ -72,7 +72,7 @@ internal static void Init() (ms_uiElements[(int)UiIndex.Reset] as Button).OnPress += Reset; BTKUILib.QuickMenuAPI.OnPlayerSelected += (_, id) => ms_selectedPlayer = id; - PoseCopycat.OnCopycatChanged.AddHandler(OnCopycatChanged); + PoseCopycat.OnCopycatChanged.AddListener(OnCopycatChanged); } static void OnCopySwitch() => OnTargetSelect.Invoke(ms_selectedPlayer); diff --git a/ml_pmc/PoseCopycat.cs b/ml_pmc/PoseCopycat.cs index 710af6c..98a1daa 100644 --- a/ml_pmc/PoseCopycat.cs +++ b/ml_pmc/PoseCopycat.cs @@ -15,8 +15,8 @@ public class PoseCopycat : MonoBehaviour public class CopycatEvent { event System.Action m_action; - public void AddHandler(System.Action p_listener) => m_action += p_listener; - public void RemoveHandler(System.Action p_listener) => m_action -= p_listener; + public void AddListener(System.Action p_listener) => m_action += p_listener; + public void RemoveListener(System.Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_value) => m_action?.Invoke(p_value); } @@ -51,12 +51,12 @@ void Awake() void Start() { - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarPreReuse.AddHandler(this.OnAvatarPreReuse); - GameEvents.OnAvatarPostReuse.AddHandler(this.OnAvatarPostReuse); + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarPreReuse.AddListener(this.OnAvatarPreReuse); + GameEvents.OnAvatarPostReuse.AddListener(this.OnAvatarPostReuse); - ModUi.OnTargetSelect.AddHandler(this.OnTargetSelect); + ModUi.OnTargetSelect.AddListener(this.OnTargetSelect); } void OnDestroy() { @@ -74,12 +74,12 @@ void OnDestroy() m_vrIk = null; m_lookAtIk = null; - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarPreReuse.RemoveHandler(this.OnAvatarPreReuse); - GameEvents.OnAvatarPostReuse.RemoveHandler(this.OnAvatarPostReuse); + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarPreReuse.RemoveListener(this.OnAvatarPreReuse); + GameEvents.OnAvatarPostReuse.RemoveListener(this.OnAvatarPostReuse); - ModUi.OnTargetSelect.RemoveHandler(this.OnTargetSelect); + ModUi.OnTargetSelect.RemoveListener(this.OnTargetSelect); } // Unity events diff --git a/ml_pmc/Settings.cs b/ml_pmc/Settings.cs index dd355bf..534227e 100644 --- a/ml_pmc/Settings.cs +++ b/ml_pmc/Settings.cs @@ -8,8 +8,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_prm/GameEvents.cs b/ml_prm/GameEvents.cs index 8969101..cc67224 100644 --- a/ml_prm/GameEvents.cs +++ b/ml_prm/GameEvents.cs @@ -20,15 +20,15 @@ internal class EventResult internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } internal class GameEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj); } diff --git a/ml_prm/Main.cs b/ml_prm/Main.cs index dece54f..f9d824b 100644 --- a/ml_prm/Main.cs +++ b/ml_prm/Main.cs @@ -1,6 +1,5 @@ using ABI_RC.Core.Player; using ABI_RC.Core.Util.AssetFiltering; -using ABI_RC.Systems.GameEventSystem; using System; using System.Collections.Generic; using System.Reflection; @@ -17,8 +16,7 @@ public override void OnInitializeMelon() ModUi.Init(); GameEvents.Init(HarmonyInstance); WorldHandler.Init(); - - CVRGameEventSystem.Player.OnJoinEntity.AddListener(this.OnRemotePlayerCreated); + RemoteGestureManager.Init(); MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer()); MelonLoader.MelonCoroutines.Start(WaitForWhitelist()); @@ -27,12 +25,11 @@ public override void OnInitializeMelon() public override void OnDeinitializeMelon() { WorldHandler.DeInit(); + RemoteGestureManager.DeInit(); if(m_localController != null) UnityEngine.Object.Destroy(m_localController); m_localController = null; - - CVRGameEventSystem.Player.OnJoinEntity.RemoveListener(this.OnRemotePlayerCreated); } System.Collections.IEnumerator WaitForLocalPlayer() @@ -55,11 +52,5 @@ System.Collections.IEnumerator WaitForWhitelist() } l_hashSet.Add(typeof(RagdollToggle)); } - - void OnRemotePlayerCreated(CVRPlayerEntity p_player) - { - if((p_player != null) && (p_player.PuppetMaster != null)) - p_player.PuppetMaster.gameObject.AddComponent(); - } } } diff --git a/ml_prm/ModUi.cs b/ml_prm/ModUi.cs index 49e3714..b6eff8f 100644 --- a/ml_prm/ModUi.cs +++ b/ml_prm/ModUi.cs @@ -11,8 +11,8 @@ static class ModUi internal class UiEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke() => m_action?.Invoke(); } @@ -87,7 +87,7 @@ internal static void Init() ms_hotkeyToggle = ms_category.AddToggle("Use hotkey", "Switch ragdoll mode with 'R' key", Settings.Hotkey); ms_hotkeyToggle.ToggleTooltip = string.Format(c_ragdollKeyTooltip, Settings.HotkeyKey); ms_hotkeyToggle.OnValueUpdated += (state) => OnToggleUpdate(UiIndex.Hotkey, state); - Settings.OnHotkeyKeyChanged.AddHandler(OnHotkeyKeyChanged); + Settings.OnHotkeyKeyChanged.AddListener(OnHotkeyKeyChanged); ms_gravityToggle = ms_category.AddToggle("Use gravity", "Apply gravity to ragdoll", Settings.Gravity); ms_gravityToggle.OnValueUpdated += (state) => OnToggleUpdate(UiIndex.Gravity, state); diff --git a/ml_prm/RagdollController.cs b/ml_prm/RagdollController.cs index 7fd72b3..aca6b7b 100644 --- a/ml_prm/RagdollController.cs +++ b/ml_prm/RagdollController.cs @@ -81,30 +81,30 @@ void Start() m_puppetRoot.localPosition = Vector3.zero; m_puppetRoot.localRotation = Quaternion.identity; - Settings.OnMovementDragChanged.AddHandler(this.OnMovementDragChanged); - Settings.OnAngularDragChanged.AddHandler(this.OnAngularDragChanged); - Settings.OnGravityChanged.AddHandler(this.OnGravityChanged); - Settings.OnSlipperinessChanged.AddHandler(this.OnPhysicsMaterialChanged); - Settings.OnBouncinessChanged.AddHandler(this.OnPhysicsMaterialChanged); - Settings.OnBuoyancyChanged.AddHandler(this.OnBuoyancyChanged); - Settings.OnFallDamageChanged.AddHandler(this.OnFallDamageChanged); - Settings.OnGestureGrabChanged.AddHandler(this.OnGestureGrabChanged); - - GameEvents.OnAvatarClear.AddHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.AddHandler(this.OnAvatarSetup); - GameEvents.OnAvatarPreReuse.AddHandler(this.OnAvatarPreReuse); - GameEvents.OnAvatarPostReuse.AddHandler(this.OnAvatarPostReuse); - GameEvents.OnIKScaling.AddHandler(this.OnAvatarScaling); - GameEvents.OnSeatPreSit.AddHandler(this.OnSeatPreSit); - GameEvents.OnCalibrationStart.AddHandler(this.OnCalibrationStart); - GameEvents.OnWorldPreSpawn.AddHandler(this.OnWorldPreSpawn); - GameEvents.OnCombatPreDown.AddHandler(this.OnCombatPreDown); - GameEvents.OnFlightChange.AddHandler(this.OnFlightChange); - GameEvents.OnIKOffsetUpdate.AddHandler(this.OnIKOffsetUpdate); + Settings.OnMovementDragChanged.AddListener(this.OnMovementDragChanged); + Settings.OnAngularDragChanged.AddListener(this.OnAngularDragChanged); + Settings.OnGravityChanged.AddListener(this.OnGravityChanged); + Settings.OnSlipperinessChanged.AddListener(this.OnPhysicsMaterialChanged); + Settings.OnBouncinessChanged.AddListener(this.OnPhysicsMaterialChanged); + Settings.OnBuoyancyChanged.AddListener(this.OnBuoyancyChanged); + Settings.OnFallDamageChanged.AddListener(this.OnFallDamageChanged); + Settings.OnGestureGrabChanged.AddListener(this.OnGestureGrabChanged); + + GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup); + GameEvents.OnAvatarPreReuse.AddListener(this.OnAvatarPreReuse); + GameEvents.OnAvatarPostReuse.AddListener(this.OnAvatarPostReuse); + GameEvents.OnIKScaling.AddListener(this.OnAvatarScaling); + GameEvents.OnSeatPreSit.AddListener(this.OnSeatPreSit); + GameEvents.OnCalibrationStart.AddListener(this.OnCalibrationStart); + GameEvents.OnWorldPreSpawn.AddListener(this.OnWorldPreSpawn); + GameEvents.OnCombatPreDown.AddListener(this.OnCombatPreDown); + GameEvents.OnFlightChange.AddListener(this.OnFlightChange); + GameEvents.OnIKOffsetUpdate.AddListener(this.OnIKOffsetUpdate); BetterBetterCharacterController.OnTeleport.AddListener(this.OnPlayerTeleport); - ModUi.OnSwitchChanged.AddHandler(this.SwitchRagdoll); - RemoteGestureHandler.OnGestureState.AddHandler(this.OnRemotePlayerGestureStateChanged); + ModUi.OnSwitchChanged.AddListener(this.SwitchRagdoll); + RemoteGestureHandler.OnGestureState.AddListener(this.OnRemotePlayerGestureStateChanged); } void OnDestroy() @@ -130,30 +130,30 @@ void OnDestroy() Object.Destroy(m_physicsMaterial); m_physicsMaterial = null; - Settings.OnMovementDragChanged.RemoveHandler(this.OnMovementDragChanged); - Settings.OnAngularDragChanged.RemoveHandler(this.OnAngularDragChanged); - Settings.OnGravityChanged.RemoveHandler(this.OnGravityChanged); - Settings.OnSlipperinessChanged.RemoveHandler(this.OnPhysicsMaterialChanged); - Settings.OnBouncinessChanged.RemoveHandler(this.OnPhysicsMaterialChanged); - Settings.OnBuoyancyChanged.RemoveHandler(this.OnBuoyancyChanged); - Settings.OnFallDamageChanged.RemoveHandler(this.OnFallDamageChanged); - Settings.OnGestureGrabChanged.RemoveHandler(this.OnGestureGrabChanged); - - GameEvents.OnAvatarClear.RemoveHandler(this.OnAvatarClear); - GameEvents.OnAvatarSetup.RemoveHandler(this.OnAvatarSetup); - GameEvents.OnAvatarPreReuse.RemoveHandler(this.OnAvatarPreReuse); - GameEvents.OnAvatarPostReuse.RemoveHandler(this.OnAvatarPostReuse); - GameEvents.OnIKScaling.RemoveHandler(this.OnAvatarScaling); - GameEvents.OnSeatPreSit.RemoveHandler(this.OnSeatPreSit); - GameEvents.OnCalibrationStart.RemoveHandler(this.OnCalibrationStart); - GameEvents.OnWorldPreSpawn.RemoveHandler(this.OnWorldPreSpawn); - GameEvents.OnCombatPreDown.RemoveHandler(this.OnCombatPreDown); - GameEvents.OnFlightChange.RemoveHandler(this.OnFlightChange); - GameEvents.OnIKOffsetUpdate.RemoveHandler(this.OnIKOffsetUpdate); + Settings.OnMovementDragChanged.RemoveListener(this.OnMovementDragChanged); + Settings.OnAngularDragChanged.RemoveListener(this.OnAngularDragChanged); + Settings.OnGravityChanged.RemoveListener(this.OnGravityChanged); + Settings.OnSlipperinessChanged.RemoveListener(this.OnPhysicsMaterialChanged); + Settings.OnBouncinessChanged.RemoveListener(this.OnPhysicsMaterialChanged); + Settings.OnBuoyancyChanged.RemoveListener(this.OnBuoyancyChanged); + Settings.OnFallDamageChanged.RemoveListener(this.OnFallDamageChanged); + Settings.OnGestureGrabChanged.RemoveListener(this.OnGestureGrabChanged); + + GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear); + GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup); + GameEvents.OnAvatarPreReuse.RemoveListener(this.OnAvatarPreReuse); + GameEvents.OnAvatarPostReuse.RemoveListener(this.OnAvatarPostReuse); + GameEvents.OnIKScaling.RemoveListener(this.OnAvatarScaling); + GameEvents.OnSeatPreSit.RemoveListener(this.OnSeatPreSit); + GameEvents.OnCalibrationStart.RemoveListener(this.OnCalibrationStart); + GameEvents.OnWorldPreSpawn.RemoveListener(this.OnWorldPreSpawn); + GameEvents.OnCombatPreDown.RemoveListener(this.OnCombatPreDown); + GameEvents.OnFlightChange.RemoveListener(this.OnFlightChange); + GameEvents.OnIKOffsetUpdate.RemoveListener(this.OnIKOffsetUpdate); BetterBetterCharacterController.OnTeleport.RemoveListener(this.OnPlayerTeleport); - ModUi.OnSwitchChanged.RemoveHandler(this.SwitchRagdoll); - RemoteGestureHandler.OnGestureState.RemoveHandler(this.OnRemotePlayerGestureStateChanged); + ModUi.OnSwitchChanged.RemoveListener(this.SwitchRagdoll); + RemoteGestureHandler.OnGestureState.RemoveListener(this.OnRemotePlayerGestureStateChanged); } void Update() diff --git a/ml_prm/RemoteGestureHandler.cs b/ml_prm/RemoteGestureHandler.cs index 06c98f8..9a1cbd5 100644 --- a/ml_prm/RemoteGestureHandler.cs +++ b/ml_prm/RemoteGestureHandler.cs @@ -1,8 +1,6 @@ using ABI_RC.Core.Networking.IO.Social; using ABI_RC.Core.Player; using System; -using System.Collections.Generic; -using System.Text; using UnityEngine; namespace ml_prm @@ -12,8 +10,8 @@ class RemoteGestureHandler : MonoBehaviour internal class GestureEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T1 p_objA, T2 p_objB, T3 p_objC) => m_action?.Invoke(p_objA, p_objB, p_objC); } diff --git a/ml_prm/RemoteGestureManager.cs b/ml_prm/RemoteGestureManager.cs new file mode 100644 index 0000000..33be251 --- /dev/null +++ b/ml_prm/RemoteGestureManager.cs @@ -0,0 +1,79 @@ +using ABI_RC.Core.Player; +using ABI_RC.Systems.GameEventSystem; +using System; +using System.Collections.Generic; + +namespace ml_prm +{ + static class RemoteGestureManager + { + static readonly Dictionary ms_remoteHandlers = new Dictionary(); + + internal static void Init() + { + CVRGameEventSystem.Player.OnJoinEntity.AddListener(OnRemotePlayerCreated); + CVRGameEventSystem.Player.OnLeaveEntity.AddListener(OnRemotePlayerDestroyed); + Settings.OnGestureGrabChanged.AddListener(OnGestureGrabChanged); + } + + internal static void DeInit() + { + CVRGameEventSystem.Player.OnJoinEntity.RemoveListener(OnRemotePlayerCreated); + CVRGameEventSystem.Player.OnLeaveEntity.RemoveListener(OnRemotePlayerDestroyed); + Settings.OnGestureGrabChanged.RemoveListener(OnGestureGrabChanged); + } + + static void OnRemotePlayerCreated(CVRPlayerEntity p_player) + { + try + { + if(Settings.GestureGrab && (p_player != null) && (p_player.PuppetMaster != null)) + { + RemoteGestureHandler l_handler = p_player.PuppetMaster.gameObject.AddComponent(); + ms_remoteHandlers.Add(p_player, l_handler); + } + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnRemotePlayerDestroyed(CVRPlayerEntity p_player) + { + try + { + if(p_player != null) + ms_remoteHandlers.Remove(p_player); + } + catch(Exception e) + { + MelonLoader.MelonLogger.Error(e); + } + } + + static void OnGestureGrabChanged(bool p_state) + { + if(p_state) + { + foreach(var l_player in CVRPlayerManager.Instance.NetworkPlayers) + { + if(!ms_remoteHandlers.ContainsKey(l_player) && (l_player.PuppetMaster != null)) + { + RemoteGestureHandler l_handler = l_player.PuppetMaster.gameObject.AddComponent(); + ms_remoteHandlers.Add(l_player, l_handler); + } + } + } + else + { + foreach(var l_pair in ms_remoteHandlers) + { + if(l_pair.Value != null) + UnityEngine.Object.Destroy(l_pair.Value); + } + ms_remoteHandlers.Clear(); + } + } + } +} diff --git a/ml_prm/Settings.cs b/ml_prm/Settings.cs index e16d152..a0f889a 100644 --- a/ml_prm/Settings.cs +++ b/ml_prm/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); } diff --git a/ml_vei/Settings.cs b/ml_vei/Settings.cs index 25210b4..0a626f1 100644 --- a/ml_vei/Settings.cs +++ b/ml_vei/Settings.cs @@ -9,8 +9,8 @@ static class Settings internal class SettingEvent { event Action m_action; - public void AddHandler(Action p_listener) => m_action += p_listener; - public void RemoveHandler(Action p_listener) => m_action -= p_listener; + public void AddListener(Action p_listener) => m_action += p_listener; + public void RemoveListener(Action p_listener) => m_action -= p_listener; public void Invoke(T p_value) => m_action?.Invoke(p_value); }