using UnityEngine;
using System.Collections;

public class Spawnable : IInteractible
{
		public SpawnPoint spawner { get; set; }

		protected float extraTime;
		protected float destroyTime;
		protected bool destroyed;

		public virtual void Start ()
		{
				extraTime = .7f;
		}

		public override void Interact (Player p)
		{
				Debug.Log ("Interact");
				spawner.Visit ();
				spawner.Reset ();
				destroyed = true;
				destroyTime = Time.time;
		}
		
		public void Update ()
		{
				if (destroyed && (Time.time - destroyTime) > extraTime) {
						GameObject.Destroy (gameObject);
				}
		}
}