Files
test/Assets/PerfectWorld/Scripts/NPC/NPCVisual.cs
T
NguyenVanDat ed29158a25 adjust st
2025-10-07 10:34:50 +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.BMLogger.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);
}
}