45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Animancer;
|
|
using BrewMonster;
|
|
using UnityEngine;
|
|
|
|
public class NPCVisual : MonoBehaviour
|
|
{
|
|
[SerializeField] NamedAnimancerComponent namedAnimancer;
|
|
public bool TryPlayAction(string animationName)
|
|
{
|
|
BMLogger.LogError("HoangDev: TryPlayAction: " + animationName);
|
|
if (namedAnimancer == null) return false;
|
|
if (namedAnimancer.IsPlaying(animationName)) return false;
|
|
|
|
return namedAnimancer.TryPlay(animationName) == 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);
|
|
}
|
|
}
|