using mh; using System.Collections; using System.Collections.Generic; using UnityEngine; public class FastBoxCollider : MonoBehaviour, IQuadTreeObject { [SerializeField] private ColliderType m_Type; [SerializeField] private Vector2 m_Offset; [SerializeField] private Vector2 m_Size; public Vector2 center { get { Vector3 pos = transform.position + m_Offset.ToVector3(); return pos; } } public Vector2 offset => m_Offset; public Vector2 size => m_Size; public Vector4 bound { get { Vector3 pos = transform.position + m_Offset.ToVector3(); Vector4 b = new Vector4(); b.x = pos.x; b.y = pos.y; b.z = size.x; b.w = size.y; return b; } } public Vector4 box { get { Vector2 c = center; Vector4 b = new Vector4(); b.x = c.x; b.y = c.y; b.z = size.x; b.w = size.y; return b; } } public void Awake() { if (m_Type == ColliderType.Collider) { PhysicsManager.Instance.AddCollider(this); } else if (m_Type == ColliderType.Hurtbox) { PhysicsManager.Instance.AddHurtboxes(this); } } public void OnDestroy() { if (m_Type == ColliderType.Collider) { PhysicsManager.Instance.RemoveCollider(this); } else if (m_Type == ColliderType.Hurtbox) { PhysicsManager.Instance.RemoveHurtbox(this); } } private void OnDrawGizmos() { Color c = Gizmos.color; if(m_Type == ColliderType.Hurtbox) { Gizmos.color = Color.red; } Gizmos.DrawWireCube(transform.position + m_Offset.ToVector3(), m_Size.ToVector3()); Gizmos.color = c; } }