Attempt2/lib/components/Hitbox_Component.gd

19 lines
747 B
GDScript

extends Area2D
export(int) var damage_amount = 0
func set_hitbox(enabled: bool):
for child in get_children():
if child is CollisionShape2D:
child.set_deferred("disabled", !enabled)
## TODO: This breaks now I guess because I moved the process functions out to parent class
#player_hurtbox.set_deferred("disabled", !enabled) #WTF Apparently this is how to do it
func _on_Hitbox_Component_area_shape_entered(area_rid, area, area_shape_index, local_shape_index):
var colliding_node = area.get_parent()
if colliding_node.has_node("Hurtbox_Component"):
colliding_node.get_node("Hurtbox_Component").on_hit(self)
else:
print(owner.name, ": Attempted to Hit an unready node, no Hurtbox_Component reciever node in ", colliding_node.name)