using UnityEngine; namespace SpecialMoveCards { /// /// Decouples PlayerPocket from AnimationManager or direct Animator usage. /// Prefers AnimationManager if present, else falls back to Animator trigger/state. /// [RequireComponent(typeof(Animator))] public class SpecialAnimationBridge : MonoBehaviour { private AnimationManager animManager; // existing class in project private Animator animator; private void Awake() { animator = GetComponent(); animManager = GetComponent(); } /// /// Play a special move by animation trigger/state name. /// public void PlaySpecialMove(string triggerOrState) { if (string.IsNullOrEmpty(triggerOrState)) { Debug.LogWarning("PlaySpecialMove called with empty name"); return; } if (animManager != null) { // AnimationManager will CrossFade by clip/state name animManager.PlayAnimation(triggerOrState); return; } // Fallback: try to SetTrigger if such a parameter exists. Else CrossFade. if (animator == null) return; int paramCount = animator.parameterCount; bool hasTrigger = false; for (int i = 0; i < paramCount; i++) { var p = animator.GetParameter(i); if (p.type == AnimatorControllerParameterType.Trigger && p.name == triggerOrState) { hasTrigger = true; break; } } if (hasTrigger) animator.SetTrigger(triggerOrState); else animator.CrossFade(triggerOrState, 0.1f, 0, 0); } } }