using KitsuneCafe.Sys.Attributes; using R3; using UnityEngine; namespace KitsuneCafe.Entity { public class DummyAnimator : MonoBehaviour { [SerializeField] private Health health; [SerializeField] private Animator animator; [SerializeField, AnimatorParam("animator")] private int hitParam; [SerializeField, AnimatorParam("animator")] private int deathParam; private void OnValidate() { if (animator == null) { animator = GetComponent(); } if (health == null) { health = GetComponent(); } } private void Start() { Observable.FromEventHandler( e => health.HealthChanged += e, e => health.HealthChanged -= e ) .Select(ev => ev.e) .Subscribe(e => { if (e.Current > 0) { animator.SetBool(hitParam, true); } else { animator.SetBool(deathParam, true); } }) .AddTo(this); } } }