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

// Wait for a signal
// Optionnal, give a maximum time to wait
class Item_WaitSignal : Item
	{
		public string _symbol;
		public int _maxWaiting;
		
		public Item_WaitSignal( string symbol )
		{
			_symbol = symbol;
			_maxWaiting = -1;
		}
		
		public Item_WaitSignal( string symbol , int maxWaiting )
		{
			_symbol = symbol;
			_maxWaiting = maxWaiting;
		}
		
		public override string getLabel()
		{
			return "WaitSignal " + _symbol + " : " + _maxWaiting;
		}
		
		public override eTickMsg tick( TrackManager trackManager , Track track )
		{
		if( _maxWaiting >= 0 && Time.time - track._timeBegin > _maxWaiting )
				return eTickMsg.FAIL;
			else
				return eTickMsg.WAIT;
		}
		
		public override eReceiveMsg receive( TrackManager trackManager , Track track, Event evt )
		{
			if( evt._symbol.Equals( _symbol ) )
				return eReceiveMsg.NEXT;
			else
				return eReceiveMsg.I_DONT_CARE;
		}
		
	}
