using System.Collections; using System.Collections.Generic; using UnityEngine; using BITKit; namespace BITKit.Entities { public class EntityHitbox : MonoBehaviour,IDamagable { public string Tag => tag is null ? base.tag : tag.Value; 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) { if (_unityEntity is not null) UnityEntity.Invoke(message); } [SerializeField]private Rigidbody m_rigidbody; [SerializeReference, SubclassSelector] private new IReference tag; [Inject(true)] private IHealth _health; private IUnityEntity _unityEntity; private bool _initialized; private void EnsureConfigure() { if (_initialized) return; _unityEntity = GetComponentInParent(true); _unityEntity?.Inject(this); _initialized = true; } } }