namespace Zinnia.Event.Proxy
{
using System;
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Data.Type;
using Zinnia.Extension;
///
/// Emits a with a payload whenever is called.
///
public class SurfaceDataProxyEmitter : RestrictableSingleEventProxyEmitter
{
///
/// The types of that can be used for the rule source.
///
public enum RuleSourceType
{
///
/// Use the as the source for the rule.
///
Source,
///
/// Use the as the target for the rule.
///
Target
}
[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.Source:
return Payload?.Transform != null ? Payload?.Transform.gameObject : null;
case RuleSourceType.Target:
return Payload?.CollisionData.transform != null ? Payload?.CollisionData.transform.gameObject : null;
}
return null;
}
}
}