Files
test/Assets/Scripts/PlayerVisual.cs
T
hoangvd 38a12bd3fa revert 439722a8c4
revert Merge pull request 'feature/movement' (#22) from feature/movement into develop

Reviewed-on: https://git.brew.monster/Unity/perfect-world-unity/pulls/22

mất package
2025-10-09 11:06:44 +00:00

44 lines
1.3 KiB
C#

using Animancer;
using System;
using UnityEngine;
public class PlayerVisual : MonoBehaviour
{
[SerializeField] NamedAnimancerComponent namedAnimancer;
[SerializeField] private INFO _playerInfo;
private void PlayActionEventHandler(PlayActionEvent @event)
{
BrewMonster.BMLogger.Log("PlayActionEventHandler : "+@event.AnimationName);
namedAnimancer.TryPlay(@event.AnimationName);
}
public void InitHostPlayerEventDoneHandler()
{
namedAnimancer = GetComponentInChildren<NamedAnimancerComponent>();
if(namedAnimancer == null)
{
BrewMonster.BMLogger.LogError("animancer == null");
return;
}
var player = GetComponentInParent<EC_Player>();
if(player == null)
{
BrewMonster.BMLogger.LogError("player == null");
return;
}
_playerInfo = player.GetPlayInfo();
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
}
private void OnDestroy()
{
EventBus.UnsubscribeAllInChannel(_playerInfo.cid);
}
public bool IsAnimationExist(string animationName)
{
return namedAnimancer.States.TryGet("ActionName", out var existingState) ? true : false;
}
}