All checks were successful
Build project / Build for (StandaloneLinux64, 6000.0.37f1) (push) Successful in 5m17s
Build project / Build for (StandaloneWindows64, 6000.0.37f1) (push) Successful in 5m19s
Build project / Publish to itch.io (StandaloneLinux64) (push) Successful in 5s
Build project / Publish to itch.io (StandaloneWindows64) (push) Successful in 5s
59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
|
|
public class Action {
|
|
|
|
#region Structs/Enums
|
|
public enum EActionType {
|
|
Hold, PressOnce, ReleaseOnce, HoldTwice, PressTwice, ReleaseTwice, MultiHold, MultiPress, MultiRelease
|
|
}
|
|
#endregion
|
|
|
|
#region Fields
|
|
// Maximum time between 2 presses before it's considered a multi-press
|
|
public static TimeSpan MultiDelayTime = TimeSpan.FromMilliseconds(200);
|
|
private ActionNode _node;
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public Action(KeyCode key, EActionType type = EActionType.Hold, int multi =0) {
|
|
if ((int) type >= 3 && multi <= 1)
|
|
multi = 2;
|
|
|
|
_node = new ActionNodeManager(key, type, multi);
|
|
}
|
|
|
|
private Action(ActionNode node) {
|
|
_node = node;
|
|
}
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public bool IsActive() {
|
|
return _node.IsActive();
|
|
}
|
|
#endregion
|
|
|
|
#region Operators
|
|
|
|
static public Action operator &(Action lhs, Action rhs) {
|
|
return new Action(new AndActionNode(lhs._node, rhs._node));
|
|
}
|
|
|
|
static public Action operator |(Action lhs, Action rhs) {
|
|
return new Action(new OrActionNode(lhs._node, rhs._node));
|
|
}
|
|
|
|
static public Action operator !(Action rhs) {
|
|
return new Action(new NotActionNode(rhs._node));
|
|
}
|
|
#endregion
|
|
}
|