Files
test/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs
T
2025-10-01 15:07:18 +07:00

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);
}
}