using Godot;
using System;

public partial class Door : Node2D
{
	[ExportGroup("text")]
	[Export] string text_char;
	[Export] string answerA;
	[Export] string answerB;
	[Export] bool answerA_good;

	[ExportGroup("image")]
	[Export] Texture2D image_mob;
	bool player_in = false;
	CharacterBody2D player;
	

	// Called every frame. 'delta' is the elapsed time since the previous frame.
	public override void _Process(double delta)
	{

		if(player_in && Input.IsActionPressed("interact"))
		{
			Control view = player.GetNode<Control>("Camera2D/door_view");

			view.Set("text_char", text_char);
			view.Set("answerA", answerA);
			view.Set("answerB", answerB);
			view.Set("answerA_good", answerA_good);
			view.Set("mobTex", image_mob);
			view.Call("start");
		}
	}

	public void BodyEntered(Node2D body)
	{
		if(body is CharacterBody2D)
		{
			player = (CharacterBody2D)body;
			player_in = true;
		}
	}
	public void BodyExited(Node body)
	{
		if(body is CharacterBody2D)
		{
			player_in = false;
		}
	}
}
