Skip to content

Commit 40bcbbb

Browse files
add action_applied signals
1 parent ead59f0 commit 40bcbbb

File tree

14 files changed

+118
-116
lines changed

14 files changed

+118
-116
lines changed

addons/gdUnit4/GdUnitRunner.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"included":{"res://test/":[]},"server_port":31003,"skipped":{},"version":"1.0"}
1+
{"included":{"res://test/":[]},"server_port":31002,"skipped":{},"version":"1.0"}

addons/health_hitbox_hurtbox/2d/hit_box_2d/hit_box_2d.gd

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ class_name HitBox2D extends Area2D
22
## [HitBox2D] is associated with an object that can collide with a [HurtBox2D].
33

44
## emitted when collision with [HitBox2D] detected.
5-
## Can be used to detect collision with projectiles.
65
signal hit_box_entered(hit_box: HitBox2D)
76
## emitted when collision with [HurtBox2D] detected.
87
signal hurt_box_entered(hurt_box: HurtBox2D)
8+
## emitted after the action is applied to a [HurtBox2D].
9+
signal action_applied(hurt_box: HurtBox2D)
910
## emitted when collision with [Area2D] that isn't [HitBox2D] or [HurtBox2D].
1011
## Can be using to detect things like environment.
1112
signal unknown_area_entered(area: Area2D)
@@ -41,18 +42,15 @@ func _on_area_entered(area: Area2D) -> void:
4142
return
4243

4344
var hurt_box: HurtBox2D = area
44-
_hit_hurt_box(hurt_box)
4545
hurt_box_entered.emit(hurt_box)
46+
_apply_action(hurt_box)
47+
action_applied.emit(hurt_box)
4648

4749

4850
## Perfomes the [Health.Action] on the specified [HurtBox2D].
49-
func _hit_hurt_box(hurt_box: HurtBox2D) -> void:
51+
func _apply_action(hurt_box: HurtBox2D) -> void:
5052
match action:
5153
Health.Action.DAMAGE:
5254
hurt_box.damage(amount)
5355
Health.Action.HEAL:
5456
hurt_box.heal(amount)
55-
56-
57-
## Returns the object's class name as a [String].
58-
func get_class() -> String: return "HitBox2D"

addons/health_hitbox_hurtbox/2d/hit_scan_2d/hit_scan_2d.gd

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ class_name HitScan2D extends RayCast2D
33
## HitScan2D interacts with [HurtBox2D] to affect [Health] components.
44

55
## emitted when collision with [HitBox2D] detected.
6-
## To cancel each other the [HitBox2D] will have to be [color=orange]queue_free()[/color]
7-
## from hear because collision detection is one sided.
86
signal hit_box_entered(hit_box: HitBox2D)
97
## emitted when collision with [HurtBox2D] detected.
108
signal hurt_box_entered(hurt_box: HurtBox2D)
9+
## emitted after the action is applied to a [HurtBox2D].
10+
signal action_applied(hurt_box: HurtBox2D)
1111
## emitted when collision with [Area2D] that isn't [HitBox2D] or [HurtBox2D].
1212
## Used to detect things like environment.
1313
signal unknown_area_entered(area: Area2D)
@@ -58,14 +58,15 @@ func fire() -> void:
5858
return
5959

6060
var hurt_box: HurtBox2D = collider
61+
hurt_box_entered.emit(hurt_box)
62+
_apply_action(hurt_box)
63+
action_applied.emit(hurt_box)
64+
65+
66+
## Perfomes the [Health.Action] on the specified [HurtBox2D].
67+
func _apply_action(hurt_box: HurtBox2D) -> void:
6168
match action:
6269
Health.Action.DAMAGE:
6370
hurt_box.damage(amount)
6471
Health.Action.HEAL:
6572
hurt_box.heal(amount)
66-
67-
hurt_box_entered.emit(hurt_box)
68-
69-
70-
## Returns the object's class name as a [String].
71-
func get_class() -> String: return "HitScan2D"

addons/health_hitbox_hurtbox/2d/hurt_box_2d/hurt_box_2d.gd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,3 @@ func _get_configuration_warnings() -> PackedStringArray:
6464
warnings.append("This node requires a 'Health' component")
6565

6666
return warnings
67-
68-
69-
## Returns the object's class name as a [String].
70-
func get_class() -> String: return "HurtBox2D"

