namespace Zinnia.Tracking.Collision.Active.Event.Proxy
{
using System;
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Event.Proxy;
using Zinnia.Extension;
using Zinnia.Tracking.Collision.Active;
///
/// Emits a UnityEvent with a payload whenever the Receive method is called.
///
public class ActiveCollisionConsumerEventProxyEmitter : RestrictableSingleEventProxyEmitter
{
///
/// The types of that can be used for the rule source.
///
public enum RuleSourceType
{
///
/// Use the for the rule.
///
PublisherContainer,
///
/// Use the for the rule.
///
SourceContainer
}
[Tooltip("The source GameObject to apply to the RestrictableSingleEventProxyEmitter.ReceiveValidity.")]
[SerializeField]
private RuleSourceType ruleSource;
///
/// The source to apply to the .
///
public RuleSourceType RuleSource
{
get
{
return ruleSource;
}
set
{
ruleSource = value;
}
}
///
/// Defines the event with the specified state.
///
[Serializable]
public class UnityEvent : UnityEvent { }
///
/// Sets the .
///
/// The index of the .
public virtual void SetRuleSource(int index)
{
RuleSource = EnumExtensions.GetByIndex(index);
}
///
protected override object GetTargetToCheck()
{
switch (RuleSource)
{
case RuleSourceType.PublisherContainer:
return Payload?.Publisher?.PublisherContainer;
case RuleSourceType.SourceContainer:
return Payload?.Publisher.SourceContainer;
}
return null;
}
}
}