This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -4,15 +4,52 @@ using UnityEngine;
using BITKit;
namespace BITKit.Entities
{
public class EntityHitbox : EntityBehavior,IDamagable
public class EntityHitbox : MonoBehaviour,IDamagable
{
IUnityEntity IDamagable.UnityEntity => UnityEntity;
public Rigidbody Rigidbody => m_rigidbody;
public IHealth Health
{
get
{
EnsureConfigure();
return _health;
}
}
public IUnityEntity UnityEntity
{
get
{
EnsureConfigure();
return _unityEntity;
}
}
public Rigidbody Rigidbody
{
get=>m_rigidbody;
set=>m_rigidbody=value;
}
public void GiveDamage(DamageMessage message)
{
UnityEntity.Invoke(message);
if (_unityEntity is not null)
UnityEntity.Invoke(message);
}
[SerializeField]private Rigidbody m_rigidbody;
[Inject(true)]
private IHealth _health;
private IUnityEntity _unityEntity;
private bool _initialized;
private void EnsureConfigure()
{
if (_initialized) return;
_unityEntity = GetComponentInParent<IUnityEntity>(true);
_unityEntity?.Inject(this);
_initialized = true;
}
}
}