#if INVECTOR_PLAYABLESANIMATOR
using InvectorCore;
using UnityEngine;
namespace Invector.vMelee
{
///
/// Holds the rolled attack index for the PlayablesAnimator and exposes it as a PDM condition,
/// replacing the animator.SetInteger("RandomAttack", ...) parameter the Animator
/// Controller version of writes.
///
///
/// A PDM context is rebuilt from its providers every tick, so a state behaviour cannot write a
/// value into it directly and expect it to survive. The value has to live on a component that
/// the context collects from, which is what this is. Attach it next to the PlayablesAnimator and
/// reference vPlayablesRandomAttack.RandomAttack in the attack rows' conditions.
///
[vClassHeader("Playables Random Attack", "Rolled by vRandomAttackBehaviourPDM on state enter.")]
public class vPlayablesRandomAttack : vMonoBehaviour
{
[SerializeField, vReadOnly] private int randomAttack;
[ExposeCondition("Index rolled by vRandomAttackBehaviourPDM when an attack state starts.")]
public float RandomAttack => randomAttack;
public void Roll(int attackCount)
{
randomAttack = attackCount > 0 ? Random.Range(0, attackCount) : 0;
}
}
}
#endif