40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using Animancer;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
public class PlayerVisual : MonoBehaviour
|
|
{
|
|
[SerializeField] NamedAnimancerComponent animancer;
|
|
|
|
[SerializeField] private INFO _playerInfo;
|
|
|
|
|
|
private void PlayActionEventHandler(PlayActionEvent @event)
|
|
{
|
|
BrewMonster.Logger.Log("PlayActionEventHandler : "+@event.AnimationName);
|
|
animancer.TryPlay(@event.AnimationName);
|
|
}
|
|
|
|
public void InitHostPlayerEventDoneHandler()
|
|
{
|
|
animancer = GetComponentInChildren<NamedAnimancerComponent>();
|
|
if(animancer == null)
|
|
{
|
|
BrewMonster.Logger.LogError("animancer == null");
|
|
return;
|
|
}
|
|
var player = GetComponentInParent<EC_Player>();
|
|
if(player == null)
|
|
{
|
|
BrewMonster.Logger.LogError("player == null");
|
|
return;
|
|
}
|
|
_playerInfo = player.GetPlayInfo();
|
|
EventBus.SubscribeChannel<PlayActionEvent>(_playerInfo.cid, PlayActionEventHandler);
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
EventBus.UnsubscribeAllInChannel(_playerInfo.cid);
|
|
}
|
|
}
|