extends MeshInstance3D

var isOnScreen:bool = false
@onready var camera_char: Camera3D = $"../Character/Head/Camera"
@onready var camera_screen: Camera3D = $Camera3D
@onready var screen: MeshInstance3D = $screen

@export var screens: Array
@export var new_screen: Texture2D
var current_screen = 0

func _input(event: InputEvent) -> void:
	if event.is_action_pressed("fly_cam"):
		isOnScreen = !isOnScreen
		if isOnScreen:
			camera_char.current = false
			camera_screen.current = true
		else: 
			camera_char.current = true
			camera_screen.current = false
			
	
	if event.is_action_pressed("next_screen"):
		current_screen += 1
		current_screen %= screens.size()
		
		var mat:StandardMaterial3D = screen.mesh.surface_get_material(0)
		mat.emission_texture = screens[current_screen]
	
	if event.is_action_pressed("new_contract"):
		var mat:StandardMaterial3D = screen.mesh.surface_get_material(0)
		mat.emission_texture = new_screen
