diff --git a/Source/Engine/Engine/InputAxis.cs b/Source/Engine/Engine/InputAxis.cs index 7dc51f025..ca77d2465 100644 --- a/Source/Engine/Engine/InputAxis.cs +++ b/Source/Engine/Engine/InputAxis.cs @@ -7,7 +7,7 @@ namespace FlaxEngine /// /// Virtual input axis binding. Helps with listening for a selected axis input. /// - public class InputAxis + public class InputAxis : IComparable, IComparable { /// /// The name of the axis to use. See . @@ -47,13 +47,13 @@ namespace FlaxEngine Input.AxisValueChanged += Handler; Name = name; } - + private void Handler(string name) { if (string.Equals(Name, name, StringComparison.OrdinalIgnoreCase)) ValueChanged?.Invoke(); } - + /// /// Finalizes an instance of the class. /// @@ -61,7 +61,7 @@ namespace FlaxEngine { Input.AxisValueChanged -= Handler; } - + /// /// Releases this object. /// @@ -70,5 +70,35 @@ namespace FlaxEngine Input.AxisValueChanged -= Handler; GC.SuppressFinalize(this); } + + /// + public int CompareTo(InputAxis other) + { + return string.Compare(Name, other.Name, StringComparison.Ordinal); + } + + /// + public int CompareTo(object obj) + { + return obj is InputAxis other ? CompareTo(other) : -1; + } + + /// + public override int GetHashCode() + { + return Name?.GetHashCode() ?? 0; + } + + /// + public override bool Equals(object obj) + { + return obj is InputAxis other && string.Equals(Name, other.Name, StringComparison.Ordinal); + } + + /// + public override string ToString() + { + return Name; + } } } diff --git a/Source/Engine/Engine/InputEvent.cs b/Source/Engine/Engine/InputEvent.cs index 10af5d531..e5653631f 100644 --- a/Source/Engine/Engine/InputEvent.cs +++ b/Source/Engine/Engine/InputEvent.cs @@ -7,7 +7,7 @@ namespace FlaxEngine /// /// Virtual input action binding. Helps with listening for a selected input event. /// - public class InputEvent + public class InputEvent : IComparable, IComparable { /// /// The name of the action to use. See . @@ -21,7 +21,7 @@ namespace FlaxEngine public bool Active => Input.GetAction(Name); /// - /// Returns the event state. Use Use , , to catch events without active waiting. + /// Returns the event state. Use , , to catch events without active waiting. /// public InputActionState State => Input.GetActionState(Name); @@ -35,12 +35,12 @@ namespace FlaxEngine /// Occurs when event is pressed (e.g. user pressed a key). Called before scripts update. /// public event Action Pressed; - + /// /// Occurs when event is being pressing (e.g. user pressing a key). Called before scripts update. /// public event Action Pressing; - + /// /// Occurs when event is released (e.g. user releases a key). Called before scripts update. /// @@ -102,5 +102,35 @@ namespace FlaxEngine Input.ActionTriggered -= Handler; GC.SuppressFinalize(this); } + + /// + public int CompareTo(InputEvent other) + { + return string.Compare(Name, other.Name, StringComparison.Ordinal); + } + + /// + public int CompareTo(object obj) + { + return obj is InputEvent other ? CompareTo(other) : -1; + } + + /// + public override int GetHashCode() + { + return Name?.GetHashCode() ?? 0; + } + + /// + public override bool Equals(object obj) + { + return obj is InputEvent other && string.Equals(Name, other.Name, StringComparison.Ordinal); + } + + /// + public override string ToString() + { + return Name; + } } }