extends Node

signal player_dead(player: Player)

var _cached_player_controller: PlayerController
var _cached_player: Player

## player controller進入tree會注冊自己到Global
func register_player_controller(pc: PlayerController) -> PlayerController:
	if not pc: return null
	
	_cached_player_controller = pc
	return _cached_player_controller

## player進入tree會注冊自己到Global
func register_player(player: Player) -> Player:
	if not player: return null
	
	_cached_player = player
	return _cached_player

## 外部快速获取Player
func get_player() -> Player:
	return _cached_player

## 外部快速获取Player Controller
func get_player_controller() -> PlayerController:
	return _cached_player_controller

## 外部用于监听Player死亡
func boradcast_player_dead_event(player:Player) -> void:
	player_dead.emit(player)
