Skip to content

Commit

Permalink
Remote gestures handlers components creation based on current settings
Browse files Browse the repository at this point in the history
Methods renames
  • Loading branch information
SDraw committed Aug 18, 2024
1 parent e5d4ea9 commit b38187d
Show file tree
Hide file tree
Showing 36 changed files with 317 additions and 249 deletions.
4 changes: 2 additions & 2 deletions ml_amt/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
30 changes: 15 additions & 15 deletions ml_amt/MotionTweaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions ml_amt/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static class Settings
internal class SettingEvent<T>
{
event Action<T> m_action;
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
public void AddListener(Action<T> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T> p_listener) => m_action -= p_listener;
public void Invoke(T p_value) => m_action?.Invoke(p_value);
}

Expand Down
4 changes: 2 additions & 2 deletions ml_asl/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static class Settings
internal class SettingEvent<T>
{
event Action<T> m_action;
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
public void AddListener(Action<T> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T> p_listener) => m_action -= p_listener;
public void Invoke(T p_value) => m_action?.Invoke(p_value);
}

Expand Down
16 changes: 8 additions & 8 deletions ml_bft/FingerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions ml_bft/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T1, T2>
{
event Action<T1, T2> m_action;
public void AddHandler(Action<T1, T2> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T1, T2> p_listener) => m_action -= p_listener;
public void AddListener(Action<T1, T2> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T1, T2> p_listener) => m_action -= p_listener;
public void Invoke(T1 p_objA, T2 p_objB) => m_action?.Invoke(p_objA, p_objB);
}

Expand Down
4 changes: 2 additions & 2 deletions ml_bft/HandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected HandHandler(bool p_left)
m_localRotations = new List<Quaternion>();
m_renderers = new List<Renderer>();

Settings.OnShowHandsChanged.AddHandler(this.OnShowHandsChanged);
Settings.OnShowHandsChanged.AddListener(this.OnShowHandsChanged);
}

public virtual void Cleanup()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions ml_bft/HandHandlerVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions ml_bft/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions ml_bft/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static class Settings
internal class SettingEvent<T>
{
event Action<T> m_action;
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
public void AddListener(Action<T> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T> p_listener) => m_action -= p_listener;
public void Invoke(T p_value) => m_action?.Invoke(p_value);
}

Expand Down
12 changes: 6 additions & 6 deletions ml_dht/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T1>
{
event Action<T1> m_action;
public void AddHandler(Action<T1> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T1> p_listener) => m_action -= p_listener;
public void AddListener(Action<T1> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T1> p_listener) => m_action -= p_listener;
public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj);
}
internal class GameEvent<T1, T2>
{
event Action<T1, T2> m_action;
public void AddHandler(Action<T1, T2> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T1, T2> p_listener) => m_action -= p_listener;
public void AddListener(Action<T1, T2> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T1, T2> p_listener) => m_action -= p_listener;
public void Invoke(T1 p_objA, T2 p_objB) => m_action?.Invoke(p_objA, p_objB);
}

Expand Down
36 changes: 18 additions & 18 deletions ml_dht/HeadTracked.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions ml_dht/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ static class Settings
internal class SettingEvent<T>
{
event Action<T> m_action;
public void AddHandler(Action<T> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T> p_listener) => m_action -= p_listener;
public void AddListener(Action<T> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T> p_listener) => m_action -= p_listener;
public void Invoke(T p_value) => m_action?.Invoke(p_value);
}

Expand Down
8 changes: 4 additions & 4 deletions ml_lme/GameEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T1>
{
event Action<T1> m_action;
public void AddHandler(Action<T1> p_listener) => m_action += p_listener;
public void RemoveHandler(Action<T1> p_listener) => m_action -= p_listener;
public void AddListener(Action<T1> p_listener) => m_action += p_listener;
public void RemoveListener(Action<T1> p_listener) => m_action -= p_listener;
public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj);
}

Expand Down
24 changes: 12 additions & 12 deletions ml_lme/LeapInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions ml_lme/LeapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LeapTracking>();
m_leapTracking.transform.parent = this.transform;
Expand Down Expand Up @@ -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()
Expand Down
Loading

0 comments on commit b38187d

Please sign in to comment.