BITFALL/Assets/BITKit/Unity/Scripts/Entity/Components/VFX/EntityVFXPlayer.cs

28 lines
808 B
C#
Raw Normal View History

2023-10-29 15:27:13 +08:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace BITKit.Entities.VFX
{
2023-10-30 01:25:53 +08:00
public class EntityVFXPlayer : EntityBehavior
2023-10-29 15:27:13 +08:00
{
[SerializeReference,SubclassSelector] private IReference[] vfxReferences;
[SerializeField] private VFXPlayer vfxPlayer;
private readonly List<string> keyWords=new();
public override void OnAwake()
{
base.OnAwake();
keyWords.AddRange(vfxReferences.Select(x=>x.Value));
2023-10-30 01:25:53 +08:00
UnityEntity.AddListener<string>(Constant.Animation.Play, Play);
2023-10-29 15:27:13 +08:00
}
private void Play(string animationName)
{
if (isActiveAndEnabled is false) return;
if (keyWords.Contains(animationName) is false) return;
vfxPlayer.Execute();
}
}
}