﻿
using UnityEngine;
using UltimateSurvival;
using ORKFramework;
using ORKFramework.Behaviours;
using System.Collections.Generic;

namespace ORKFramework.UltimateSurvival
{
	public class UltimateSurvivalORKInteraction : InteractableObject, IInventoryTrigger
	{
		[Tooltip("Select the ORK interaction component you want to use (e.g. 'Event Interaction').\n" + 
			"Select none to use the first available interaction on the game object.")]
		public BaseInteraction interaction;

		public override void OnInteract(PlayerEventHandler player)
		{
			if(this.interaction != null)
			{
				this.interaction.Interact();
			}
			else
			{
				BaseInteraction[] interactions = this.GetComponents<BaseInteraction>();

				for(int i = 0; i < interactions.Length; i++)
				{
					if(interactions[i] != null &&
						interactions[i].enabled &&
						interactions[i].Interact())
					{
						return;
					}
				}
			}
		}
	}
}
