arthurdiniz0_outer-math/OuterMath Unity Project/Assets/PlayMaker/Actions/GameObject/GetTagCount.cs
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
	[ActionCategory(ActionCategory.GameObject)]
	[Tooltip("Gets the number of Game Objects in the scene with the specified Tag.")]
	public class GetTagCount : FsmStateAction
	{
		[UIHint(UIHint.Tag)]
        [Tooltip("The Tag to search for.")]
		public FsmString tag;

        [RequiredField]
		[UIHint(UIHint.Variable)]
        [Tooltip("Store the number found in an int variable.")]
		public FsmInt storeResult;
		
		public override void Reset()
		{
			tag = "Untagged";
			storeResult = null;
		}

		public override void OnEnter()
		{
			GameObject[] gos = GameObject.FindGameObjectsWithTag(tag.Value);
			
			if (storeResult != null)
				storeResult.Value = gos != null ? gos.Length : 0;
				
			Finish();
		}
	}
}