namespace Zinnia.Event.Proxy { using UnityEngine; using UnityEngine.Events; using Zinnia.Extension; using Zinnia.Rule; /// /// An Event Proxy Emitter that can be restricted by a . /// /// The type of data for the event. /// The event that is emitted. public abstract class RestrictableSingleEventProxyEmitter : SingleEventProxyEmitter where TEvent : UnityEvent, new() { [Tooltip("Determines whether the received payload is valid to be re-emitted.")] [SerializeField] private RuleContainer receiveValidity; /// /// Determines whether the received payload is valid to be re-emitted. /// public RuleContainer ReceiveValidity { get { return receiveValidity; } set { receiveValidity = value; } } /// /// Gets the target for the validity check. /// /// The target to check on. protected abstract object GetTargetToCheck(); /// /// Clears . /// public virtual void ClearReceiveValidity() { if (!this.IsValidState()) { return; } ReceiveValidity = default; } /// protected override bool IsValid() { return base.IsValid() && ReceiveValidity.Accepts(GetTargetToCheck()); } } }