using UnityEngine;
using System.Collections.Generic;
using Enviro;

namespace HutongGames.PlayMaker.Actions
{
	[ActionCategory("ENVIRO")]
	[Tooltip("Changes the current weather by ID.")]
	public class SetWeatherByID : FsmStateAction
	{
		[RequiredField]
		public FsmInt WeatherID;

		[Tooltip("Repeat every frame.")]
		public bool everyFrame;

		public override void OnEnter()
		{
			if (EnviroManager.instance.Weather != null && EnviroManager.instance.Weather.Settings.weatherTypes.Count >= WeatherID.Value)
                EnviroManager.instance.Weather.ChangeWeather (WeatherID.Value);

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

		public override void OnUpdate()
		{
			if (EnviroManager.instance.Weather != null && EnviroManager.instance.Weather.Settings.weatherTypes.Count >= WeatherID.Value)
                EnviroManager.instance.Weather.ChangeWeather (WeatherID.Value);
		}
		
	}


}