using System;
using UnityEngine;

[Serializable]
public class AMTranslationAction : AMAction
{
	public override string ToString(int codeLanguage, int frameRate)
	{
		if (this.path.Length <= 1)
		{
			return null;
		}
		if (this.getNumberOfFrames() <= 0)
		{
			return null;
		}
		string text;
		if (codeLanguage == 0)
		{
			text = string.Concat(new object[]
			{
				"AMTween.MoveTo (obj.gameObject, AMTween.Hash (\"delay\", ",
				base.getWaitTime(frameRate, 0f),
				"f, \"time\", ",
				this.getTime(frameRate),
				"f, "
			});
			if (this.path.Length == 2)
			{
				text += "\"position\", ";
				string text2 = text;
				text = string.Concat(new object[]
				{
					text2,
					"new Vector3(",
					this.path[1].x,
					"f, ",
					this.path[1].y,
					"f, ",
					this.path[1].z,
					"f), "
				});
			}
			else
			{
				text += "\"path\", new Vector3[]{";
				for (int i = 0; i < this.path.Length; i++)
				{
					string text2 = text;
					text = string.Concat(new object[]
					{
						text2,
						"new Vector3(",
						this.path[i].x,
						"f, ",
						this.path[i].y,
						"f, ",
						this.path[i].z,
						"f)"
					});
					if (i < this.path.Length - 1)
					{
						text += ", ";
					}
				}
				text += "}, ";
			}
			text = text + base.getEaseString(codeLanguage) + "));";
		}
		else
		{
			text = string.Concat(new object[]
			{
				"AMTween.MoveTo (obj.gameObject, {\"delay\": ",
				base.getWaitTime(frameRate, 0f),
				", \"time\": ",
				this.getTime(frameRate),
				", "
			});
			if (this.path.Length == 2)
			{
				text += "\"position\": ";
				string text2 = text;
				text = string.Concat(new object[]
				{
					text2,
					" Vector3(",
					this.path[1].x,
					", ",
					this.path[1].y,
					", ",
					this.path[1].z,
					"), "
				});
			}
			else
			{
				text += "\"path\": [";
				for (int j = 0; j < this.path.Length; j++)
				{
					string text2 = text;
					text = string.Concat(new object[]
					{
						text2,
						" Vector3(",
						this.path[j].x,
						", ",
						this.path[j].y,
						", ",
						this.path[j].z,
						")"
					});
					if (j < this.path.Length - 1)
					{
						text += ", ";
					}
				}
				text += "], ";
			}
			text = text + base.getEaseString(codeLanguage) + "});";
		}
		return text;
	}

	public override int getNumberOfFrames()
	{
		return this.endFrame - this.startFrame;
	}

	public float getTime(int frameRate)
	{
		return (float)this.getNumberOfFrames() / (float)frameRate;
	}

	public override void execute(int frameRate, float delay, string trackId)
	{
		if (!this.obj)
		{
			return;
		}
		if (this.path.Length <= 1)
		{
			return;
		}
		if (this.getNumberOfFrames() <= 0)
		{
			return;
		}
		if (this.path.Length == 2)
		{
			if (base.hasCustomEase())
			{
				AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
				{
					"trackid",
					trackId,
					"delay",
					base.getWaitTime(frameRate, delay),
					"time",
					this.getTime(frameRate),
					"position",
					this.path[1],
					"easecurve",
					base.easeCurve
				}));
			}
			else
			{
				AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
				{
					"trackid",
					trackId,
					"delay",
					base.getWaitTime(frameRate, delay),
					"time",
					this.getTime(frameRate),
					"position",
					this.path[1],
					"easetype",
					(AMTween.EaseType)this.easeType
				}));
			}
			return;
		}
		if (base.hasCustomEase())
		{
			AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
			{
				"trackid",
				trackId,
				"delay",
				base.getWaitTime(frameRate, delay),
				"time",
				this.getTime(frameRate),
				"path",
				this.path,
				"easecurve",
				base.easeCurve
			}));
		}
		else
		{
			AMTween.MoveTo(this.obj.gameObject, AMTween.Hash(new object[]
			{
				"trackid",
				trackId,
				"delay",
				base.getWaitTime(frameRate, delay),
				"time",
				this.getTime(frameRate),
				"path",
				this.path,
				"easetype",
				(AMTween.EaseType)this.easeType
			}));
		}
	}

	public override AnimatorTimeline.JSONAction getJSONAction(int frameRate)
	{
		if (!this.obj)
		{
			return null;
		}
		if (this.path.Length <= 1)
		{
			return null;
		}
		if (this.getNumberOfFrames() <= 0)
		{
			return null;
		}
		AnimatorTimeline.JSONAction jsonaction = new AnimatorTimeline.JSONAction();
		jsonaction.go = this.obj.gameObject.name;
		jsonaction.method = "moveto";
		jsonaction.delay = base.getWaitTime(frameRate, 0f);
		jsonaction.time = this.getTime(frameRate);
		base.setupJSONActionEase(jsonaction);
		if (this.path.Length == 2)
		{
			jsonaction.setPath(new Vector3[]
			{
				this.path[1]
			});
		}
		else
		{
			jsonaction.setPath(this.path);
		}
		return jsonaction;
	}

	public int endFrame;

	public Transform obj;

	public Vector3[] path;
}
