namespace Zinnia.Cast.Operation.Extraction
{
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Data.Operation.Extraction;
///
/// Extracts and emits the concrete implementation for data derrived from the .
///
/// The result type.
/// The unity event to emit.
/// The event element type.
public abstract class PointsCastEventDataExtractor : ValueExtractor where TEvent : UnityEvent, new()
{
///
/// The validity state the event data needs to be in to extract.
///
public enum ExtractionState
{
///
/// Ignore the validity setting and always extract.
///
AlwaysExtract,
///
/// Only extract when the event data is not valid.
///
OnlyWhenNotValid,
///
/// Only extract when the event data is valid.
///
OnlyWhenValid
}
[Tooltip("The validity state of the event data to determine whether to extract or not.")]
[SerializeField]
private ExtractionState extractWhen = ExtractionState.AlwaysExtract;
///
/// The validity state of the event data to determine whether to extract or not.
///
public ExtractionState ExtractWhen
{
get
{
return extractWhen;
}
set
{
extractWhen = value;
}
}
///
/// Determines if the extraction can be executed.
///
/// Whether to execute the extraction.
protected virtual bool CanExtract()
{
switch (ExtractWhen)
{
case ExtractionState.AlwaysExtract:
return true;
case ExtractionState.OnlyWhenNotValid:
return !Source.IsValid;
case ExtractionState.OnlyWhenValid:
return Source.IsValid;
}
return false;
}
}
}