36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Animancer;
|
|
using UnityEngine;
|
|
|
|
public class NPCVisual : MonoBehaviour
|
|
{
|
|
[SerializeField] NamedAnimancerComponent namedAnimancer;
|
|
|
|
public bool TryPlayAction(string animationName)
|
|
{
|
|
if(namedAnimancer == null) return false;
|
|
if(namedAnimancer.IsPlaying(animationName)) return false;
|
|
BrewMonster.Logger.LogError("TryPlayAction "+ animationName);
|
|
|
|
return namedAnimancer.TryPlay(animationName) == null;
|
|
}
|
|
public void InitNPCEventDoneHandler()
|
|
{
|
|
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
|
|
if (namedAnimancer == null)
|
|
{
|
|
BrewMonster.Logger.LogError("animancer == null");
|
|
return;
|
|
}
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
|
|
}
|
|
public bool IsAnimationExist(string animationName)
|
|
{
|
|
return namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false;
|
|
}
|
|
public bool IsPlayAnimation() => namedAnimancer.IsPlaying();
|
|
public bool IsPlayAnimation(string animationName) => namedAnimancer.IsPlaying(animationName);
|
|
}
|