using UnityEngine;
using System.Collections;
using Framework.Entities;
using Framework.Extensions;
using System.Linq;
using System.Collections.Generic;
using Framework.InteractionSystem;
using Framework.Utility;
using Project.Player;

namespace Project.Triggers
{
    public class DialogTrigger : CoreBehaviour
    {
        public class StartDialogAction : CoreAction
        {
            public string resourceName;

            public StartDialogAction(string resourceName)
            {
                this.resourceName = resourceName;
            }
        }

        public string resourceName;
        public GameObject speakerObject;

        // Use this for initialization
        protected override void InnerAwake()
        {
            if (this.speakerObject == null)
            {
                this.speakerObject = GameObject.Find("Player");
            }
        }

        // Update is called once per frame
        protected override void InnerUpdate()
        {

        }

        protected void OnTriggerEnter(Collider collider)
        {
            GameObject other = collider.gameObject;
            if (other.GetComponent<PlayerInput>() != null)
            {
                this.speakerObject.Interact(new StartDialogAction(this.resourceName));
                Destroy(this.gameObject);
            }
        }
    }
}