using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ExitPortal : MonoBehaviour
{
	public SceneReference destination;
	public string door;

	void Start() {
		if (destination.ScenePath == "")
			Debug.LogError($"No destination set for exit '{gameObject.name}'.", this);
	}

	void OnTriggerEnter(Collider other) {
		GameObject g = other.gameObject;
		PlayerControl pc = g.GetComponent<PlayerControl>();
		if (pc && pc.enabled) {
			Game.ExitEvent(g);
			Game.GotoScene(destination.ScenePath, door);
		}
	}
}
