Decompiled source of AutoMoveCCMPlugin v1.2.1

AutoMoveCCMPlugin.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ModdingTales;
using Newtonsoft.Json;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AutoMoveCCMPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Nth Dimension")]
[assembly: AssemblyProduct("AutoMoveCCMPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("AutoMoveCCMPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.2.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.automovecmm", "Auto Move Plugin (CCM)", "1.2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AutoMovePlugin : BaseUnityPlugin
{
	public static class CreatureBoardAsset_DropAtLocation_Patch
	{
		public static bool Prefix(Vector3 pos)
		{
			return true;
		}

		public static void Postfix(object __instance, Vector3 pos)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			LoggingPlugin.LogDebug("Asset DropAtLocation Patch");
			string text = Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(__instance).ToString();
			LoggingPlugin.LogDebug("Asset Name: " + text);
			object cid = Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(__instance);
			LoggingPlugin.LogDebug("Asset Cid: " + cid.ToString());
			Transform val = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(__instance);
			LoggingPlugin.LogDebug("Asset " + text + " (" + cid?.ToString() + ") Moved");
			foreach (PathApplication movingAsset in _self.movingAssets)
			{
				LoggingPlugin.LogDebug("Moving Asset Cid " + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(movingAsset.asset)?.ToString() + " Vs This Cid " + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(__instance));
			}
			List<PathApplication> list = _self.movingAssets.Where((PathApplication ma) => Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(ma.asset) == cid).ToList();
			if (list.Count > 0)
			{
				LoggingPlugin.LogDebug("Asset " + text + " (" + cid?.ToString() + ") Is A Auto Move Asset");
				if (list[0].proximity > 0f)
				{
					LoggingPlugin.LogDebug("Asset " + text + " (" + cid?.ToString() + ") Is A Auto Move Asset With Proximity " + list[0].proximity);
					{
						foreach (object item in _self.GetAssetsByType(AssetType.pc))
						{
							string text2 = Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(item).ToString();
							object value = Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(item);
							Transform val2 = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(item);
							string[] obj = new string[11]
							{
								"Asset ",
								text,
								" (",
								cid?.ToString(),
								") Is ",
								null,
								null,
								null,
								null,
								null,
								null
							};
							Vector3 val3 = val.position - val2.position;
							obj[5] = ((Vector3)(ref val3)).magnitude.ToString();
							obj[6] = " Away From ";
							obj[7] = text2;
							obj[8] = " (";
							obj[9] = value?.ToString();
							obj[10] = ")";
							LoggingPlugin.LogDebug(string.Concat(obj));
							val3 = val.position - val2.position;
							if ((double)((Vector3)(ref val3)).magnitude < (double)list[0].proximity + 0.5)
							{
								string[] obj2 = new string[10]
								{
									"Asset ",
									text,
									" (",
									cid?.ToString(),
									") Stopped By Proximity To ",
									text2,
									" (",
									value?.ToString(),
									"). Distance = ",
									null
								};
								val3 = val.position - val2.position;
								obj2[9] = ((Vector3)(ref val3)).magnitude.ToString();
								LoggingPlugin.LogDebug(string.Concat(obj2));
								list[0].paused = true;
								break;
							}
						}
						return;
					}
				}
				LoggingPlugin.LogDebug("Asset " + text + " (" + cid?.ToString() + ") Proximity Is Set To " + list[0].proximity);
			}
			else
			{
				LoggingPlugin.LogDebug("No Players Found");
			}
		}
	}

	public class P3
	{
		public float x { get; set; }

		public float y { get; set; }

		public float z { get; set; }

		public P3()
		{
		}

		public P3(float x, float y, float z)
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public P3(Vector3 pos)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			x = pos.x;
			y = pos.y;
			z = pos.z;
		}

		public Vector3 ToVector3()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, y, z);
		}

		public override string ToString()
		{
			return x + "," + y + "," + z;
		}
	}

	public class Path
	{
		public string name { get; set; } = "";


		public List<P3> steps { get; set; } = new List<P3>();

	}

	public class PathApplication
	{
		public string pathName { get; set; } = "";


		public P3 appliedAt { get; set; } = new P3(0f, 0f, 0f);


		public float proximity { get; set; } = 0f;


		public bool paused { get; set; } = false;


		public ushort step { get; set; } = 0;


		public object asset { get; set; }
	}

	public enum OperationMode
	{
		RealTimeMode = 1,
		TurnBasedMode
	}

	public enum AssetType
	{
		pc,
		npc
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass45_0
	{
		public AutoMovePlugin <>4__this;

		public AssetInfo info;
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass45_1
	{
		public object cid;

		public <>c__DisplayClass45_0 CS$<>8__locals1;
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass45_2
	{
		public Transform rotator;

		public <>c__DisplayClass45_1 CS$<>8__locals2;

		internal void <ProcessAssetSelection>b__0(object proximity)
		{
			CS$<>8__locals2.CS$<>8__locals1.<>4__this.SetPath(CS$<>8__locals2.CS$<>8__locals1.info, CS$<>8__locals2.cid, int.Parse(proximity.ToString()), rotator);
		}
	}

	[CompilerGenerated]
	private sealed class <MoveAssets>d__39 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public float stepDelay;

		public AutoMovePlugin <>4__this;

		private List<PathApplication>.Enumerator <>s__1;

		private PathApplication <mini>5__2;

		private Transform <rotator>5__3;

		private Vector3 <delta>5__4;

		private Vector3 <abs>5__5;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveAssets>d__39(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = default(List<PathApplication>.Enumerator);
			<mini>5__2 = null;
			<rotator>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			LoggingPlugin.LogTrace("Executing Mini Step(s)");
			<>s__1 = <>4__this.movingAssets.GetEnumerator();
			try
			{
				while (<>s__1.MoveNext())
				{
					<mini>5__2 = <>s__1.Current;
					LoggingPlugin.LogDebug("Considering Mini " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(<mini>5__2.asset)?.ToString() + " (" + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(<mini>5__2.asset)?.ToString() + ")");
					if (!<mini>5__2.paused)
					{
						LoggingPlugin.LogDebug("Moving Mini " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(<mini>5__2.asset)?.ToString() + " (" + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(<mini>5__2.asset)?.ToString() + ") Using " + <mini>5__2.pathName);
						<rotator>5__3 = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(<mini>5__2.asset);
						<mini>5__2.step++;
						if (<mini>5__2.step >= <>4__this.paths[<mini>5__2.pathName].steps.Count)
						{
							<mini>5__2.step = 0;
							<delta>5__4 = Vector3.zero;
							LoggingPlugin.LogDebug("Mini " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(<mini>5__2.asset)?.ToString() + " (" + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(<mini>5__2.asset)?.ToString() + ") Path Loop To " + <mini>5__2.appliedAt);
						}
						else
						{
							<delta>5__4 = <>4__this.paths[<mini>5__2.pathName].steps.ElementAt(<mini>5__2.step).ToVector3();
							string[] obj = new string[6]
							{
								"Mini ",
								Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(<mini>5__2.asset)?.ToString(),
								" (",
								Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(<mini>5__2.asset)?.ToString(),
								") Moved To ",
								null
							};
							Vector3 val = <rotator>5__3.position + <delta>5__4;
							obj[5] = ((object)(Vector3)(ref val)).ToString();
							LoggingPlugin.LogTrace(string.Concat(obj));
						}
						<abs>5__5 = <mini>5__2.appliedAt.ToVector3() + <delta>5__4;
						<abs>5__5.y = <rotator>5__3.position.y;
						Reflection.Execute(Reflection.Method(_CreatureBoardAsset, "DropAtLocation", (string[])null), <mini>5__2.asset, new object[1] { <abs>5__5 }, 0);
						Reflection.Execute(Reflection.Method(_CreatureBoardAsset, "RotateTowards", (string[])null), <mini>5__2.asset, new object[1] { <abs>5__5 }, 0);
						<rotator>5__3 = null;
					}
					<mini>5__2 = null;
				}
			}
			finally
			{
				((IDisposable)<>s__1).Dispose();
			}
			<>s__1 = default(List<PathApplication>.Enumerator);
			if (<>4__this.stepMode.Value != OperationMode.TurnBasedMode)
			{
				LoggingPlugin.LogTrace("Executing Mini Step Wait");
				<>2__current = (object)new WaitForSeconds(stepDelay);
				<>1__state = 1;
				return true;
			}
			LoggingPlugin.LogTrace("Executing Mini Step Complete");
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <ProcessAssetSelection>d__45 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AssetInfo info;

		public AutoMovePlugin <>4__this;

		private <>c__DisplayClass45_0 <>8__1;

		private <>c__DisplayClass45_1 <>8__2;

		private object <asset>5__3;

		private <>c__DisplayClass45_2 <>8__4;

		private string <currentPath>5__5;

		private Exception <e>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ProcessAssetSelection>d__45(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>8__1 = null;
			<>8__2 = null;
			<asset>5__3 = null;
			<>8__4 = null;
			<currentPath>5__5 = null;
			<e>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>8__1 = new <>c__DisplayClass45_0();
				<>8__1.<>4__this = <>4__this;
				<>8__1.info = info;
				LoggingPlugin.LogDebug("Processing Menu Request");
				try
				{
					<>8__2 = new <>c__DisplayClass45_1();
					<>8__2.CS$<>8__locals1 = <>8__1;
					<>8__2.cid = Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null);
					LoggingPlugin.LogDebug("CCM Selection: Path " + <>8__2.CS$<>8__locals1.info.name + " On Creature " + <>8__2.cid.ToString());
					<asset>5__3 = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2] { <>8__2.cid, null }, 2);
					if (<asset>5__3 != null)
					{
						<>8__4 = new <>c__DisplayClass45_2();
						<>8__4.CS$<>8__locals2 = <>8__2;
						<>8__4.rotator = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(<asset>5__3);
						<currentPath>5__5 = AssetDataPlugin.ReadInfo(<>8__4.CS$<>8__locals2.cid.ToString(), "org.lordashes.plugins.automovecmm");
						LoggingPlugin.LogDebug("Current Creature " + <>8__4.CS$<>8__locals2.cid.ToString() + " Path Is " + ((<currentPath>5__5 == null || <currentPath>5__5 == "") ? "Null. Set Path." : (<currentPath>5__5 + ". Remove Path.")));
						if (<currentPath>5__5 == null || <currentPath>5__5 == "")
						{
							Reflection.Execute(Reflection.Method(_SystemMessage, "AskForTextInput", new string[9] { "System.String", "System.String", "System.Int32", "System.String", "System.Action`1[System.String]", "System.Action", "System.String", "System.Action", "System.String" }), (object)null, new object[9]
							{
								"Path Name",
								"Stop If PC Is Within N Tiles (0=OFF):",
								1,
								"Apply",
								(Action<object>)delegate(object proximity)
								{
									<>8__4.CS$<>8__locals2.CS$<>8__locals1.<>4__this.SetPath(<>8__4.CS$<>8__locals2.CS$<>8__locals1.info, <>8__4.CS$<>8__locals2.cid, int.Parse(proximity.ToString()), <>8__4.rotator);
								},
								null,
								"Cancel",
								null,
								"0"
							}, 0);
						}
						else
						{
							LoggingPlugin.LogDebug("Clear Path On Creature " + <>8__4.CS$<>8__locals2.cid.ToString());
							AssetDataPlugin.ClearInfo(<>8__4.CS$<>8__locals2.cid.ToString(), "org.lordashes.plugins.automovecmm", false);
						}
						<>8__4 = null;
						<currentPath>5__5 = null;
					}
					<>8__2 = null;
					<asset>5__3 = null;
				}
				catch (Exception ex)
				{
					<e>5__6 = ex;
					Reflection.CatchFullError(<e>5__6);
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <RegisterAssets>d__44 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public ReadOnlyDictionary<string, AssetInfo> existingAssets;

		public Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback;

		public AutoMovePlugin <>4__this;

		private string <cacheFolder>5__1;

		private Texture2D <portrait>5__2;

		private byte[] <pngData>5__3;

		private Dictionary<string, AssetInfo> <assets>5__4;

		private Dictionary<string, Path>.ValueCollection.Enumerator <>s__5;

		private Path <path>5__6;

		private AssetInfo <assetInfo>5__7;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RegisterAssets>d__44(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			int num = <>1__state;
			if (num == -3 || num == 1)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<cacheFolder>5__1 = null;
			<portrait>5__2 = null;
			<pngData>5__3 = null;
			<assets>5__4 = null;
			<>s__5 = default(Dictionary<string, Path>.ValueCollection.Enumerator);
			<path>5__6 = null;
			<assetInfo>5__7 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			try
			{
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -3;
					File.WriteAllBytes(<cacheFolder>5__1 + "/Portrait." + <assetInfo>5__7.prefab + ".png", <pngData>5__3, (CacheType)999);
					<assetInfo>5__7 = null;
					goto IL_022d;
				}
				<>1__state = -1;
				<>4__this.LoadPaths();
				<cacheFolder>5__1 = Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/";
				<portrait>5__2 = Image.LoadTexture("org.lordashes.plugins.automovecmm.png", (CacheType)999);
				<pngData>5__3 = ImageConversion.EncodeToPNG(<portrait>5__2);
				<assets>5__4 = new Dictionary<string, AssetInfo>();
				<>s__5 = <>4__this.paths.Values.GetEnumerator();
				<>1__state = -3;
				goto IL_0235;
				IL_022d:
				<path>5__6 = null;
				goto IL_0235;
				IL_0235:
				if (<>s__5.MoveNext())
				{
					<path>5__6 = <>s__5.Current;
					if (!existingAssets.ContainsKey(<path>5__6.name))
					{
						<assetInfo>5__7 = new AssetInfo
						{
							provider = "AutoMove",
							filename = "Path:" + <path>5__6.name,
							pack = "AutoMoveCore",
							prefab = <path>5__6.name,
							name = <path>5__6.name,
							kind = "Creature",
							category = "Path",
							header = "Relative Paths",
							groupName = "Registered Paths",
							description = "Relative Path For Auto Move Plugin",
							author = "Lord Ashes",
							comment = "Auto Move Plugin",
							hasAnimations = false,
							hasAudio = false,
							hasBlendshapes = false,
							tags = "Move,Plugin"
						};
						<assets>5__4.Add(<assetInfo>5__7.prefab, <assetInfo>5__7);
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 1;
						return true;
					}
					goto IL_022d;
				}
				<>m__Finally1();
				<>s__5 = default(Dictionary<string, Path>.ValueCollection.Enumerator);
				LoggingPlugin.LogDebug("Sending CCM Registration For " + <assets>5__4.Count + " New Auto Move Assets");
				((MonoBehaviour)_self).StartCoroutine(callback(<assets>5__4, "AutoMove"));
				return false;
			}
			catch
			{
				//try-fault
				((IDisposable)this).Dispose();
				throw;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		private void <>m__Finally1()
		{
			<>1__state = -1;
			((IDisposable)<>s__5).Dispose();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <WarnAboutLogLevel>d__49 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AutoMovePlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <WarnAboutLogLevel>d__49(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			try
			{
				MethodInfo methodInfo = Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null);
				object[] array = new object[4];
				DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
				array[0] = "Auto Move Plugin (CCM): Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance";
				array[1] = 10;
				array[2] = Type.Missing;
				array[3] = Type.Missing;
				Reflection.Execute(methodInfo, (object)null, array, 0);
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Plugin (CCM): Use 'Debug' or 'Trace' for\r\ntroubleshooting only.",
					10,
					Type.Missing,
					Type.Missing
				}, 0);
			}
			catch
			{
				goto IL_00ce;
			}
			return false;
			IL_00ce:
			<>2__current = (object)new WaitForSeconds(1f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string Name = "Auto Move Plugin (CCM)";

	public const string Guid = "org.lordashes.plugins.automovecmm";

	public const string Version = "1.2.0.0";

	public const string Author = "Lord Ashes";

	public static AutoMovePlugin _self = null;

	public ConfigEntry<KeyboardShortcut> triggerStartRecord;

	public ConfigEntry<KeyboardShortcut> triggerStepRecord;

	public ConfigEntry<KeyboardShortcut> triggerEndRecord;

	public ConfigEntry<KeyboardShortcut> triggerDeleteLastStep;

	public ConfigEntry<KeyboardShortcut> triggerApplyPath;

	public ConfigEntry<KeyboardShortcut> triggerRemovePath;

	public ConfigEntry<KeyboardShortcut> triggerPausePath;

	public ConfigEntry<KeyboardShortcut> triggerModeChange;

	public ConfigEntry<KeyboardShortcut> triggerManualStep;

	public Dictionary<string, Path> paths = null;

	public List<PathApplication> movingAssets = new List<PathApplication>();

	public Path newPath = new Path();

	public Vector3 recordingPositionReference = Vector3.zero;

	public List<PathApplication> pathsToAdd = new List<PathApplication>();

	public List<object> pathsToRemove = new List<object>();

	public ConfigEntry<float> stepDelay;

	public ConfigEntry<OperationMode> stepMode;

	public static Type _CampaignSessionManager = Reflection.Type("CampaignSessionManager", (string[])null, (string[])null, 0);

	public static Type _CreatureBoardAsset = Reflection.Type("CreatureBoardAsset", (string[])null, (string[])null, 0);

	public static Type _CreatureGuid = Reflection.Type("CreatureGuid", (string[])null, (string[])null, 0);

	public static Type _CreatureManager = Reflection.Type("CreatureManager", (string[])null, (string[])null, 0);

	public static Type _CreaturePresenter = Reflection.Type("CreaturePresenter", (string[])null, (string[])null, 0);

	public static Type _LocalClient = Reflection.Type("LocalClient", (string[])null, (string[])null, 0);

	public static Type _SystemMessage = Reflection.Type("SystemMessage", (string[])null, (string[])null, 0);

	public void ApplyPatch(Harmony harmony)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		//IL_0044: Expected O, but got Unknown
		harmony.Patch((MethodBase)Reflection.Method(_CreatureBoardAsset, "DropAtLocation", (string[])null), new HarmonyMethod(typeof(CreatureBoardAsset_DropAtLocation_Patch), "Prefix", (Type[])null), new HarmonyMethod(typeof(CreatureBoardAsset_DropAtLocation_Patch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private void Awake()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Invalid comparison between Unknown and I4
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Expected O, but got Unknown
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Expected O, but got Unknown
		_self = this;
		LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
		string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
		DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
		LoggingPlugin.LogInfo(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
		triggerStartRecord = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Start Recording A New Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)282 }), (ConfigDescription)null);
		triggerStepRecord = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Recording Step", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)283 }), (ConfigDescription)null);
		triggerDeleteLastStep = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Delete Last Step Of Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)284 }), (ConfigDescription)null);
		triggerEndRecord = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "End Recording A New Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)285 }), (ConfigDescription)null);
		triggerApplyPath = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Apply Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)277 }), (ConfigDescription)null);
		triggerRemovePath = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Remove Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)127 }), (ConfigDescription)null);
		triggerPausePath = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Pause Path", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)280 }), (ConfigDescription)null);
		triggerModeChange = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Mode", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)279 }), (ConfigDescription)null);
		triggerManualStep = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Manual Step", new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)281 }), (ConfigDescription)null);
		stepDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Step Delay", 1f, (ConfigDescription)null);
		stepMode = ((BaseUnityPlugin)this).Config.Bind<OperationMode>("Settings", "Step Mode", OperationMode.RealTimeMode, (ConfigDescription)null);
		AssetDataPlugin.Subscribe("org.lordashes.plugins.automovecmm", (Action<DatumChange>)ModifyAssetPath, (Func<DatumChange, bool>)Checker.CheckSourceAsCreature);
		string text = CommonCustomsMenuPlugin.RegisterProviderV2("AutoMove", "Auto Move Paths", "1.2.0.0", (Func<ReadOnlyDictionary<string, AssetInfo>, Func<Dictionary<string, AssetInfo>, string, IEnumerator>, IEnumerator>)RegisterAssets, (Action<AssetInfo>)delegate(AssetInfo assetInfo)
		{
			LoggingPlugin.LogDebug("CCM Selection");
			LoggingPlugin.LogTrace(JsonConvert.SerializeObject((object)assetInfo));
			((MonoBehaviour)_self).StartCoroutine(ProcessAssetSelection(assetInfo));
		});
		((MonoBehaviour)_self).StartCoroutine(MoveAssets(stepDelay.Value));
		if ((int)LoggingPlugin.GetLogLevel() >= 4)
		{
			((MonoBehaviour)this).StartCoroutine(WarnAboutLogLevel());
		}
		LoadPaths();
		ApplyPatch(new Harmony("org.lordashes.plugins.automovecmm"));
		ModdingUtils.Initialize((BaseUnityPlugin)(object)this, new ManualLogSource("Auto Move Plugin (CCM)"), "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s"), false);
	}

	private void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0413: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0966: Unknown result type (might be due to invalid IL or missing references)
		//IL_096b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0585: Unknown result type (might be due to invalid IL or missing references)
		//IL_058c: Expected O, but got Unknown
		//IL_0599: Unknown result type (might be due to invalid IL or missing references)
		//IL_059f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0619: Unknown result type (might be due to invalid IL or missing references)
		//IL_061f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0624: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dcc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dd1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0911: Unknown result type (might be due to invalid IL or missing references)
		//IL_0916: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0adb: Expected O, but got Unknown
		//IL_0afd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b2c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b51: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b8c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b91: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b94: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b99: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b9b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c08: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c14: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c33: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c5c: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = triggerApplyPath.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "AskForTextInput", (string[])null), (object)null, new object[8]
				{
					"Path Name",
					"Enter Path Name, Proximity:",
					"Add",
					(Action<object>)delegate(object pathName)
					{
						ApplyPath(pathName);
					},
					null,
					"Cancel",
					null,
					",0"
				}, 0);
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Apply Path' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerRemovePath.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				object obj = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2]
				{
					Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null),
					null
				}, 2);
				AssetDataPlugin.ClearInfo(Reflection.Property(obj.GetType(), "CreatureId", (string)null).GetValue(obj).ToString(), "org.lordashes.plugins.automovecmm", false);
				LoggingPlugin.LogDebug("Sending Path Remove Request To " + Reflection.Property(obj.GetType(), "Name", (string)null).GetValue(obj)?.ToString() + " (" + Reflection.Property(obj.GetType(), "CreatureId", (string)null).GetValue(obj)?.ToString() + ")");
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Remove Path' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerPausePath.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				for (int i = 0; i < movingAssets.Count; i++)
				{
					if (Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(movingAssets.ElementAt(i).asset) == Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null))
					{
						movingAssets.ElementAt(i).paused = !movingAssets.ElementAt(i).paused;
						LoggingPlugin.LogDebug("Toggling Path Pause To " + (movingAssets.ElementAt(i).paused ? "Paused" : "Not Paused") + " On Creature " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(movingAssets.ElementAt(i).asset)?.ToString() + " (" + Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(movingAssets.ElementAt(i).asset).ToString() + ")");
					}
				}
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Pause/Unpause Path' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerStartRecord.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "AskForTextInput", (string[])null), (object)null, new object[8]
				{
					"Path Name",
					"Enter Name For The New Path:",
					"Add",
					(Action<object>)delegate(object pathName)
					{
						StartRecording(pathName);
					},
					null,
					"Cancel",
					null,
					""
				}, 0);
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Start Record' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerStepRecord.Value;
		Vector3 val2;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				object obj2 = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2]
				{
					Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null),
					null
				}, 2);
				if (obj2 != null)
				{
					Transform val = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(obj2);
					newPath.steps.Add(new P3(val.position - recordingPositionReference));
					string[] obj3 = new string[8] { "Path '", newPath.name, "' Added Step ", null, null, null, null, null };
					val2 = val.position;
					obj3[3] = ((object)(Vector3)(ref val2)).ToString();
					obj3[4] = " - ";
					obj3[5] = ((object)(Vector3)(ref recordingPositionReference)).ToString();
					obj3[6] = " = ";
					obj3[7] = new P3(val.position - recordingPositionReference).ToString();
					LoggingPlugin.LogDebug(string.Concat(obj3));
					Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
					{
						"Recording Path '" + newPath.name + "' Step " + newPath.steps.Count,
						Type.Missing,
						Type.Missing,
						Type.Missing
					}, 0);
				}
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Record Step' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerEndRecord.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				if (newPath.name != null && newPath.name != "")
				{
					LoggingPlugin.LogDebug("Adding Path '" + newPath.name + "' To Paths");
					paths.Add(newPath.name.ToUpper(), newPath);
					LoggingPlugin.LogDebug("Getting Configuration File Location");
					string text = File.Find("org.lordashes.plugins.automovecmm.paths.json", (CacheType)999).FirstOrDefault();
					if (text == null)
					{
						LoggingPlugin.LogDebug("Creating Default Paths File");
						text = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/CustomData/org.lordashes.plugins.automovecmm.paths.json";
					}
					LoggingPlugin.LogDebug("Configuration File Location = " + text);
					File.WriteAllText(text, JsonConvert.SerializeObject((object)paths.Values, (Formatting)1), (CacheType)999);
					Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
					{
						"Saved Path '" + newPath.name + "' With " + newPath.steps.Count + ". Steps.",
						Type.Missing,
						Type.Missing,
						Type.Missing
					}, 0);
					LoggingPlugin.LogDebug("Saved Path '" + newPath.name + "' With " + newPath.steps.Count + ". Steps To " + text);
					newPath = new Path();
					recordingPositionReference = Vector3.zero;
				}
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'End Record' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerDeleteLastStep.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if ((bool)Reflection.Property(_LocalClient, "IsInGmMode", (string)null).GetValue(null))
			{
				if (newPath.name != null && newPath.name != "")
				{
					object obj4 = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2]
					{
						Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null),
						null
					}, 2);
					if (obj4 != null)
					{
						Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
						{
							"Deleted Path '" + newPath.name + "' Step " + newPath.steps.Count,
							Type.Missing,
							Type.Missing,
							Type.Missing
						}, 0);
						LoggingPlugin.LogDebug("Deleting Path '" + newPath.name + "' Step " + newPath.steps.Count);
						Transform val3 = (Transform)Reflection.Field(_CreatureBoardAsset, "Rotator", (string)null).GetValue(obj4);
						Vector3 val4 = newPath.steps.ElementAt(newPath.steps.Count - 1).ToVector3();
						newPath.steps.RemoveAt(newPath.steps.Count - 1);
						val4 = -1f * val4;
						Reflection.Execute(Reflection.Method(_CreatureBoardAsset, "MoveTo", (string[])null), obj4, new object[1] { val3.position + val4 }, 0);
						Vector3 val5 = newPath.steps.ElementAt(newPath.steps.Count - 1).ToVector3();
						Vector3 val6 = recordingPositionReference + val5;
						string[] obj5 = new string[6]
						{
							"Mini ",
							Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(obj4)?.ToString(),
							" (",
							Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(obj4).ToString(),
							") Moved To ",
							null
						};
						val2 = recordingPositionReference + val5;
						obj5[5] = ((object)(Vector3)(ref val2)).ToString();
						LoggingPlugin.LogTrace(string.Concat(obj5));
						val6.y = val3.position.y;
						Reflection.Execute(Reflection.Method(_CreatureBoardAsset, "DropAtLocation", (string[])null), obj4, new object[1] { val6 }, 0);
					}
				}
			}
			else
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Auto Move Operation 'Delete Last Step' Is Available To GM Only",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
		}
		value = triggerModeChange.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			if (stepMode.Value == OperationMode.RealTimeMode)
			{
				stepMode.Value = OperationMode.TurnBasedMode;
			}
			else
			{
				stepMode.Value = OperationMode.RealTimeMode;
			}
			Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
			{
				"Auto Move Plugin Set To " + ((stepMode.Value == OperationMode.RealTimeMode) ? "RealTime" : "Manual") + " Mode",
				Type.Missing,
				Type.Missing,
				Type.Missing
			}, 0);
			LoggingPlugin.LogDebug("Auto Move Plugin Set To " + ((stepMode.Value == OperationMode.RealTimeMode) ? "RealTime" : "Manual") + " Mode");
			if (stepMode.Value == OperationMode.RealTimeMode)
			{
				((MonoBehaviour)_self).StartCoroutine(MoveAssets(stepDelay.Value));
			}
		}
		value = triggerManualStep.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			LoggingPlugin.LogDebug("Manual Step");
			((MonoBehaviour)_self).StartCoroutine(MoveAssets(stepDelay.Value));
		}
		if (pathsToRemove.Count > 0)
		{
			foreach (object item in pathsToRemove)
			{
				for (int j = 0; j < movingAssets.Count; j++)
				{
					object value2 = Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(movingAssets.ElementAt(j).asset);
					LoggingPlugin.LogDebug("Found Asset Cid " + value2.ToString() + " While Searching For " + item.ToString());
					if (value2.ToString() == item.ToString())
					{
						LoggingPlugin.LogDebug("Removing Creature " + Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null).ToString() + " From MovingAssets");
						movingAssets.RemoveAt(j);
					}
				}
			}
			pathsToRemove.Clear();
		}
		if (pathsToAdd.Count > 0)
		{
			LoggingPlugin.LogTrace("Adding New Creatures To MovingAssets");
			movingAssets.AddRange(pathsToAdd);
			pathsToAdd.Clear();
			LoggingPlugin.LogTrace("Contains " + movingAssets.Count + " Auto Moving Assets");
		}
	}

	private void ApplyPath(object pathName)
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		string text = pathName.ToString().Substring(0, pathName.ToString().IndexOf(","));
		string text2 = pathName.ToString().Substring(pathName.ToString().IndexOf(",") + 1);
		if (paths.ContainsKey(text.ToUpper()))
		{
			object obj = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2]
			{
				Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null),
				null
			}, 0);
			Transform val = (Transform)Reflection.Field(obj.GetType(), "Rotator", (string)null).GetValue(obj);
			AssetDataPlugin.SetInfo(Reflection.Property(obj.GetType(), "CreatureId", (string)null).GetValue(obj).ToString(), "org.lordashes.plugins.automovecmm", pathName.ToString().ToUpper() + "," + new P3(val.position).ToString(), false);
			LoggingPlugin.LogDebug("Sending Path '" + pathName?.ToString() + "' Add Request To " + Reflection.Property(obj.GetType(), "CreatureId", (string)null).GetValue(obj)?.ToString() + " (" + Reflection.Property(obj.GetType(), "CreatureId", (string)null).GetValue(obj).ToString() + ")");
		}
		else
		{
			Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
			{
				"Path '" + pathName?.ToString() + "' Does Not Exist. No Path Added To Selected Creature.",
				Type.Missing,
				Type.Missing,
				Type.Missing
			}, 0);
		}
	}

	private void StartRecording(object pathName)
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		object obj = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2]
		{
			Reflection.Property(_LocalClient, "SelectedCreatureId", (string)null).GetValue(null),
			null
		}, 2);
		if (obj != null)
		{
			Transform val = (Transform)Reflection.Field(obj.GetType(), "Rotator", (string)null).GetValue(obj);
			newPath = new Path
			{
				name = pathName.ToString()
			};
			recordingPositionReference = val.position;
			Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
			{
				"Started Recording Path '" + pathName?.ToString() + "'. Step 1 recorded.",
				Type.Missing,
				Type.Missing,
				Type.Missing
			}, 0);
			newPath.steps.Add(new P3(Vector3.zero));
		}
	}

	[IteratorStateMachine(typeof(<MoveAssets>d__39))]
	private IEnumerator MoveAssets(float stepDelay)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveAssets>d__39(0)
		{
			<>4__this = this,
			stepDelay = stepDelay
		};
	}

	private void ModifyAssetPath(DatumChange change)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected I4, but got Unknown
		LoggingPlugin.LogTrace("Path: ModifyAssetPath");
		string[] obj = new string[5] { "Remote Path Request For Action ", null, null, null, null };
		ChangeAction action = change.action;
		obj[1] = ((object)(ChangeAction)(ref action)).ToString();
		obj[2] = " To Asset ";
		obj[3] = change.source;
		obj[4] = (((int)change.action != 1) ? (" And Value " + ((change.value == null) ? "Null" : change.value)) : "");
		LoggingPlugin.LogDebug(string.Concat(obj));
		if ((int)change.action == 0 && paths == null)
		{
			LoadPaths();
		}
		LoggingPlugin.LogDebug("Number Of Paths Defined = " + ((paths != null) ? paths.Count.ToString() : "0"));
		string[] array = null;
		ChangeAction action2 = change.action;
		ChangeAction val = action2;
		switch ((int)val)
		{
		case 0:
		case 2:
			LoggingPlugin.LogTrace("Processing Initial/Add Request");
			array = change.value.ToString().Split(new char[1] { ',' });
			AddPath(change.source, array[0], float.Parse(array[1], CultureInfo.InvariantCulture), new P3(float.Parse(array[2], CultureInfo.InvariantCulture), float.Parse(array[3], CultureInfo.InvariantCulture), float.Parse(array[4], CultureInfo.InvariantCulture)));
			break;
		case 1:
			LoggingPlugin.LogTrace("Processing Remove Request");
			RemovePath(change.source);
			break;
		case 3:
			LoggingPlugin.LogTrace("Processing Modify:Remove Request");
			RemovePath(change.source);
			LoggingPlugin.LogTrace("Processing Modify:Add Request");
			array = change.value.ToString().Split(new char[1] { ',' });
			AddPath(change.source, array[0], float.Parse(array[1], CultureInfo.InvariantCulture), new P3(float.Parse(array[2], CultureInfo.InvariantCulture), float.Parse(array[3], CultureInfo.InvariantCulture), float.Parse(array[4], CultureInfo.InvariantCulture)));
			break;
		}
		LoggingPlugin.LogTrace("Path Exit: ModifyAssetPath");
	}

	private void AddPath(object cidString, string pathName, float proximity, P3 startPos)
	{
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		LoggingPlugin.LogTrace("Adding Path To Add Stack");
		object obj = Reflection.New(_CreatureGuid, new object[1] { cidString.ToString() });
		object obj2 = Reflection.Execute(Reflection.Method(_CreaturePresenter, "TryGetAsset", (string[])null), (object)null, new object[2] { obj, null }, 2);
		if (obj2 != null)
		{
			string text = Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(obj2).ToString();
			object obj3 = Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(obj2).ToString();
			LoggingPlugin.LogDebug("Obtained reference to creature " + text + " (" + obj3?.ToString() + ")");
			pathsToAdd.Add(new PathApplication
			{
				appliedAt = startPos,
				pathName = pathName.ToUpper(),
				asset = obj2,
				proximity = proximity,
				paused = false,
				step = ushort.MaxValue
			});
			LoggingPlugin.LogDebug("Dropping creature " + text + " (" + obj3?.ToString() + "/" + obj?.ToString() + ")");
			Reflection.Execute(Reflection.Method(_CreatureBoardAsset, "DropAtLocation", (string[])null), obj2, new object[1] { startPos.ToVector3() }, 0);
			LoggingPlugin.LogDebug("Displaying system message for creature " + text + " (" + obj3?.ToString() + "/" + obj?.ToString() + ")");
			try
			{
				Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
				{
					"Path '" + pathName + "' Added To Creature " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(obj2)?.ToString() + " (" + obj.ToString() + ")",
					Type.Missing,
					Type.Missing,
					Type.Missing
				}, 0);
			}
			catch (Exception ex)
			{
				LoggingPlugin.LogDebug("Failed To Generate System Message");
				Reflection.CatchFullError(ex);
			}
			LoggingPlugin.LogDebug("Path '" + pathName + "' Added To Creature " + Reflection.Property(_CreatureBoardAsset, "Name", (string)null).GetValue(obj2)?.ToString() + " (" + obj.ToString() + ")");
		}
		else
		{
			LoggingPlugin.LogTrace("Referenced Asset Is Null");
		}
	}

	private void RemovePath(object cid)
	{
		pathsToRemove.Add(cid);
		Reflection.Execute(Reflection.Method(_SystemMessage, "DisplayInfoText", (string[])null), (object)null, new object[4]
		{
			"Path Removed From Creature " + cid,
			Type.Missing,
			Type.Missing,
			Type.Missing
		}, 0);
		LoggingPlugin.LogDebug("Path Removed From Creature " + cid);
	}

	private void LoadPaths()
	{
		LoggingPlugin.LogTrace("Path: LoadPaths");
		try
		{
			LoggingPlugin.LogDebug("Getting Path File Content");
			string text = File.ReadAllText("org.lordashes.plugins.automovecmm.paths.json", (CacheType)999);
			LoggingPlugin.LogTrace("Path File Content:\r\n" + text);
			paths = new Dictionary<string, Path>();
			Path[] array = JsonConvert.DeserializeObject<Path[]>(text);
			foreach (Path path in array)
			{
				paths.Add(path.name.ToUpper(), path);
			}
			LoggingPlugin.LogInfo("Loaded " + paths.Count + " Paths (" + string.Join(",", paths.Keys) + ")");
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogInfo("No Paths File Found. Error: " + ex.Message);
			paths = new Dictionary<string, Path>();
		}
		LoggingPlugin.LogTrace("Path Exit: LoadPaths");
	}

	[IteratorStateMachine(typeof(<RegisterAssets>d__44))]
	private IEnumerator RegisterAssets(ReadOnlyDictionary<string, AssetInfo> existingAssets, Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RegisterAssets>d__44(0)
		{
			<>4__this = this,
			existingAssets = existingAssets,
			callback = callback
		};
	}

	[IteratorStateMachine(typeof(<ProcessAssetSelection>d__45))]
	private IEnumerator ProcessAssetSelection(AssetInfo info)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ProcessAssetSelection>d__45(0)
		{
			<>4__this = this,
			info = info
		};
	}

	private void SetPath(AssetInfo info, object cid, float proximity, Transform rotator)
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		LoggingPlugin.LogDebug("Set Path " + info.name + " On Creature " + cid.ToString());
		AssetDataPlugin.SetInfo(cid.ToString(), "org.lordashes.plugins.automovecmm", info.prefab + "," + proximity + "," + rotator.position.x + "," + rotator.position.y + "," + rotator.position.z, false);
	}

	public List<object> GetAssetsByType(AssetType assetType)
	{
		List<object> pcs = new List<object>();
		foreach (object key in ((Dictionary<object, object>)Reflection.Field(_CampaignSessionManager, "PlayersInfo", (string)null).GetValue(null)).Keys)
		{
			string text = (string)Reflection.Execute(Reflection.Method(_CampaignSessionManager, "GetPlayerName", (string[])null), (object)null, new object[1] { key }, 0);
			LoggingPlugin.LogDebug("Checking Owned Assets Of Player " + text + " (" + key.ToString() + ")");
			object[] array = null;
			Reflection.Execute(Reflection.Method(_CreatureManager, "TryGetPlayerOwnedCreatureIds", (string[])null), (object)null, new object[2] { key, array }, 0);
			LoggingPlugin.LogDebug("Player " + text + " (" + key.ToString() + ") Owns " + array.Length + " Assets (" + string.Join(",", array) + ")");
			pcs.AddRange(array);
		}
		if (assetType == AssetType.pc)
		{
			return ((object[])Reflection.Execute(Reflection.Method(_CreaturePresenter, "GetTempReadOnlyViewOfAllCreatureAssets", (string[])null), (object)null, new object[0], 0)).Where((object a) => pcs.Contains(Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(a))).ToList();
		}
		return ((object[])Reflection.Execute(Reflection.Method(_CreaturePresenter, "GetTempReadOnlyViewOfAllCreatureAssets", (string[])null), (object)null, new object[0], 0)).Where((object a) => !pcs.Contains(Reflection.Property(_CreatureBoardAsset, "CreatureId", (string)null).GetValue(a))).ToList();
	}

	[IteratorStateMachine(typeof(<WarnAboutLogLevel>d__49))]
	private IEnumerator WarnAboutLogLevel()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <WarnAboutLogLevel>d__49(0)
		{
			<>4__this = this
		};
	}
}