extends Area2D
class_name BridgeArea

var character_body: Node2D = null
var is_character_on_bridge: bool = false

func _on_body_entered(_body: Node2D) -> void:
	#_body.update_collision_layer_mask("in")
	self._set_character_body_on_bridge(_body, true)

func _on_body_exited(_body: Node2D) -> void:
	#_body.update_collision_layer_mask("out")
	self._set_character_body_on_bridge(_body, false)

func _set_character_body_on_bridge(_body: Node2D, _state: bool) -> void:
	if _body is BaseCharacter:
		self.character_body = _body
		self.is_character_on_bridge = _state
		print("on bridge: " + str(_state))

func get_character_body_on_bridge() -> bool:
	return self.is_character_on_bridge
	
func get_body() -> Node2D:
	return self.character_body
