namespace Zinnia.Action
{
using System;
using UnityEngine;
using UnityEngine.Events;
using Zinnia.Extension;
///
/// Emits a value.
///
public class Vector2Action : Action
{
///
/// Defines the event with the state.
///
[Serializable]
public class UnityEvent : UnityEvent { }
[Tooltip("The tolerance of equality between two Vector2 values.")]
[SerializeField]
private float equalityTolerance = float.Epsilon;
///
/// The tolerance of equality between two values.
///
public float EqualityTolerance
{
get
{
return equalityTolerance;
}
set
{
equalityTolerance = value;
if (this.IsMemberChangeAllowed())
{
OnAfterEqualityToleranceChange();
}
}
}
///
protected override bool IsValueEqual(Vector2 value)
{
return Value.ApproxEquals(value, EqualityTolerance);
}
///
protected override bool ShouldActivate(Vector2 value)
{
return !DefaultValue.ApproxEquals(value, EqualityTolerance);
}
///
/// Called after has been changed.
///
protected virtual void OnAfterEqualityToleranceChange()
{
Receive(Value);
}
}
}