using UnityEngine; namespace TyphoonEvent { public struct EventOperation { public uint OperationID { get; internal set; } public EventOperation(uint operationID) { OperationID = operationID; } public bool IsValid => OperationID > 0 && EventKit.GetGroup(OperationID) != null; public void Register(IEventOperation operation) { if (IsValid) { #if UNITY_EDITOR var component = operation as Component; if (component != null) { Debug.Log( $"[警告]二次注册,释放旧订阅,{component} gameObject instance ID:{component.gameObject.GetInstanceID()}"); } else { Debug.Log($"[警告]二次注册,释放旧订阅,{operation}"); } #endif Release(); } if (!operation.EventOperation.IsValid) { var proxies = operation.EventProxies; if (proxies != null && proxies.Length > 0) { operation.EventOperation = EventKit.NewOperation(proxies); } } } public void Release() { if (EventKit.HasInstance()) { EventKit.GetGroup(OperationID)?.Release(); } } public void EnableAll() { if (EventKit.HasInstance()) { EventKit.GetGroup(OperationID)?.EnableAll(); } } public void DisableAll() { if (EventKit.HasInstance()) { EventKit.GetGroup(OperationID)?.DisableAll(); } } public void Enable() { if (EventKit.HasInstance()) { EventKit.GetGroup(OperationID)?.Enable(); } } public void Disable() { if (EventKit.HasInstance()) { EventKit.GetGroup(OperationID)?.Disable(); } } } }