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.Actors;
using Framework.ActorComponents;

namespace Project.Constructs
{
    public class BandagesBehaviour : CoreBehaviour
    {
        public float refreshTime = 20f;

        private UnityTimer refreshTimer;
        private Vector3 startPosition;


        // Use this for initialization
        protected override void InnerAwake()
        {
            this.startPosition = this.transform.position;
            this.refreshTimer = new UnityTimer(this.refreshTime, false);
        }

        // Update is called once per frame
        protected override void InnerUpdate()
        {
            this.refreshTimer.Advance();
            if (this.refreshTimer.IsComplete())
            {
                this.transform.position = this.startPosition;
            }
        }

        protected void OnTriggerEnter(Collider collider)
        {
            GameObject other = collider.gameObject;
            Debug.Log("HEALLLY: " + other.name);
            if(other.name == "Player")
            {
                Debug.Log("Has player");
                other.Interact(new Woundable.HealAction());
                this.transform.position = Vector3.up * -100f;
                this.refreshTimer.Reset();
            }
        }
    }
}