summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/PowerTools/WaitForAnimationFinish.cs
blob: f4f083c5cacb032fe654186a6fe09491cd8debc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections;
using UnityEngine;

namespace PowerTools
{
	public class WaitForAnimationFinish : IEnumerator
	{
		public object Current
		{
			get
			{
				return null;
			}
		}

		private SpriteAnim animator;

		private AnimationClip clip;

		private bool first = true;

		public WaitForAnimationFinish(SpriteAnim animator, AnimationClip clip)
		{
			this.animator = animator;
			this.clip = clip;
			this.animator.Play(this.clip, 1f);
		}

		public bool MoveNext()
		{
			if (this.first)
			{
				this.first = false;
				return true;
			}
			bool result;
			try
			{
				result = this.animator.IsPlaying(this.clip);
			}
			catch
			{
				result = false;
			}
			return result;
		}

		public void Reset()
		{
			this.first = true;
			this.animator.Play(this.clip, 1f);
		}
	}
}