done else player animation

This commit is contained in:
VDH
2025-09-22 12:15:11 +07:00
parent 0dd73da3c4
commit a995887904
9 changed files with 84 additions and 34 deletions
+15 -9
View File
@@ -5,11 +5,9 @@ using UnityEngine;
public class PlayerVisual : MonoBehaviour
{
[SerializeField] NamedAnimancerComponent animancer;
private void Awake()
{
EventBus.Subscribe<InitHostPlayerEventDone>(InitHostPlayerEventDoneHandler);
EventBus.Subscribe<PlayActionEvent>(PlayActionEventHandler);
}
[SerializeField] private INFO _playerInfo;
private void PlayActionEventHandler(PlayActionEvent @event)
{
@@ -17,17 +15,25 @@ public class PlayerVisual : MonoBehaviour
animancer.TryPlay(@event.AnimationName);
}
private void InitHostPlayerEventDoneHandler(InitHostPlayerEventDone done)
public void InitHostPlayerEventDoneHandler()
{
animancer = GetComponentInChildren<NamedAnimancerComponent>();
if(animancer == null)
{
BrewMonster.Logger.Log("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.Unsubscribe<InitHostPlayerEventDone>(InitHostPlayerEventDoneHandler);
EventBus.Unsubscribe<PlayActionEvent>(PlayActionEventHandler);
EventBus.UnsubscribeAllInChannel(_playerInfo.cid);
}
}