addons/health_hitbox_hurtbox/3d/hit_box_3d/hit_box_3d.gd

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class_name HitBox3D extends Area3D
55
signal hit_box_entered(hit_box: HitBox3D)
66
## emitted when collision with [HurtBox3D] detected.
77
signal hurt_box_entered(hurt_box: HurtBox3D)
8+
## emitted after the action is applied to a [HurtBox3D].
9+
signal action_applied(hurt_box: HurtBox3D)
810
## emitted when collision with [Area3D] that isn't [HitBox3D] or [HurtBox3D].
911
## Can be using to detect things like environment.
1012
signal unknown_area_entered(area: Area3D)
@@ -40,18 +42,15 @@ func _on_area_entered(area: Area3D) -> void:
4042
return
4143

4244
var hurt_box: HurtBox3D = area
43-
_hit_hurt_box(hurt_box)
4445
hurt_box_entered.emit(hurt_box)
46+
_apply_action(hurt_box)
47+
action_applied.emit(hurt_box)
4548

4649

4750
## Perfomes the [Health.Action] on the specified [HurtBox3D].
48-
func _hit_hurt_box(hurt_box: HurtBox3D) -> void:
51+
func _apply_action(hurt_box: HurtBox3D) -> void:
4952
match action:
5053
Health.Action.DAMAGE:
5154
hurt_box.damage(amount)
5255
Health.Action.HEAL:
5356
hurt_box.heal(amount)
54-
55-
56-
## Returns the object's class name as a [String].
57-
func get_class() -> String: return "HitBox3D"

addons/health_hitbox_hurtbox/3d/hit_scan_3d/hit_scan_3d.gd

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ class_name HitScan3D extends RayCast3D
33
## HitScan3D interacts with [HurtBox3D] to affect [Health] components.
44

55
## emitted when collision with [HitBox3D] detected.
6-
## To cancel each other the [HitBox3D] will have to be [color=orange]queue_free()[/color]
7-
## from hear because collision detection is one sided.
86
signal hit_box_entered(hit_box: HitBox3D)
97
## emitted when collision with [HurtBox3D] detected.
108
signal hurt_box_entered(hurt_box: HurtBox3D)
9+
## emitted after the action is applied to a [HurtBox3D].
10+
signal action_applied(hurt_box: HurtBox3D)
1111
## emitted when collision with [Area3D] that isn't [HitBox3D] or [HurtBox3D].
1212
## Used to detect things like environment.
1313
signal unknown_area_entered(area: Area3D)
@@ -58,14 +58,15 @@ func fire() -> void:
5858
return
5959

6060
var hurt_box: HurtBox3D = collider
61+
hurt_box_entered.emit(hurt_box)
62+
_apply_action(hurt_box)
63+
action_applied.emit(hurt_box)
64+
65+
66+
## Perfomes the [Health.Action] on the specified [HurtBox3D].
67+
func _apply_action(hurt_box: HurtBox3D) -> void:
6168
match action:
6269
Health.Action.DAMAGE:
6370
hurt_box.damage(amount)
6471
Health.Action.HEAL:
6572
hurt_box.heal(amount)
66-
67-
hurt_box_entered.emit(hurt_box)
68-
69-
70-
## Returns the object's class name as a [String].
71-
func get_class() -> String: return "HitScan3D"

addons/health_hitbox_hurtbox/3d/hurt_box_3d/hurt_box_3d.gd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,3 @@ func _get_configuration_warnings() -> PackedStringArray:
6363
warnings.append("This node requires a 'Health' component")
6464

6565
return warnings
66-
67-
68-
## Returns the object's class name as a [String].
69-
func get_class() -> String: return "HurtBox3D"

addons/health_hitbox_hurtbox/health/health.gd

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const DEFAULT_MAX = 100
5959
# reduce current in game so it is not greater than max
6060
current = mini(current, max)
6161

62-
6362
@export_group("Conditions")
6463
## Enable if entity is capable of taking damage.
6564
@export var damageable: bool = true
@@ -173,7 +172,3 @@ func heal(amount: int, multiplier: float = 1.0) -> void:
173172
if notify_revived:
174173
print_debug("%s revived" % entity)
175174
revived.emit(entity)
176-
177-
178-
## Returns the object's class name as a [String].
179-
func get_class() -> String: return "Health"

addons/health_hitbox_hurtbox/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
name="Health, HitBoxes, HurtBoxes, and HitScans"
44
description="2D and 3D Components to manage health, damage, and healing"
55
author="ClutteredCode"
6-
version="4.1.0"
6+
version="4.2.0"
77
script="plugin.gd"

0 commit comments

Comments
 (0)