38 lines
995 B
C#
38 lines
995 B
C#
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<string> keyWords=new();
|
|
public override void OnAwake()
|
|
{
|
|
base.OnAwake();
|
|
keyWords.AddRange(vfxReferences.Select(x=>x.Value));
|
|
UnityEntity.AddListener<string>(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);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|