This commit is contained in:
CortexCore
2023-10-20 19:31:12 +08:00
parent 5cd094ed9a
commit a160813262
1878 changed files with 630581 additions and 4485 deletions

View File

@@ -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);
}
}