summaryrefslogtreecommitdiff
path: root/marching/Assets/Scripts/Physics/FastBoxCollider.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-05-09 10:17:45 +0800
committerchai <215380520@qq.com>2023-05-09 10:17:45 +0800
commitc35533e31efe30121a7c61a725fdaaba47714296 (patch)
treeb25bc22f00911f376c741b89b0591d2d48565e79 /marching/Assets/Scripts/Physics/FastBoxCollider.cs
parentd2a574ba76c56c340d8ac0ad841344664bc2cc59 (diff)
*misc
Diffstat (limited to 'marching/Assets/Scripts/Physics/FastBoxCollider.cs')
-rw-r--r--marching/Assets/Scripts/Physics/FastBoxCollider.cs66
1 files changed, 58 insertions, 8 deletions
diff --git a/marching/Assets/Scripts/Physics/FastBoxCollider.cs b/marching/Assets/Scripts/Physics/FastBoxCollider.cs
index 4f20b81..7b52caf 100644
--- a/marching/Assets/Scripts/Physics/FastBoxCollider.cs
+++ b/marching/Assets/Scripts/Physics/FastBoxCollider.cs
@@ -1,18 +1,68 @@
+using mh;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
-public class FastBoxCollider : MonoBehaviour
+public class FastBoxCollider : MonoBehaviour, IQuadTreeObject
{
- // Start is called before the first frame update
- void Start()
+
+ [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 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);
+ }
}
- // Update is called once per frame
- void Update()
+ private void OnDrawGizmos()
{
-
+ Gizmos.DrawWireCube(transform.position + m_Offset.ToVector3(), m_Size.ToVector3());
}
-}
+
+} \ No newline at end of file