extends Node
class_name CharacterWrapper

@export var die_script: GDScript = null
var owner_placeholder: Node3D = null

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	# Characters should be always controlled by the server and synced accross client
	# The owner should be responsible for the syncronization, since this node is 
	# just a dummy that is following the controller
	set_multiplayer_authority(1)
	
	pass # Replace with function body.

# Set the owner placeholder, so the characters can send the requests to a node
# it depends on
func set_owner_placeholder(owner: Node3D):
	owner_placeholder = owner
	
func die(): 
	push_warning("TODO: Implement ragdoll kind of dying and respawn character as an object")
	queue_free()


func _on_area_body_part_hit(damage: int) -> void:
	# The owner node should be aware of how to take damage, so we need to
	# pass the value.
	if owner_placeholder:
		if owner_placeholder.has_method("take_damage"):
			owner_placeholder.take_damage(damage)
		else:
			push_warning("Node doesn't know how to take the damage")