summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/PowerTools/SpriteAnimEventHandler.cs
blob: b97b8c2882019301fb7fd45f69d0ad884a60f81d (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
using System;
using UnityEngine;

namespace PowerTools
{
	[DisallowMultipleComponent]
	public class SpriteAnimEventHandler : MonoBehaviour
	{
		private string m_eventWithObjectMessage;

		private object m_eventWithObjectData;

		public static class EventParser
		{
			public static readonly char MESSAGE_DELIMITER = '\t';

			public static readonly string MESSAGE_NOPARAM = "_Anim";

			public static readonly string MESSAGE_INT = "_AnimInt";

			public static readonly string MESSAGE_FLOAT = "_AnimFloat";

			public static readonly string MESSAGE_STRING = "_AnimString";

			public static readonly string MESSAGE_OBJECT_FUNCNAME = "_AnimObjectFunc";

			public static readonly string MESSAGE_OBJECT_DATA = "_AnimObjectData";

			public static int ParseInt(ref string messageString)
			{
				int num = messageString.IndexOf(SpriteAnimEventHandler.EventParser.MESSAGE_DELIMITER);
				int result = 0;
				int.TryParse(messageString.Substring(num + 1), out result);
				messageString = messageString.Substring(0, num);
				return result;
			}

			public static float ParseFloat(ref string messageString)
			{
				int num = messageString.IndexOf(SpriteAnimEventHandler.EventParser.MESSAGE_DELIMITER);
				float result = 0f;
				float.TryParse(messageString.Substring(num + 1), out result);
				messageString = messageString.Substring(0, num);
				return result;
			}

			public static string ParseString(ref string messageString)
			{
				int num = messageString.IndexOf(SpriteAnimEventHandler.EventParser.MESSAGE_DELIMITER);
				string result = messageString.Substring(num + 1);
				messageString = messageString.Substring(0, num);
				return result;
			}
		}

		private void _Anim(string function)
		{
			base.SendMessageUpwards(function, SendMessageOptions.DontRequireReceiver);
		}

		private void _AnimInt(string messageString)
		{
			int num = SpriteAnimEventHandler.EventParser.ParseInt(ref messageString);
			base.SendMessageUpwards(messageString, num, SendMessageOptions.DontRequireReceiver);
		}

		private void _AnimFloat(string messageString)
		{
			float num = SpriteAnimEventHandler.EventParser.ParseFloat(ref messageString);
			base.SendMessageUpwards(messageString, num, SendMessageOptions.DontRequireReceiver);
		}

		private void _AnimString(string messageString)
		{
			string value = SpriteAnimEventHandler.EventParser.ParseString(ref messageString);
			base.SendMessageUpwards(messageString, value, SendMessageOptions.DontRequireReceiver);
		}

		private void _AnimObjectFunc(string funcName)
		{
			if (this.m_eventWithObjectData != null)
			{
				base.SendMessageUpwards(funcName, this.m_eventWithObjectData, SendMessageOptions.DontRequireReceiver);
				this.m_eventWithObjectMessage = null;
				this.m_eventWithObjectData = null;
				return;
			}
			if (!string.IsNullOrEmpty(this.m_eventWithObjectMessage))
			{
				Debug.LogError("Animation event with object parameter had no object");
			}
			this.m_eventWithObjectMessage = funcName;
		}

		private void _AnimObjectData(UnityEngine.Object data)
		{
			if (!string.IsNullOrEmpty(this.m_eventWithObjectMessage))
			{
				base.SendMessageUpwards(this.m_eventWithObjectMessage, data, SendMessageOptions.DontRequireReceiver);
				this.m_eventWithObjectMessage = null;
				this.m_eventWithObjectData = null;
				return;
			}
			if (this.m_eventWithObjectData != null)
			{
				Debug.LogError("Animation event with object parameter had no object");
			}
			this.m_eventWithObjectData = data;
		}
	}
}