1
This commit is contained in:
@@ -6,22 +6,29 @@ using BITKit.Animations;
|
||||
using BITKit.Entities;
|
||||
namespace BITFALL.Entites
|
||||
{
|
||||
public class EntityProxyCharacter : EntityComponent, IHealthCallback
|
||||
public class EntityProxyCharacter : EntityComponent
|
||||
{
|
||||
public UnityAnimator animator;
|
||||
[SerializeReference, SubclassSelector] public References _getDamage;
|
||||
[SerializeField] private Optional<Collider> aliveCollider = new();
|
||||
[Inject]
|
||||
private IHealth _health;
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
entity.RegisterCallback<IHealthCallback>(this);
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
}
|
||||
|
||||
public void OnSetAlive(bool alive)
|
||||
{
|
||||
|
||||
if (aliveCollider.Allow)
|
||||
aliveCollider.Value.enabled = alive;
|
||||
}
|
||||
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
if (_getDamage is null || animator is null) return;
|
||||
animator.animator.Play(_getDamage,-1,0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user