extends Spatial

onready var animation_player = get_node("CharacterModel/AnimationPlayer")
onready var characters = [
	get_node("CharacterModel/Rogue"),
	get_node("CharacterModel/Worker"),
	get_node("CharacterModel/Barbarian"),
	get_node("CharacterModel/Knight"),
	get_node("CharacterModel/Mage"),
]

export var ROGUE_LEVEL = 0
export var MAX_LEVEL = 4

var active = false

# character level, ROGUE_LEVEL for rogue
var level = 1

func set_character_visibility(character_is_visible : bool):
	characters[level].visible = character_is_visible

func upgrade():
	if level >= MAX_LEVEL: # MAX_LEVEL or special levels
		return false
	
	set_character_visibility(false)
	level += 1
	set_character_visibility(true)
	
	return true

func became_rogue():
	set_character_visibility(false)
	level = ROGUE_LEVEL
	set_character_visibility(true)

func _physics_process(_delta):
	animation_player.play("Active" if active else "NotActive")
