using UnityEngine;
using Enviro;

namespace HutongGames.PlayMaker.Actions
{
	[ActionCategory("ENVIRO")]
	[Tooltip("Gets the current time (Date).")]
	public class GetTimeDate : FsmStateAction
	{
		public FsmInt Second;
		public FsmInt Minute;
		public FsmInt Hour;
		public FsmInt Day;
		public FsmInt Month;
		public FsmInt Year;
 
		[Tooltip("Repeat every frame.")]
		public bool everyFrame;
		
		public override void OnEnter()
		{
			if(EnviroManager.instance.Time != null)
			{
			Second.Value = EnviroManager.instance.Time.seconds;	
			Minute.Value = EnviroManager.instance.Time.minutes;	
			Hour.Value = EnviroManager.instance.Time.hours;		
			Day.Value = EnviroManager.instance.Time.days;
			Month.Value = EnviroManager.instance.Time.months;
			Year.Value = EnviroManager.instance.Time.years;
			}

			if (!everyFrame)
			{
				Finish();
			}
		}


		public override void OnUpdate()
		{
			if(EnviroManager.instance.Time != null)
			{
			Second.Value = EnviroManager.instance.Time.seconds;	
			Minute.Value = EnviroManager.instance.Time.minutes;	
			Hour.Value = EnviroManager.instance.Time.hours;		
			Day.Value = EnviroManager.instance.Time.days;
			Month.Value = EnviroManager.instance.Time.months;
			Year.Value = EnviroManager.instance.Time.years;
			}
		}
	}
}