using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using JsonFx.Json;
using UnityEngine;

public class AnimatorTimeline : MonoBehaviour
{
	public static Component aData
	{
		get
		{
			if (AnimatorTimeline._aData != null)
			{
				return AnimatorTimeline._aData;
			}
			AnimatorTimeline.cachedInvoker = null;
			GameObject gameObject = GameObject.Find("AnimatorData");
			if (gameObject)
			{
				AnimatorTimeline._aData = gameObject.GetComponent("AnimatorData");
			}
			if (!AnimatorTimeline._aData)
			{
				Debug.LogWarning("Animator: Could not find AnimatorData component.");
			}
			return AnimatorTimeline._aData;
		}
	}

	private static MethodInfo invoker
	{
		get
		{
			if (AnimatorTimeline.cachedInvoker == null)
			{
				AnimatorTimeline.cachedInvoker = AnimatorTimeline.aData.GetType().GetMethod("Invoker");
			}
			return AnimatorTimeline.cachedInvoker;
		}
	}

	public static bool isPlaying
	{
		get
		{
			return (bool)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					0
				}
			});
		}
		set
		{
			Debug.LogWarning("Animator: Variable Animator.isPlaying is read-only!");
		}
	}

	public static bool isPaused
	{
		get
		{
			return (bool)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					12
				}
			});
		}
		set
		{
			Debug.LogWarning("Animator: Variable Animator.isPaused is read-only!");
		}
	}

	public static string nowPlayingTake
	{
		get
		{
			return (string)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					1
				}
			});
		}
		set
		{
			Debug.LogWarning("Animator: Variable Animator.nowPlayingTake is read-only!");
		}
	}

	public static float runningTime
	{
		get
		{
			return (float)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					10
				}
			});
		}
		set
		{
			Debug.LogWarning("Animator: Variable Animator.runningTime is read-only!");
		}
	}

	public static float totalTime
	{
		get
		{
			return (float)AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					11
				}
			});
		}
		set
		{
			Debug.LogWarning("Animator: Variable Animator.totalTime is read-only!");
		}
	}

	public static void Play(string takeName, bool loop = false)
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					2,
					takeName,
					loop
				}
			});
		}
	}

	public static void Stop()
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					3
				}
			});
		}
	}

	public static void Pause()
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					4
				}
			});
		}
	}

	public static void Resume()
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					5
				}
			});
		}
	}

	public static void PlayFromTime(string takeName, float time, bool loop = false)
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					6,
					takeName,
					time,
					loop
				}
			});
		}
	}

	public static void PlayFromFrame(string takeName, int frame, bool loop = false)
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					7,
					takeName,
					frame,
					loop
				}
			});
		}
	}

	public static void PreviewFrame(string takeName, float frame)
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					8,
					takeName,
					frame
				}
			});
		}
	}

	public static void PreviewTime(string takeName, float time)
	{
		if (AnimatorTimeline.aData)
		{
			AnimatorTimeline.invoker.Invoke(AnimatorTimeline.aData, new object[]
			{
				new object[]
				{
					9,
					takeName,
					time
				}
			});
		}
	}

	public static void ParseJSON(string textAssetName)
	{
		TextAsset textAsset = (TextAsset)Resources.Load(textAssetName);
		if (!textAsset)
		{
			Debug.LogError("Animator: Could not find TextAsset '" + textAssetName + ".txt', make sure it's placed in a Resources folder!");
		}
		AnimatorTimeline.ParseJSON(textAsset);
	}

	private static void ParseJSON(TextAsset json)
	{
		AnimatorTimeline.ParseJSONString(json.ToString());
	}

	public static void ParseJSONString(string json)
	{
		AnimatorTimeline.JSONTake j = JsonReader.Deserialize<AnimatorTimeline.JSONTake>(json);
		if (!AnimatorTimeline.parseJSONTake(j))
		{
			Debug.LogWarning("Animator: Error parsing JSON");
		}
	}

	private static AnimatorTimeline.JSONVector3[] getJSONVector3Array(Vector3[] v)
	{
		List<AnimatorTimeline.JSONVector3> list = new List<AnimatorTimeline.JSONVector3>();
		foreach (Vector3 value in v)
		{
			AnimatorTimeline.JSONVector3 jsonvector = new AnimatorTimeline.JSONVector3();
			jsonvector.setValue(value);
			list.Add(jsonvector);
		}
		return list.ToArray();
	}

	private static bool setInitialValue(AnimatorTimeline.JSONInit init)
	{
		string type = init.type;
		if (type != null)
		{
			if (AnimatorTimeline.<>f__switch$map1 == null)
			{
				AnimatorTimeline.<>f__switch$map1 = new Dictionary<string, int>(13)
				{
					{
						"position",
						0
					},
					{
						"rotation",
						1
					},
					{
						"orientation",
						2
					},
					{
						"propertymorph",
						3
					},
					{
						"propertyint",
						4
					},
					{
						"propertylong",
						5
					},
					{
						"propertyfloat",
						6
					},
					{
						"propertydouble",
						7
					},
					{
						"propertyvect2",
						8
					},
					{
						"propertyvect3",
						9
					},
					{
						"propertycolor",
						10
					},
					{
						"propertyrect",
						11
					},
					{
						"cameraswitcher",
						12
					}
				};
			}
			int num;
			if (AnimatorTimeline.<>f__switch$map1.TryGetValue(type, out num))
			{
				switch (num)
				{
				case 0:
					if (init.position == null || init.go == null)
					{
						return false;
					}
					AnimatorTimeline.getGO(init.go).transform.position = init.position.toVector3();
					break;
				case 1:
					if (init.rotation == null || init.go == null)
					{
						return false;
					}
					AnimatorTimeline.getGO(init.go).transform.rotation = init.rotation.toQuaternion();
					break;
				case 2:
					if (init.position == null || init.go == null)
					{
						return false;
					}
					AnimatorTimeline.getGO(init.go).transform.LookAt(init.position.toVector3());
					break;
				case 3:
					if (init.go == null || init.floats == null)
					{
						return false;
					}
					AMTween.SetMorph(AnimatorTimeline.getCMP(init.go, "MegaMorph"), AnimatorTimeline.getMethodInfo(init.go, "MegaMorph", "SetPercent", new string[]
					{
						"System.Int32",
						"System.Single"
					}), init.floats);
					break;
				case 4:
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._int))
					{
						return false;
					}
					break;
				case 5:
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._long))
					{
						return false;
					}
					break;
				case 6:
					if (init.floats == null || init.floats.Length <= 0)
					{
						return false;
					}
					if (!AnimatorTimeline.setInitialValueForProperty(init, init.floats[0]))
					{
						return false;
					}
					break;
				case 7:
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._double))
					{
						return false;
					}
					break;
				case 8:
					if (init._vect2 == null)
					{
						return false;
					}
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._vect2.toVector2()))
					{
						return false;
					}
					break;
				case 9:
					if (init.position == null)
					{
						return false;
					}
					if (!AnimatorTimeline.setInitialValueForProperty(init, init.position.toVector3()))
					{
						return false;
					}
					break;
				case 10:
					if (init._color == null)
					{
						return false;
					}
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._color.toColor()))
					{
						return false;
					}
					break;
				case 11:
					if (init._rect == null)
					{
						return false;
					}
					if (!AnimatorTimeline.setInitialValueForProperty(init, init._rect.toRect()))
					{
						return false;
					}
					break;
				case 12:
					if (init.strings != null && init.strings.Length > 0)
					{
						AnimatorTimeline.allCameras = new Camera[init.strings.Length];
						for (int i = 0; i < init.strings.Length; i++)
						{
							AnimatorTimeline.allCameras[i] = AnimatorTimeline.getGO(init.strings[i]).GetComponent<Camera>();
						}
					}
					if (init.typeExtra == "camera")
					{
						if (init.go == null)
						{
							return false;
						}
						AMTween.SetTopCamera(AnimatorTimeline.getGO(init.go).GetComponent<Camera>(), AnimatorTimeline.allCameras);
					}
					else
					{
						if (init._color == null)
						{
							return false;
						}
						AMTween.ShowColor(init._color.toColor());
					}
					break;
				case 13:
					goto IL_441;
				default:
					goto IL_441;
				}
				return true;
			}
		}
		IL_441:
		Debug.LogWarning("Animator: Error parsing initial value type '" + init.type + "'");
		return false;
	}

	private static bool setInitialValueForProperty(AnimatorTimeline.JSONInit init, object value)
	{
		if (init.go == null || value == null || init.strings == null || init.strings.Length < 2 || init.typeExtra == null)
		{
			return false;
		}
		if (init.typeExtra == "fieldInfo")
		{
			AnimatorTimeline.getFieldInfo(init.go, init.strings[0], init.strings[1]).SetValue(AnimatorTimeline.getCMP(init.go, init.strings[0]), value);
		}
		else
		{
			AnimatorTimeline.getPropertyInfo(init.go, init.strings[0], init.strings[1]).SetValue(AnimatorTimeline.getCMP(init.go, init.strings[0]), value, null);
		}
		return true;
	}

	private static bool parseJSONTake(AnimatorTimeline.JSONTake j)
	{
		AnimatorTimeline.dictGameObjects = new Dictionary<string, GameObject>();
		AnimatorTimeline.dictComponents = new Dictionary<string, Component>();
		AnimatorTimeline.dictMethodInfos = new Dictionary<string, MethodInfo>();
		AnimatorTimeline.dictFieldInfos = new Dictionary<string, FieldInfo>();
		AnimatorTimeline.dictPropertyInfos = new Dictionary<string, PropertyInfo>();
		AnimatorTimeline.allCameras = null;
		bool flag = false;
		if (j.inits != null)
		{
			foreach (AnimatorTimeline.JSONInit initialValue in j.inits)
			{
				if (!AnimatorTimeline.setInitialValue(initialValue))
				{
					flag = true;
				}
			}
		}
		if (j.actions != null)
		{
			AnimatorTimeline.JSONAction[] actions = j.actions;
			int k = 0;
			while (k < actions.Length)
			{
				AnimatorTimeline.JSONAction jsonaction = actions[k];
				string method = jsonaction.method;
				if (method == null)
				{
					goto IL_249;
				}
				if (AnimatorTimeline.<>f__switch$map2 == null)
				{
					AnimatorTimeline.<>f__switch$map2 = new Dictionary<string, int>(10)
					{
						{
							"moveto",
							0
						},
						{
							"rotateto",
							1
						},
						{
							"lookfollow",
							2
						},
						{
							"looktofollow",
							3
						},
						{
							"playanimation",
							4
						},
						{
							"playaudio",
							5
						},
						{
							"propertyto",
							6
						},
						{
							"sendmessage",
							7
						},
						{
							"invokemethod",
							8
						},
						{
							"camerafade",
							9
						}
					};
				}
				int num;
				if (!AnimatorTimeline.<>f__switch$map2.TryGetValue(method, out num))
				{
					goto IL_249;
				}
				switch (num)
				{
				case 0:
					if (!AnimatorTimeline.parseMoveTo(jsonaction))
					{
						flag = true;
					}
					break;
				case 1:
					if (!AnimatorTimeline.parseRotateTo(jsonaction))
					{
						flag = true;
					}
					break;
				case 2:
					if (!AnimatorTimeline.parseLookFollow(jsonaction))
					{
						flag = true;
					}
					break;
				case 3:
					if (!AnimatorTimeline.parseLookToFollow(jsonaction))
					{
						flag = true;
					}
					break;
				case 4:
					if (!AnimatorTimeline.parsePlayAnimation(jsonaction))
					{
						flag = true;
					}
					break;
				case 5:
					if (!AnimatorTimeline.parsePlayAudio(jsonaction))
					{
						flag = true;
					}
					break;
				case 6:
					if (!AnimatorTimeline.parsePropertyTo(jsonaction))
					{
						flag = true;
					}
					break;
				case 7:
					if (!AnimatorTimeline.parseSendMessage(jsonaction))
					{
						flag = true;
					}
					break;
				case 8:
					if (!AnimatorTimeline.parseInvokeMethod(jsonaction))
					{
						flag = true;
					}
					break;
				case 9:
					if (!AnimatorTimeline.parseCameraFade(jsonaction))
					{
						flag = true;
					}
					break;
				case 10:
					goto IL_249;
				default:
					goto IL_249;
				}
				IL_26B:
				k++;
				continue;
				IL_249:
				Debug.LogWarning("Animator: Error parsing method '" + jsonaction.method + "'");
				flag = true;
				goto IL_26B;
			}
		}
		AMTween.StartDisabled();
		return !flag;
	}

	private static bool parseCameraFade(AnimatorTimeline.JSONAction a)
	{
		if (a.ints == null || a.ints.Length < 3)
		{
			Debug.LogWarning("Animator: CameraFade missing fade type, start or end targets.");
			return false;
		}
		if (a.strings == null || a.strings.Length < 2 || a.colors == null || a.colors.Length < 2)
		{
			Debug.LogWarning("Animator: CameraFade missing start or end targets.");
			return false;
		}
		Hashtable hashtable = new Hashtable();
		hashtable.Add("time", a.time);
		hashtable.Add("delay", a.delay);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.bools != null && a.bools.Length > 0)
		{
			hashtable.Add("reversed", a.bools[0]);
		}
		if (a.ints[1] == 0 || a.ints[2] == 0)
		{
			hashtable.Add("allcameras", AnimatorTimeline.allCameras);
		}
		if (a.stringsExtra != null && a.stringsExtra.Length > 0)
		{
			hashtable.Add("texture", AMTween.LoadTexture2D(a.stringsExtra[0]));
		}
		if (a.ints[1] == 0)
		{
			hashtable.Add("camera1", AnimatorTimeline.getGO(a.strings[0]).GetComponent<Camera>());
		}
		else
		{
			hashtable.Add("color1", a.colors[0].toColor());
		}
		if (a.ints[2] == 0)
		{
			hashtable.Add("camera2", AnimatorTimeline.getGO(a.strings[1]).GetComponent<Camera>());
		}
		else
		{
			hashtable.Add("color2", a.colors[1].toColor());
		}
		float[] array = a.floats;
		if (array == null)
		{
			array = new float[0];
		}
		AMTween.CameraFade(a.ints[0], a.bools != null && a.bools.Length >= 2 && a.bools[1], array, hashtable);
		return true;
	}

	private static bool parseInvokeMethod(AnimatorTimeline.JSONAction a)
	{
		if (a.strings == null || a.strings.Length < 2)
		{
			Debug.LogWarning("Animator: SendMessage missing Component or MethodInfo Name.");
			return false;
		}
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("methodinfo", AnimatorTimeline.getMethodInfo(a.go, a.strings[0], a.strings[1], null));
		if (a.eventParams != null && a.eventParams.Length > 0)
		{
			object[] array = new object[a.eventParams.Length];
			for (int i = 0; i < a.eventParams.Length; i++)
			{
				array[i] = a.eventParams[i].toObject();
			}
			if (array.Length <= 0)
			{
				array = null;
			}
			hashtable.Add("parameters", array);
		}
		AMTween.InvokeMethod(AnimatorTimeline.getCMP(a.go, a.strings[0]), hashtable);
		return true;
	}

	private static bool parseSendMessage(AnimatorTimeline.JSONAction a)
	{
		if (a.strings == null || a.strings.Length < 1)
		{
			Debug.LogWarning("Animator: SendMessage missing Method Name.");
			return false;
		}
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("methodname", a.strings[0]);
		if (a.eventParams != null && a.eventParams.Length > 0)
		{
			hashtable.Add("parameter", a.eventParams[0].toObject());
		}
		AMTween.SendMessage(AnimatorTimeline.getGO(a.go), hashtable);
		return true;
	}

	private static bool parsePropertyTo(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("time", a.time);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.strings == null || a.strings.Length < 2)
		{
			Debug.LogWarning("Animator: PropertyTo missing Component or property type.");
			return false;
		}
		string componentName = a.strings[0];
		bool flag = false;
		string text = a.strings[1];
		if (text != null)
		{
			if (AnimatorTimeline.<>f__switch$map3 == null)
			{
				AnimatorTimeline.<>f__switch$map3 = new Dictionary<string, int>(9)
				{
					{
						"morph",
						0
					},
					{
						"integer",
						1
					},
					{
						"long",
						2
					},
					{
						"float",
						3
					},
					{
						"double",
						4
					},
					{
						"vector2",
						5
					},
					{
						"vector3",
						6
					},
					{
						"color",
						7
					},
					{
						"rect",
						8
					}
				};
			}
			int num;
			if (AnimatorTimeline.<>f__switch$map3.TryGetValue(text, out num))
			{
				switch (num)
				{
				case 0:
					if (a.floats == null || a.floatsExtra == null)
					{
						flag = true;
					}
					hashtable.Add("methodtype", "morph");
					hashtable.Add("methodinfo", AnimatorTimeline.getMethodInfo(a.go, "MegaMorph", "SetPercent", new string[]
					{
						"System.Int32",
						"System.Single"
					}));
					hashtable.Add("from", a.floats);
					hashtable.Add("to", a.floatsExtra);
					break;
				case 1:
					if (a.ints == null || a.ints.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.ints[0]);
					hashtable.Add("to", a.ints[1]);
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 2:
					if (a.longs == null || a.longs.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.longs[0]);
					hashtable.Add("to", a.longs[1]);
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 3:
					if (a.floats == null || a.floats.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.floats[0]);
					hashtable.Add("to", a.floats[1]);
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 4:
					if (a.doubles == null || a.doubles.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.doubles[0]);
					hashtable.Add("to", a.doubles[1]);
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 5:
					if (a.vect2s == null || a.vect2s.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.vect2s[0].toVector2());
					hashtable.Add("to", a.vect2s[1].toVector2());
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 6:
					if (a.path == null || a.path.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.path[0].toVector3());
					hashtable.Add("to", a.path[1].toVector3());
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 7:
					if (a.colors == null || a.colors.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.colors[0].toColor());
					hashtable.Add("to", a.colors[1].toColor());
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 8:
					if (a.rects == null || a.rects.Length < 2)
					{
						flag = true;
					}
					hashtable.Add("from", a.rects[0].toRect());
					hashtable.Add("to", a.rects[1].toRect());
					AnimatorTimeline.setupHashFieldOrPropertyInfo(hashtable, a);
					break;
				case 9:
					goto IL_4C3;
				default:
					goto IL_4C3;
				}
				if (flag)
				{
					Debug.LogWarning("Animator: PropertyTo missing 'to' or 'from' targets.");
					return false;
				}
				AMTween.PropertyTo(AnimatorTimeline.getCMP(a.go, componentName), hashtable);
				return true;
			}
		}
		IL_4C3:
		Debug.LogWarning("Animator: PropertyTo unknown property type '" + a.strings[1] + "'.");
		return false;
	}

	private static void setupHashFieldOrPropertyInfo(Hashtable hash, AnimatorTimeline.JSONAction a)
	{
		if (a.strings.Length < 4)
		{
			Debug.LogWarning("Animator: PropertyTo missing Component or property type.");
			return;
		}
		if (a.strings[2] == "fieldinfo")
		{
			hash.Add("fieldinfo", AnimatorTimeline.getFieldInfo(a.go, a.strings[0], a.strings[3]));
		}
		else
		{
			hash.Add("propertyinfo", AnimatorTimeline.getPropertyInfo(a.go, a.strings[0], a.strings[3]));
		}
	}

	private static bool parsePlayAudio(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		if (a.strings.Length < 1)
		{
			Debug.LogWarning("Animator: PlayAudio missing 'audioclip' clip name.");
			return false;
		}
		AudioClip audioClip = (AudioClip)Resources.Load(a.strings[0]);
		if (audioClip == null)
		{
			Debug.LogWarning("Animator: Could not find AudioClip '" + a.strings[0] + "'. Make sure the audio file is placed in a Resources folder!");
			return false;
		}
		hashtable.Add("audioclip", audioClip);
		if (a.bools.Length >= 1)
		{
			hashtable.Add("loop", a.bools[0]);
			AMTween.PlayAudio((AudioSource)AnimatorTimeline.getCMP(a.go, "AudioSource"), hashtable);
			return true;
		}
		Debug.LogWarning("Animator: PlayAudio missing 'loop'.");
		return false;
	}

	private static bool parsePlayAnimation(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		if (a.strings.Length < 1)
		{
			Debug.LogWarning("Animator: PlayAnimation missing 'animation' clip name.");
			return false;
		}
		hashtable.Add("animation", a.strings[0]);
		if (a.floats.Length < 2)
		{
			Debug.LogWarning("Animator: PlayAnimation missing 'wrapmode' or 'fadeLength'.");
			return false;
		}
		hashtable.Add("wrapmode", (WrapMode)a.floats[0]);
		hashtable.Add("fadeLength", a.floats[1]);
		if (a.bools.Length >= 1)
		{
			hashtable.Add("crossfade", a.bools[0]);
			AMTween.PlayAnimation(AnimatorTimeline.getGO(a.go), hashtable);
			return true;
		}
		Debug.LogWarning("Animator: PlayAnimation missing 'crossfade'.");
		return false;
	}

	private static bool parseLookToFollow(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("time", a.time);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.strings.Length >= 1)
		{
			hashtable.Add("looktarget", AnimatorTimeline.getGO(a.strings[0]).transform);
			if (a.path != null && a.path.Length >= 1)
			{
				hashtable.Add("endposition", a.path[0].toVector3());
			}
			AMTween.LookToFollow(AnimatorTimeline.getGO(a.go), hashtable);
			return true;
		}
		Debug.LogWarning("Animator: LookFollow missing 'looktarget'.");
		return false;
	}

	private static bool parseLookFollow(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("time", a.time);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.strings.Length >= 1)
		{
			hashtable.Add("looktarget", AnimatorTimeline.getGO(a.strings[0]).transform);
			AMTween.LookFollow(AnimatorTimeline.getGO(a.go), hashtable);
			return true;
		}
		Debug.LogWarning("Animator: LookFollow missing 'looktarget'.");
		return false;
	}

	private static bool parseMoveTo(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("time", a.time);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.path.Length > 1)
		{
			hashtable.Add("path", a.getVector3Path());
		}
		else
		{
			if (a.path.Length != 1)
			{
				Debug.LogWarning("Animator: MoveTo missing 'position' or 'path'.");
				return false;
			}
			hashtable.Add("position", a.path[0].toVector3());
		}
		AMTween.MoveTo(AnimatorTimeline.getGO(a.go), hashtable);
		return true;
	}

	private static bool parseRotateTo(AnimatorTimeline.JSONAction a)
	{
		Hashtable hashtable = new Hashtable();
		hashtable.Add("disable", true);
		hashtable.Add("delay", a.delay);
		hashtable.Add("time", a.time);
		AnimatorTimeline.setupHashEase(hashtable, a);
		if (a.path.Length >= 1)
		{
			hashtable.Add("rotation", a.path[0].toVector3());
			AMTween.RotateTo(AnimatorTimeline.getGO(a.go), hashtable);
			return true;
		}
		Debug.LogWarning("Animator: RotateTo missing 'rotation'.");
		return false;
	}

	private static void setupHashEase(Hashtable hashTable, AnimatorTimeline.JSONAction a)
	{
		if (a.customEase.Length > 0)
		{
			AnimationCurve value = AMTween.GenerateCurve(a.customEase);
			hashTable.Add("easecurve", value);
		}
		else
		{
			hashTable.Add("easetype", (AMTween.EaseType)a.easeType);
		}
	}

	private static GameObject getGO(string name)
	{
		if (name == null)
		{
			Debug.LogWarning("Animator: Error parsing GameObject with null value");
			return null;
		}
		if (AnimatorTimeline.dictGameObjects.ContainsKey(name))
		{
			return AnimatorTimeline.dictGameObjects[name];
		}
		GameObject gameObject = GameObject.Find(name);
		if (!gameObject)
		{
			Debug.LogWarning("Animator: Error parsing JSON; Could not find GameObject '" + name + "'.");
		}
		AnimatorTimeline.dictGameObjects.Add(name, gameObject);
		return gameObject;
	}

	private static Component getCMP(string goName, string componentName)
	{
		if (goName == null || componentName == null)
		{
			Debug.LogWarning("Animator: Error parsing GameObject or Component with null value: " + goName + ", " + componentName);
			return null;
		}
		string key = goName + "." + componentName;
		if (AnimatorTimeline.dictComponents.ContainsKey(key))
		{
			return AnimatorTimeline.dictComponents[key];
		}
		GameObject go = AnimatorTimeline.getGO(goName);
		Component component = go.GetComponent(componentName);
		if (!component)
		{
			Debug.LogWarning(string.Concat(new string[]
			{
				"Animator: Error parsing JSON; Could not find Component '",
				componentName,
				"' on GameObject '",
				goName,
				"'."
			}));
		}
		AnimatorTimeline.dictComponents.Add(key, component);
		return component;
	}

	private static MethodInfo getMethodInfo(string goName, string componentName, string methodName, string[] typeNames)
	{
		if (methodName == null || componentName == null)
		{
			Debug.LogWarning("Animator: Error parsing MethodInfo or Component with null value");
			return null;
		}
		string text = componentName + "." + methodName;
		List<Type> list = new List<Type>();
		if (typeNames != null)
		{
			for (int i = 0; i < typeNames.Length; i++)
			{
				text = text + "." + typeNames[i];
			}
			foreach (string typeName in typeNames)
			{
				list.Add(Type.GetType(typeName));
			}
		}
		if (AnimatorTimeline.dictMethodInfos.ContainsKey(text))
		{
			return AnimatorTimeline.dictMethodInfos[text];
		}
		MethodInfo method;
		if (typeNames == null)
		{
			method = AnimatorTimeline.getCMP(goName, componentName).GetType().GetMethod(methodName);
		}
		else
		{
			method = AnimatorTimeline.getCMP(goName, componentName).GetType().GetMethod(methodName, list.ToArray());
		}
		AnimatorTimeline.dictMethodInfos.Add(text, method);
		return AnimatorTimeline.dictMethodInfos[text];
	}

	private static FieldInfo getFieldInfo(string goName, string componentName, string fieldName)
	{
		if (fieldName == null || componentName == null)
		{
			Debug.LogWarning("Animator: Error parsing FieldInfo or Component with null value");
			return null;
		}
		string key = componentName + "." + fieldName;
		if (AnimatorTimeline.dictFieldInfos.ContainsKey(key))
		{
			return AnimatorTimeline.dictFieldInfos[key];
		}
		AnimatorTimeline.dictFieldInfos.Add(key, AnimatorTimeline.getCMP(goName, componentName).GetType().GetField(fieldName));
		return AnimatorTimeline.dictFieldInfos[key];
	}

	private static PropertyInfo getPropertyInfo(string goName, string componentName, string propertyName)
	{
		if (propertyName == null || componentName == null)
		{
			Debug.LogWarning("Animator: Error parsing PropertyInfo or Component with null value");
			return null;
		}
		string key = componentName + "." + propertyName;
		if (AnimatorTimeline.dictPropertyInfos.ContainsKey(key))
		{
			return AnimatorTimeline.dictPropertyInfos[key];
		}
		AnimatorTimeline.dictPropertyInfos.Add(key, AnimatorTimeline.getCMP(goName, componentName).GetType().GetProperty(propertyName));
		return AnimatorTimeline.dictPropertyInfos[key];
	}

	private static Component _aData;

	private static MethodInfo cachedInvoker;

	private static Dictionary<string, GameObject> dictGameObjects;

	private static Dictionary<string, Component> dictComponents;

	private static Dictionary<string, MethodInfo> dictMethodInfos;

	private static Dictionary<string, FieldInfo> dictFieldInfos;

	private static Dictionary<string, PropertyInfo> dictPropertyInfos;

	private static Camera[] allCameras;

	public class JSONTake
	{
		public string takeName;

		public AnimatorTimeline.JSONInit[] inits;

		public AnimatorTimeline.JSONAction[] actions;
	}

	public class JSONInit
	{
		public string type;

		public string typeExtra;

		public string go;

		public AnimatorTimeline.JSONVector3 position;

		public AnimatorTimeline.JSONQuaternion rotation;

		public float[] floats;

		public string[] strings;

		public string[] stringsExtra;

		public int _int;

		public long _long;

		public double _double;

		public AnimatorTimeline.JSONVector2 _vect2;

		public AnimatorTimeline.JSONColor _color;

		public AnimatorTimeline.JSONRect _rect;
	}

	public class JSONAction
	{
		public void setPath(Vector3[] _path)
		{
			this.path = AnimatorTimeline.getJSONVector3Array(_path);
		}

		public Vector3[] getVector3Path()
		{
			List<Vector3> list = new List<Vector3>();
			for (int i = 0; i < this.path.Length; i++)
			{
				list.Add(this.path[i].toVector3());
			}
			return list.ToArray();
		}

		public string method;

		public string go;

		public float delay;

		public float time;

		public int easeType;

		public float[] customEase;

		public string[] strings;

		public string[] stringsExtra;

		public float[] floats;

		public float[] floatsExtra;

		public bool[] bools;

		public int[] ints;

		public long[] longs;

		public double[] doubles;

		public AnimatorTimeline.JSONVector3[] path;

		public AnimatorTimeline.JSONVector2[] vect2s;

		public AnimatorTimeline.JSONColor[] colors;

		public AnimatorTimeline.JSONRect[] rects;

		public AnimatorTimeline.JSONEventParameter[] eventParams;
	}

	public class JSONEventParameter
	{
		public object toObject()
		{
			if (this.valueType == 13)
			{
				return this.val_bool;
			}
			if (this.valueType == 9)
			{
				return this.val_string;
			}
			if (this.valueType == 10)
			{
				if (this.val_string == null || this.val_string.Length <= 0)
				{
					return '\0';
				}
				return this.val_string[0];
			}
			else
			{
				if (this.valueType == 0 || this.valueType == 1)
				{
					return this.val_int;
				}
				if (this.valueType == 2 || this.valueType == 3)
				{
					return this.val_float;
				}
				if (this.valueType == 4)
				{
					return this.val_vect2;
				}
				if (this.valueType == 5)
				{
					return this.val_vect3;
				}
				if (this.valueType == 6)
				{
					return this.val_vect4;
				}
				if (this.valueType == 7)
				{
					return this.val_color;
				}
				if (this.valueType == 8)
				{
					return this.val_rect;
				}
				if (this.valueType != 11)
				{
					if (this.valueType == 12)
					{
						if (this.array == null || this.array.Length <= 0)
						{
							Debug.LogError("Animator: Expected array parameters in JSON");
							return null;
						}
						if (this.array[0].valueType == 13)
						{
							bool[] array = new bool[this.array.Length];
							for (int i = 0; i < this.array.Length; i++)
							{
								array[i] = this.array[i].val_bool;
							}
							return array;
						}
						if (this.array[0].valueType == 9)
						{
							string[] array2 = new string[this.array.Length];
							for (int j = 0; j < this.array.Length; j++)
							{
								array2[j] = this.array[j].val_string;
							}
							return array2;
						}
						if (this.array[0].valueType == 10)
						{
							char[] array3 = new char[this.array.Length];
							for (int k = 0; k < this.array.Length; k++)
							{
								array3[k] = this.array[k].val_string[0];
							}
							return array3;
						}
						if (this.array[0].valueType == 0 || this.array[0].valueType == 1)
						{
							int[] array4 = new int[this.array.Length];
							for (int l = 0; l < this.array.Length; l++)
							{
								array4[l] = this.array[l].val_int;
							}
							return array4;
						}
						if (this.array[0].valueType == 2 || this.array[0].valueType == 3)
						{
							float[] array5 = new float[this.array.Length];
							for (int m = 0; m < this.array.Length; m++)
							{
								array5[m] = this.array[m].val_float;
							}
							return array5;
						}
						if (this.array[0].valueType == 4)
						{
							Vector2[] array6 = new Vector2[this.array.Length];
							for (int n = 0; n < this.array.Length; n++)
							{
								array6[n] = this.array[n].val_vect2.toVector2();
							}
							return array6;
						}
						if (this.array[0].valueType == 5)
						{
							Vector3[] array7 = new Vector3[this.array.Length];
							for (int num = 0; num < this.array.Length; num++)
							{
								array7[num] = this.array[num].val_vect3.toVector3();
							}
							return array7;
						}
						if (this.array[0].valueType == 6)
						{
							Vector4[] array8 = new Vector4[this.array.Length];
							for (int num2 = 0; num2 < this.array.Length; num2++)
							{
								array8[num2] = this.array[num2].val_vect4.toVector4();
							}
							return array8;
						}
						if (this.array[0].valueType == 7)
						{
							Color[] array9 = new Color[this.array.Length];
							for (int num3 = 0; num3 < this.array.Length; num3++)
							{
								array9[num3] = this.array[num3].val_color.toColor();
							}
							return array9;
						}
						if (this.array[0].valueType == 8)
						{
							Rect[] array10 = new Rect[this.array.Length];
							for (int num4 = 0; num4 < this.array.Length; num4++)
							{
								array10[num4] = this.array[num4].val_rect.toRect();
							}
							return array10;
						}
						if (this.array[0].valueType == 11)
						{
							UnityEngine.Object[] array11 = new UnityEngine.Object[this.array.Length];
							for (int num5 = 0; num5 < this.array.Length; num5++)
							{
								array11[num5] = AnimatorTimeline.getGO(this.array[num5].val_obj);
							}
							return array11;
						}
					}
					Debug.LogError("Animator: Type not found for Event Parameter valueType " + this.valueType);
					return null;
				}
				if (this.val_obj_extra == null)
				{
					return AnimatorTimeline.getGO(this.val_obj);
				}
				return AnimatorTimeline.getCMP(this.val_obj_extra, this.val_obj);
			}
		}

		public int valueType;

		public bool val_bool;

		public int val_int;

		public float val_float;

		public AnimatorTimeline.JSONVector2 val_vect2;

		public AnimatorTimeline.JSONVector3 val_vect3;

		public AnimatorTimeline.JSONVector4 val_vect4;

		public AnimatorTimeline.JSONColor val_color;

		public AnimatorTimeline.JSONRect val_rect;

		public string val_string;

		public string val_obj;

		public string val_obj_extra;

		public AnimatorTimeline.JSONEventParameter[] array;

		public enum ValueType
		{
			Integer,
			Long,
			Float,
			Double,
			Vector2,
			Vector3,
			Vector4,
			Color,
			Rect,
			String,
			Char,
			Object,
			Array,
			Boolean
		}
	}

	public class JSONVector4
	{
		public void setValue(Vector4 v)
		{
			this.x = v.x;
			this.y = v.y;
			this.z = v.z;
			this.w = v.w;
		}

		public Vector4 toVector4()
		{
			return new Vector4(this.x, this.y, this.z, this.w);
		}

		public float x;

		public float y;

		public float z;

		public float w;
	}

	public class JSONVector3
	{
		public void setValue(Vector3 v)
		{
			this.x = v.x;
			this.y = v.y;
			this.z = v.z;
		}

		public Vector3 toVector3()
		{
			return new Vector3(this.x, this.y, this.z);
		}

		public float x;

		public float y;

		public float z;
	}

	public class JSONVector2
	{
		public void setValue(Vector2 v)
		{
			this.x = v.x;
			this.y = v.y;
		}

		public Vector2 toVector2()
		{
			return new Vector2(this.x, this.y);
		}

		public float x;

		public float y;
	}

	public class JSONQuaternion
	{
		public void setValue(Vector4 q)
		{
			this.x = q.x;
			this.y = q.y;
			this.z = q.z;
			this.w = q.w;
		}

		public Quaternion toQuaternion()
		{
			return new Quaternion(this.x, this.y, this.z, this.w);
		}

		public float x;

		public float y;

		public float z;

		public float w;
	}

	public class JSONColor
	{
		public void setValue(Color c)
		{
			this.r = c.r;
			this.g = c.g;
			this.b = c.b;
			this.a = c.a;
		}

		public Color toColor()
		{
			return new Color(this.r, this.g, this.b, this.a);
		}

		public float r;

		public float g;

		public float b;

		public float a;
	}

	public class JSONRect
	{
		public void setValue(Rect r)
		{
			this.x = r.x;
			this.y = r.y;
			this.width = r.width;
			this.height = r.height;
		}

		public Rect toRect()
		{
			return new Rect(this.x, this.y, this.width, this.height);
		}

		public float x;

		public float y;

		public float width;

		public float height;
	}
}
