namespace Zinnia.Cast.Event.Proxy { using System; using UnityEngine; using UnityEngine.Events; using Zinnia.Event.Proxy; using Zinnia.Extension; /// /// Emits a with a payload whenever is called. /// public class PointsCastEventProxyEmitter : RestrictableSingleEventProxyEmitter { /// /// The types of that can be used for the rule source. /// public enum RuleSourceType { /// /// Use the actual hit as the source for the rule. /// Collider, /// /// Use the parent hit as the target for the rule. /// Rigidbody } [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 { } /// protected override object GetTargetToCheck() { if (Payload == null || Payload.HitData == null) { return null; } RaycastHit hitData = (RaycastHit)Payload.HitData; switch (RuleSource) { case RuleSourceType.Collider: return hitData.collider.gameObject; case RuleSourceType.Rigidbody: return hitData.collider.GetContainingTransform().gameObject; } return null; } } }