]> purplebirdman git - frog-ninja.git/blobdiff - asset/character/model/hitbox.gd
Squashed commit of the following:
[frog-ninja.git] / asset / character / model / hitbox.gd
index 532f987d61cf87c43284d310b5f799268cba25fb..0a20654ba4d9fadb1cbfab0576efb7c1f4ccc5d4 100644 (file)
@@ -5,8 +5,6 @@ class_name Hitbox
 @export var debug_color_hit: Color = Color(Color.YELLOW, 0.5)
 @export var debug_color_standby: Color = Color(Color.GREEN, 0.5)
 
-
-@onready var model: CharacterModel = $"../.."
 @onready var shape: CollisionShape3D = $CollisionShape3D
 @onready var hit_effect: HitEffect = $HitEffect
 
@@ -18,13 +16,13 @@ func _ready() -> void:
 
 
 func _process(delta: float) -> void:
-       for area in get_overlapping_areas():
-               if area is Hurtbox:
-                       on_hit(area)
+       if monitoring:
+               for area in get_overlapping_areas():
+                       if area is Hurtbox:
+                               on_hit(area)
                
        _last_hit += delta
        if _last_hit > 1.0:
-               # TODO: all these guys share the same collision shape
                shape.debug_color = debug_color_standby
 
 
@@ -34,12 +32,14 @@ func on_hit(area: Hurtbox):
                shape.debug_color = debug_color_hit
                hit_effect.trigger()
                
-               
                area.ignore_list.append(self)
-               var hit_pkt := area.get_hit_packet()
-               model.current_state.react_to_hit(hit_pkt)
-               hit_pkt.queue_free()
+               on_successful_hit(area)
 
 
 func is_being_attacked_by(area: Hurtbox):
        return area.is_attacking and not area.ignore_list.has(self)
+
+
+## To be overridden by a child class
+func on_successful_hit(_area: Hurtbox):
+       pass