43 lines
1.2 KiB
C#
43 lines
1.2 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;
|
|
|
|
return namedAnimancer.TryPlay("慢速移动") == null;
|
|
}
|
|
public void InitNPCEventDoneHandler()
|
|
{
|
|
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
|
|
if (namedAnimancer == null)
|
|
{
|
|
BrewMonster.Logger.LogError("animancer == null");
|
|
return;
|
|
}
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
|
|
}
|
|
public bool IsAnimationExist(string animationName)
|
|
{
|
|
if (namedAnimancer == null) return false;
|
|
return namedAnimancer.States.TryGet(animationName, out var existingState) ? true : false;
|
|
}
|
|
public bool IsPlayAnimation()
|
|
{
|
|
if (namedAnimancer == null) return false;
|
|
return namedAnimancer.IsPlaying();
|
|
}
|
|
public bool IsPlayAnimation(string animationName)
|
|
{
|
|
if (namedAnimancer == null) return false;
|
|
return namedAnimancer.IsPlaying(animationName);
|
|
}
|
|
}
|