using System;
using System.Collections.Generic;

namespace script
{
	public class WaitEventList
	{
		public void EventCheck()
		{
			if (this.event_list_.Count <= 0)
			{
				return;
			}
			for (int i = 0; i < this.event_list_.Count; i++)
			{
				WaitEventList.Event @event = this.event_list_[i];
				if (@event.start_tick_count != -1)
				{
					if (@event.wait_time <= GameMain.tick_count - @event.start_tick_count && @event.IsPossibleDelete())
					{
						@event.call_back_delegate();
						@event.start_tick_count = -1;
					}
				}
			}
			this.event_list_.RemoveAll((WaitEventList.Event target) => target.start_tick_count < 0);
		}

		public void Add(Action exec_delegate, int wait)
		{
			WaitEventList.Event @event = new WaitEventList.Event(exec_delegate, wait);
			@event.start_tick_count = GameMain.tick_count;
			this.event_list_.Add(@event);
		}

		public void Clear()
		{
			this.event_list_.Clear();
		}

		public List<WaitEventList.Event> list
		{
			get
			{
				return this.event_list_;
			}
		}

		protected List<WaitEventList.Event> event_list_ = new List<WaitEventList.Event>();

		public class Event
		{
			public Event()
			{
				this.start_tick_count = -1;
			}

			public Event(Action call_back_delegate, int wait_time)
			{
				this.wait_time = wait_time;
				this.call_back_delegate = call_back_delegate;
				this.start_tick_count = -1;
			}

			public virtual bool IsPossibleDelete()
			{
				return true;
			}

			public int wait_time { get; set; }

			public Action call_back_delegate { get; set; }

			public int start_tick_count { get; set; }
		}
	}
}
