extends ShapeCast3D

func deal_damage(damage: float, crit_chance: float) -> void:
	for collision_id in get_collision_count():
		var is_critical: bool = randf() <= crit_chance
		var collider: Object = get_collider(collision_id)

		if collider is Player:
			var protection: float = collider.ui.inventory.get_armor_protection() / 100.0
			var damage_reduction: float = damage * protection
			damage -= damage_reduction
			collider.health_component.take_damage(damage, is_critical)
		elif collider is Enemy:
			collider.health_component.take_damage(damage, is_critical)
