This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -11,20 +11,38 @@ namespace BITKit
[System.Serializable]
public class InputActionGroup : IDisposable
{
public override string ToString()
{
return $"Source:{Source}\nEnabled:{isEnabled}\nInitialized:{state}\nKeys:{string.Join("\n",actions.Keys)}";
}
public string Source;
private int lockFile = Guid.NewGuid().GetHashCode();
public bool allowGlobalActivation = true;
[SerializeField, ReadOnly] private bool isEnabled;
private InitializationState state = InitializationState.None;
public ValidHandle allowInput = new();
public readonly ValidHandle allowInput = new();
private readonly ConcurrentDictionary<string,InputAction> actions = new();
/// <summary>
/// 注册所有(started,performed,canceled)回调
/// </summary>
/// <param name="reference"></param>
/// <param name="callback"></param>
/// <returns></returns>
public InputActionGroup RegisterCallback(InputActionReference reference,
Action<InputAction.CallbackContext> callback)
{
var action = EnsureCreated(reference);
action.RegisterCallback(callback);
return this;
}
public InputAction EnsureCreated(InputActionReference reference)
{
if (reference is null)
{
Debug.LogWarning($"未知的引用");
return this;
return null;
}
EnsureConfiguration();
@@ -34,12 +52,12 @@ namespace BITKit
newAction.Rename(reference.name);
return newAction;
});
action.RegisterCallback(callback);
allowInput.Invoke();
return this;
return action;
}
public void Inherit(InputActionGroup other)
{
throw new NotImplementedException();