extends Node3D

var revolver: Node3D

func _ready() -> void:
	revolver = GameManager.get_enemy_revolver()
	GameManager.state_changed.connect(on_state_changed)

func on_state_changed():
	if GameManager.current_state == GameManager.GameState.PLAYER2_GUN_LOAD:
		make_turn()

func make_turn():
	if revolver == null:
		revolver = GameManager.get_enemy_revolver()
	var bullets = GameManager.bullets
	var avaible_bullets = Array()
	for bullet in bullets:
		if bullet.is_loaded == false:
			avaible_bullets.append(bullet)
	var randNumb = randi_range(0, avaible_bullets.size() -1)
	revolver.load_bullet(avaible_bullets[randNumb])
	
