using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace BITKit.Entities.VFX { public class EntityVFXPlayer : EntityBehavior { [SerializeReference,SubclassSelector] private IReference[] vfxReferences; [SerializeField] private VFXPlayer vfxPlayer; private readonly List keyWords=new(); public override void OnAwake() { base.OnAwake(); keyWords.AddRange(vfxReferences.Select(x=>x.Value)); UnityEntity.AddListener(Constant.Animation.Play, Play); } private void Play(string animationName) { try { if (isActiveAndEnabled is false) return; if (keyWords.Contains(animationName) is false) return; vfxPlayer.Execute(); } catch (Exception e) { Debug.LogWarning(transform.name); Debug.LogException(e); } } } }