Decompiled source of RemoteControlPlugin v3.0.0

RemoteControlPlugin.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Bounce.ManagedCollections;
using Bounce.Singletons;
using Newtonsoft.Json;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.SceneManagement;

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

[BepInPlugin("org.lordashes.plugins.remotecontrol", "Remote Control Plug-In", "3.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RemoteControlPlugin : BaseUnityPlugin
{
	public class StateObject
	{
		public const int BufferSize = 1024;

		public byte[] buffer = new byte[1024];

		public StringBuilder sb = new StringBuilder();

		public Socket workSocket = null;
	}

	public static class AsynchronousSocketListener
	{
		private static Socket listener;

		public static void StartListening(int port, Action<Socket, string> callback, bool diagnostics = false)
		{
			_diagnostics = diagnostics;
			_callback = callback;
			IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Creating Socket");
			}
			listener = new Socket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
			try
			{
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Binding To End Point");
				}
				listener.Bind(localEP);
				listener.Listen(100);
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Accept");
				}
				listener.BeginAccept(AcceptCallback, listener);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)ex);
			}
		}

		public static void AcceptCallback(IAsyncResult ar)
		{
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Accept Callback");
			}
			Socket socket = (Socket)ar.AsyncState;
			Socket socket2 = socket.EndAccept(ar);
			StateObject stateObject = new StateObject();
			stateObject.workSocket = socket2;
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Begin Data Read");
			}
			socket2.BeginReceive(stateObject.buffer, 0, 1024, SocketFlags.None, ReadCallback, stateObject);
		}

		public static void ReadCallback(IAsyncResult ar)
		{
			string empty = string.Empty;
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Get Read State");
			}
			StateObject stateObject = (StateObject)ar.AsyncState;
			Socket workSocket = stateObject.workSocket;
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Get Bytes");
			}
			int num = workSocket.EndReceive(ar);
			if (num <= 0)
			{
				return;
			}
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Append Bytes To Message");
			}
			stateObject.sb.Append(Encoding.ASCII.GetString(stateObject.buffer, 0, num));
			empty = stateObject.sb.ToString();
			if (empty.IndexOf("\n") > -1)
			{
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Reading Line Complete");
				}
				_callback(workSocket, empty);
				Send(workSocket, empty);
			}
			else
			{
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Reading Line Incomplete");
				}
				workSocket.BeginReceive(stateObject.buffer, 0, 1024, SocketFlags.None, ReadCallback, stateObject);
			}
		}

		public static void Send(Socket handler, string data)
		{
			byte[] bytes = Encoding.ASCII.GetBytes(data);
			if (_diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Server: Send Begin");
			}
			handler.BeginSend(bytes, 0, bytes.Length, SocketFlags.None, SendCallback, handler);
		}

		private static void SendCallback(IAsyncResult ar)
		{
			try
			{
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Send Data");
				}
				Socket socket = (Socket)ar.AsyncState;
				int num = socket.EndSend(ar);
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Close Connection");
				}
				socket.Shutdown(SocketShutdown.Both);
				socket.Close();
				socket.Dispose();
				if (_diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Server: Wait For New Connection");
				}
				listener.BeginAccept(AcceptCallback, listener);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)ex);
			}
		}
	}

	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		public static bool isBoardLoaded()
		{
			return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}

		public static GameObject GetRootLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Type typeFromHandle = typeof(CreatureBoardAsset);
				foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
				{
					if (runtimeField.Name == "_creatureRoot")
					{
						Transform val2 = (Transform)runtimeField.GetValue(val);
						return ((Component)val2).gameObject;
					}
				}
			}
			return null;
		}

		public static GameObject GetBaseLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Type typeFromHandle = typeof(CreatureBoardAsset);
				foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
				{
					if (runtimeField.Name == "_base")
					{
						CreatureBase val2 = (CreatureBase)runtimeField.GetValue(val);
						return ((Component)((Component)val2).transform.GetChild(0)).gameObject;
					}
				}
			}
			return null;
		}

		public static GameObject GetAssetLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Type typeFromHandle = typeof(CreatureBoardAsset);
				foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
				{
					if (runtimeField.Name == "_creatureRoot")
					{
						Transform val2 = (Transform)runtimeField.GetValue(val);
						return ((Component)val2.GetChild(0).GetChild(2).GetChild(0)).gameObject;
					}
				}
			}
			return null;
		}
	}

	private class MoveRequest
	{
		public Vector3 delta { get; set; } = Vector3.zero;


		public string style { get; set; } = "Teleport";

	}

	public class Rotations
	{
		public float axisX { get; set; } = 0f;


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


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

	}

	public class Step
	{
		public float path { get; set; }

		public float tangent { get; set; }

		public float elevation { get; set; }

		public Rotations rotations { get; set; }

		public float delay { get; set; }
	}

	public class Mover
	{
		public string name { get; set; }

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

	}

	private static Action<Socket, string> _callback = null;

	private static bool _diagnostics = false;

	public const string Name = "Remote Control Plug-In";

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

	public const string Version = "3.0.0.0";

	public static bool diagnostics = false;

	private static RemoteControlPlugin self = null;

	private static Dictionary<CreatureGuid, List<MoveRequest>> animationRequest = new Dictionary<CreatureGuid, List<MoveRequest>>();

	private static Dictionary<CreatureGuid, float> animatingCreatures = new Dictionary<CreatureGuid, float>();

	private static Dictionary<string, Mover> movers = new Dictionary<string, Mover>();

	private static float speedModifier = 1f;

	private static float speedRunModifier = 1f;

	public static KeyboardShortcut startControlServer { get; set; }

	private void Awake()
	{
		self = this;
		diagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Setting", "Include Server Diagnostic Logs", false, (ConfigDescription)null).Value;
		Debug.Log((object)("Remote Control Plugin: Active. (Diagnostic Mode = " + diagnostics));
		speedModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Setting", "Animation Duration Multiplier", 1f, (ConfigDescription)null).Value;
		speedRunModifier = ((BaseUnityPlugin)this).Config.Bind<float>("Setting", "Run Duration Multiplier", 0.1f, (ConfigDescription)null).Value;
		((MonoBehaviour)this).StartCoroutine("RemoteControlServer");
		string text = "";
		foreach (string item in from f in File.Catalog(false)
			where f.ToUpper().EndsWith(".RMV")
			select f)
		{
			try
			{
				text = File.ReadAllText(item, (CacheType)999);
				Mover mover = JsonConvert.DeserializeObject<Mover>(text);
				movers.Add(mover.name, mover);
				Debug.Log((object)("Remote Control Plugin: Found Mover '" + mover.name + "'"));
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("Remote Control Plugin: Found Mover File '" + item + "' But Could Not Parse It."));
				Debug.LogException(ex);
			}
		}
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void Update()
	{
	}

	private IEnumerator RemoteControlServer()
	{
		yield return (object)new WaitForSeconds(0.1f);
		int port = ((BaseUnityPlugin)this).Config.Bind<int>("Setting", "Server Port", 11000, (ConfigDescription)null).Value;
		if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Starting Remote Control Server (Listening On Port " + port + ")"));
		}
		AsynchronousSocketListener.StartListening(port, MessageHandler, diagnostics);
	}

	private static void MessageHandler(Socket sender, string content)
	{
		content = content.Replace("\r\n", "\n");
		content = content.Replace("\r", "\n");
		if (content.Substring(0, content.IndexOf("\n")).ToUpper().StartsWith("POST "))
		{
			if (diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Processing as HTTP message");
			}
			HandlerHTTPMessage(sender, content);
		}
		else
		{
			if (diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Processing as simple TCP/IP message");
			}
			HandlerSimpleTCPMessage(sender, content);
		}
	}

	private static void HandlerHTTPMessage(Socket sender, string content)
	{
		content = content.Substring(content.IndexOf("\n\n") + 2).Trim() + "\n";
		HandlerSimpleTCPMessage(sender, content);
	}

	private static void MoveCharacter(string command, CreatureBoardAsset asset, Vector3 direction, string style)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		if (command.Contains("CAMERABASED"))
		{
			LegacyCutsceneSetup cutsceneSetup = CameraController.CutsceneSetup;
			CutsceneData cutsceneState = cutsceneSetup.GetCutsceneState();
			direction = Quaternion.Euler(0f, cutsceneState.RotationEuler, 0f) * direction;
		}
		if (command.ToUpper().EndsWith("ANDFACE"))
		{
			Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles.x, Mathf.Atan2(direction.x, direction.z) / (float)Math.PI * 180f + 180f, Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles.z);
		}
		AddAnimation(asset, direction, style);
	}

	private static void HandlerSimpleTCPMessage(Socket sender, string content)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cf9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb2: 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_0839: Unknown result type (might be due to invalid IL or missing references)
		//IL_0887: Unknown result type (might be due to invalid IL or missing references)
		//IL_0860: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_1044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f47: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f49: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f53: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f61: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f66: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ff1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ffd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fff: Unknown result type (might be due to invalid IL or missing references)
		//IL_1009: Unknown result type (might be due to invalid IL or missing references)
		//IL_100b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1015: Unknown result type (might be due to invalid IL or missing references)
		//IL_101a: Unknown result type (might be due to invalid IL or missing references)
		//IL_101f: Unknown result type (might be due to invalid IL or missing references)
		//IL_102b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1155: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0634: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0813: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f77: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f79: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f85: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f8f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f91: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f9d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fb3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fb5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fc3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fcd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fcf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fd9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fde: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fe3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0956: 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_0975: Unknown result type (might be due to invalid IL or missing references)
		//IL_0980: Unknown result type (might be due to invalid IL or missing references)
		//IL_098f: Unknown result type (might be due to invalid IL or missing references)
		//IL_099a: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_110b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ec3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ec5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ecf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ed1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0edd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0edf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ef3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f01: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f1b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f25: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f2f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a25: Unknown result type (might be due to invalid IL or missing references)
		//IL_111d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a95: Unknown result type (might be due to invalid IL or missing references)
		//IL_112f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b05: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b16: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b26: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b35: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b40: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
		//IL_1141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b93: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bbc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bd8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be2: Unknown result type (might be due to invalid IL or missing references)
		content = content.Substring(0, content.IndexOf("\n"));
		if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Request = " + content));
		}
		string[] array = content.Split(new char[1] { ',' });
		CreatureBoardAsset val = null;
		List<CreatureBoardAsset> list = new List<CreatureBoardAsset>();
		if (array[0].ToUpper().Trim() != "ALL")
		{
			foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
			{
				if ((item.Name + "<>").Substring(0, (item.Name + "<>").IndexOf("<")).ToUpper().Trim() == array[0].ToUpper().Trim())
				{
					if (diagnostics)
					{
						Debug.Log((object)("Remote Control Plugin: Found Asset '" + array[0].ToUpper() + "'"));
					}
					if ((Object)(object)val == (Object)null)
					{
						val = item;
					}
					list.Add(item);
				}
			}
		}
		else
		{
			if (diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Using All Assets");
			}
			list = ((IEnumerable<CreatureBoardAsset>)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).ToList();
		}
		float result = 1f;
		string style = "Teleport";
		if (array.Length > 2)
		{
			float.TryParse(array[2], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
		}
		if (array.Length > 3)
		{
			style = array[3];
		}
		if ((Object)(object)val != (Object)null || array[0] == "GM")
		{
			switch (array[1].ToUpper())
			{
			case "CHAT":
			{
				string text = string.Join(",", array.Skip(2).ToArray());
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Chat Message '" + text + "'"));
				}
				if (text.ToLower().StartsWith("/rr"))
				{
					if (diagnostics)
					{
						Debug.Log((object)"Remote Control Plugin: Dice Result Detected");
					}
					AddDiceResultToChat(array[0], text.Substring(3).Trim());
				}
				else
				{
					ChatManager.SendChatMessageToBoard(text, val.CreatureId.Value, (float3?)null, false);
				}
				break;
			}
			case "DICE":
			{
				Process process = new Process
				{
					StartInfo = new ProcessStartInfo
					{
						FileName = "talespire://dice/" + string.Join(",", array.Skip(2).ToArray()),
						Arguments = "",
						CreateNoWindow = true
					}
				};
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Executing = " + process.StartInfo.FileName));
				}
				process.Start();
				break;
			}
			case "ANIMATE":
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Animation Sequence '" + array[2] + "->" + array[3] + "s->" + array[4] + "'"));
				}
				((MonoBehaviour)self).StartCoroutine(ProcessAnimationReqeust(list, array[2], float.Parse(array[3], CultureInfo.InvariantCulture), array[4]));
				break;
			case "REQUEST":
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Request Source " + array[0] + " Key " + array[2] + " To " + array[3] + "'"));
				}
				if (array.Length > 4)
				{
					ProcessGenericReqeust(list, array[2], array[3], bool.Parse(array[4]));
				}
				else
				{
					ProcessGenericReqeust(list, array[2], array[3], legacy: false);
				}
				break;
			case "DELETE":
				val.RequestDelete();
				break;
			case "UP":
				AddAnimation(val, new Vector3(0f, result, 0f), style);
				break;
			case "DOWN":
				AddAnimation(val, new Vector3(0f, -1f * result, 0f), style);
				break;
			case "FORWARD":
			case "FORWARDCAMERABASED":
			case "FORWARDANDFACE":
			case "FORWARDCAMERABASEDANDFACE":
				MoveCharacter(array[1].ToUpper(), val, new Vector3(0f, 0f, result), style);
				break;
			case "BACKWARD":
			case "BACKWARDCAMERABASED":
			case "BACKWARDANDFACE":
			case "BACKWARDCAMERABASEDANDFACE":
				MoveCharacter(array[1].ToUpper(), val, new Vector3(0f, 0f, 0f - result), style);
				break;
			case "LEFT":
			case "LEFTCAMERABASED":
			case "LEFTANDFACE":
			case "LEFTCAMERABASEDANDFACE":
				MoveCharacter(array[1].ToUpper(), val, new Vector3(0f - result, 0f, 0f), style);
				break;
			case "RIGHT":
			case "RIGHTCAMERABASED":
			case "RIGHTANDFACE":
			case "RIGHTCAMERABASEDANDFACE":
				MoveCharacter(array[1].ToUpper(), val, new Vector3(result, 0f, 0f), style);
				break;
			case "ROTATE":
				if (array.Length > 3)
				{
					float.TryParse(array[3], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
				}
				switch (array[2].ToUpper())
				{
				case "LEFT":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z - result);
					break;
				case "RIGHT":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z + result);
					break;
				case "FORWARD":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x - result, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z);
					break;
				case "BACKWARD":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x + result, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z);
					break;
				case "COUNTERCLOCKWISE":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y + result, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z);
					break;
				case "CLOCKWISE":
					Utility.GetRootLoader(val.CreatureId).transform.eulerAngles = new Vector3(Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.x, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.y - result, Utility.GetRootLoader(val.CreatureId).transform.eulerAngles.z);
					break;
				}
				break;
			}
		}
		else if (array[0].ToUpper() == "GM" && array[1].ToUpper() == "CHAT")
		{
			string text2 = string.Join(",", array.Skip(2).ToArray());
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Chat Message '" + text2 + "'"));
			}
			if (text2.ToLower().StartsWith("/rr"))
			{
				if (diagnostics)
				{
					Debug.Log((object)"Remote Control Plugin: Dice Result Detected");
				}
				AddDiceResultToChat(array[0], text2.Substring(3).Trim());
			}
			else
			{
				ChatManager.SendChatMessageToBoard(text2, LocalPlayer.Id.Value, (float3?)null, false);
			}
		}
		else if (array[0].ToUpper() == "CAMERA")
		{
			LegacyCutsceneSetup cutsceneSetup = CameraController.CutsceneSetup;
			CutsceneData cutsceneState = cutsceneSetup.GetCutsceneState();
			switch (array[1].ToUpper())
			{
			case "UP":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x, cutsceneState.Position.y + result, cutsceneState.Position.z));
				break;
			case "DOWN":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x, cutsceneState.Position.y - result, cutsceneState.Position.z));
				break;
			case "FORWARD":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x, cutsceneState.Position.y, cutsceneState.Position.z + result));
				break;
			case "BACKWARD":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x, cutsceneState.Position.y, cutsceneState.Position.z - result));
				break;
			case "LEFT":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x - result, cutsceneState.Position.y, cutsceneState.Position.z));
				break;
			case "RIGHT":
				cutsceneState.Position = float3.op_Implicit(new Vector3(cutsceneState.Position.x + result, cutsceneState.Position.y, cutsceneState.Position.z));
				break;
			case "ZOOMIN":
				cutsceneState.Zoom *= 0.9f;
				break;
			case "ZOOMOUT":
				cutsceneState.Zoom *= 1.1f;
				break;
			case "ZOOMSET":
				cutsceneState.Zoom = float.Parse(array[2], CultureInfo.InvariantCulture);
				break;
			case "ZOOMRESET":
				cutsceneState.Zoom = 1f;
				break;
			case "ROTATE":
				if (array.Length > 3)
				{
					float.TryParse(array[3], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result);
				}
				switch (array[2].ToUpper())
				{
				case "FORWARD":
					cutsceneState.TiltEuler -= result;
					break;
				case "BACKWARD":
					cutsceneState.TiltEuler += result;
					break;
				case "LEFT":
				case "COUNTERCLOCKWISE":
					cutsceneState.RotationEuler -= result;
					break;
				case "RIGHT":
				case "CLOCKWISE":
					cutsceneState.RotationEuler += result;
					break;
				}
				break;
			}
			cutsceneSetup.PreviewCutsceneState(cutsceneState);
		}
		else if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Asset Named '" + array[0] + "' Not Found."));
		}
	}

	public static IEnumerator ProcessAnimationReqeust(List<CreatureBoardAsset> assets, string animationName, float duration, string animationResetName)
	{
		Dictionary<CreatureGuid, int> animIndex = new Dictionary<CreatureGuid, int>();
		Dictionary<CreatureGuid, int> animResetIndex = new Dictionary<CreatureGuid, int>();
		CreatureGuid creatureId;
		foreach (CreatureBoardAsset asset2 in assets)
		{
			if (!((Object)(object)asset2 != (Object)null))
			{
				continue;
			}
			Animation anim = ((Component)asset2).gameObject.GetComponentInChildren<Animation>();
			if ((Object)(object)anim != (Object)null)
			{
				List<AnimationState> anims = new List<AnimationState>(((IEnumerable)anim).Cast<AnimationState>());
				for (int selection = 0; selection < anims.Count; selection++)
				{
					if (anims[selection].name.ToUpper() == animationName.ToUpper())
					{
						animIndex.Add(asset2.CreatureId, selection + 1);
						if (diagnostics)
						{
							string[] obj = new string[7]
							{
								"Remote Control Plugin: Found Animation '",
								animationName,
								"' At Index '",
								(selection + 1).ToString(),
								"' Of Creature '",
								null,
								null
							};
							creatureId = asset2.CreatureId;
							obj[5] = ((object)(CreatureGuid)(ref creatureId)).ToString();
							obj[6] = "'";
							Debug.Log((object)string.Concat(obj));
						}
					}
					if (anims[selection].name.ToUpper() == animationResetName.ToUpper())
					{
						animResetIndex.Add(asset2.CreatureId, selection + 1);
						if (diagnostics)
						{
							string[] obj2 = new string[7]
							{
								"Remote Control Plugin: Found Reset Animation '",
								animationResetName,
								"' At Index '",
								(selection + 1).ToString(),
								"' Of Creature '",
								null,
								null
							};
							creatureId = asset2.CreatureId;
							obj2[5] = ((object)(CreatureGuid)(ref creatureId)).ToString();
							obj2[6] = "'";
							Debug.Log((object)string.Concat(obj2));
						}
					}
				}
			}
			if (!animIndex.ContainsKey(asset2.CreatureId))
			{
				animIndex.Add(asset2.CreatureId, -1);
			}
			if (!animResetIndex.ContainsKey(asset2.CreatureId))
			{
				animIndex.Add(asset2.CreatureId, -1);
			}
		}
		foreach (CreatureBoardAsset asset4 in assets)
		{
			if (diagnostics)
			{
				string[] obj3 = new string[5]
				{
					"Remote Control Plugin: Requesting Animation Index '",
					animIndex[asset4.CreatureId].ToString(),
					"' On Creature '",
					null,
					null
				};
				creatureId = asset4.CreatureId;
				obj3[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
				obj3[4] = "'";
				Debug.Log((object)string.Concat(obj3));
			}
			creatureId = asset4.CreatureId;
			AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.customassetslibraryintegratedextension.animate", animIndex[asset4.CreatureId].ToString(), false);
		}
		yield return (object)new WaitForSeconds(duration);
		foreach (CreatureBoardAsset asset3 in assets)
		{
			if (diagnostics)
			{
				creatureId = asset3.CreatureId;
				Debug.Log((object)("Remote Control Plugin: Requesting Animation Stop On Creature '" + ((object)(CreatureGuid)(ref creatureId)).ToString() + "'"));
			}
			creatureId = asset3.CreatureId;
			AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.customassetslibraryintegratedextension.animate", "-1", false);
		}
		foreach (CreatureBoardAsset asset in assets)
		{
			if (diagnostics)
			{
				string[] obj4 = new string[5]
				{
					"Remote Control Plugin: Requesting Reset Animation Index '",
					animResetIndex[asset.CreatureId].ToString(),
					"' On Creature '",
					null,
					null
				};
				creatureId = asset.CreatureId;
				obj4[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
				obj4[4] = "'";
				Debug.Log((object)string.Concat(obj4));
			}
			creatureId = asset.CreatureId;
			AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.customassetslibraryintegratedextension.animate", animResetIndex[asset.CreatureId].ToString(), false);
		}
	}

	private static void ProcessGenericReqeust(List<CreatureBoardAsset> assets, string key, string value, bool legacy)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if (assets.Count > 0)
		{
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Requesting '" + key + "' To '" + value + "' On Matching Assets"));
			}
			{
				foreach (CreatureBoardAsset asset in assets)
				{
					CreatureGuid creatureId = asset.CreatureId;
					AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), key, value, legacy);
				}
				return;
			}
		}
		if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Requesting '" + key + "' To '" + value + "'"));
		}
		AssetDataPlugin.SendInfo(key, value);
	}

	public static void AddAnimation(CreatureBoardAsset asset, Vector3 delta, string style)
	{
		//IL_004d: 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)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Adding Movement Request To Stack (" + Convert.ToString(delta) + ", " + style + ")"));
		}
		if (!animationRequest.ContainsKey(asset.CreatureId))
		{
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Making An Animation Stack From " + GetBareCreatureName(asset)));
			}
			animationRequest.Add(asset.CreatureId, new List<MoveRequest>());
		}
		if (diagnostics)
		{
			Debug.Log((object)"Remote Control Plugin: Queuing Movement Animation");
		}
		animationRequest[asset.CreatureId].Add(new MoveRequest
		{
			delta = delta,
			style = style
		});
		if (!animatingCreatures.ContainsKey(asset.CreatureId))
		{
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Starting Creature " + GetBareCreatureName(asset) + "'s Animation Sequencer"));
			}
			animatingCreatures.Add(asset.CreatureId, 1f);
			((MonoBehaviour)self).StartCoroutine(Animate(asset));
		}
		else
		{
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Creature " + GetBareCreatureName(asset) + "'s Animation Sequencer Already Started"));
			}
			animatingCreatures[asset.CreatureId] = speedRunModifier;
		}
	}

	public static IEnumerator Animate(CreatureBoardAsset asset)
	{
		yield return (object)new WaitForSeconds(0.1f);
		if (animationRequest.ContainsKey(asset.CreatureId))
		{
			if (diagnostics)
			{
				Debug.Log((object)"Remote Control Plugin: Checking Animation Stack");
			}
			while (animationRequest[asset.CreatureId].Count > 0)
			{
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Stack Has " + animationRequest[asset.CreatureId].Count + " Entries"));
				}
				MoveRequest animation = animationRequest[asset.CreatureId].ElementAt(0);
				animationRequest[asset.CreatureId].RemoveAt(0);
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Animation Entry = " + Convert.ToString(animation)));
				}
				Vector3 startPos = Utility.GetRootLoader(asset.CreatureId).transform.position;
				Vector3 endPos = startPos + animation.delta;
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Animation From " + Convert.ToString(startPos) + " + " + Convert.ToString(animation.delta) + " = " + Convert.ToString(startPos)));
				}
				if (!movers.ContainsKey(animation.style))
				{
					if (diagnostics)
					{
						Debug.Log((object)("Remote Control Plugin: Style '" + animation.style + "' unkown. Using 'Teleport' to " + Convert.ToString(endPos)));
					}
					((Component)asset).transform.position = endPos;
					asset.DropAtCurrentLocation();
					asset.Pickup();
					continue;
				}
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Style '" + animation.style + "'. Moving from " + Convert.ToString(startPos) + " to " + Convert.ToString(endPos)));
				}
				Mover mover = movers[animation.style];
				Vector3 path = endPos - startPos;
				Vector3 tangent = Quaternion.Euler(0f, 90f, 0f) * path;
				tangent /= ((Vector3)(ref tangent)).magnitude;
				_ = ((Vector3)(ref path)).magnitude;
				Vector3 elevation = new Vector3(0f, 1f, 0f);
				Vector3 baseOrientation = Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles;
				foreach (Step step in mover.steps)
				{
					if (diagnostics)
					{
						Debug.Log((object)("Remote Control Plugin: Style '" + animation.style + "'. Step " + JsonConvert.SerializeObject((object)step)));
					}
					Vector3 currentPos4 = startPos;
					currentPos4 += path * step.path;
					currentPos4 += tangent * step.tangent;
					currentPos4 += elevation * step.elevation;
					if (diagnostics)
					{
						Debug.Log((object)("Remote Control Plugin: Style '" + animation.style + "'. Moving To " + Convert.ToString(currentPos4)));
					}
					((Component)asset).transform.position = currentPos4;
					asset.DropAtCurrentLocation();
					asset.Pickup();
					Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles = new Vector3(baseOrientation.x + step.rotations.axisX, baseOrientation.y + step.rotations.axisY, baseOrientation.z + step.rotations.axisZ);
					yield return (object)new WaitForSeconds(step.delay * speedModifier * animatingCreatures[asset.CreatureId]);
				}
				((Component)asset).transform.position = new Vector3(endPos.x, endPos.y + 0.25f, endPos.z);
				asset.DropAtCurrentLocation();
				Utility.GetRootLoader(asset.CreatureId).transform.eulerAngles = baseOrientation;
				path = default(Vector3);
				tangent = default(Vector3);
			}
		}
		else if (diagnostics)
		{
			Debug.LogWarning((object)("Remote Control Plugin: No Movement Animation Stack Found For " + GetBareCreatureName(asset)));
		}
		animatingCreatures.Remove(asset.CreatureId);
	}

	public static MethodInfo GetUpdateMethod(CreatureBoardAsset asset)
	{
		foreach (MethodInfo runtimeMethod in typeof(CreatureBoardAsset).GetRuntimeMethods())
		{
			if (runtimeMethod.Name == "Update")
			{
				return runtimeMethod;
			}
		}
		return null;
	}

	public static void AddDiceResultToChat(string roller, string msg)
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_0428: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_043d: Expected O, but got Unknown
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string text = msg.Substring(msg.IndexOf("[") + 1).Trim();
			text = text.Substring(0, text.IndexOf("]"));
			List<string> list = text.Split(new char[1] { ',' }).ToList();
			string text2 = msg.Substring(0, msg.IndexOf("[")).Trim();
			string text3 = "(From Remote)";
			if (text2.IndexOf(":") > -1)
			{
				text3 = text2.Substring(0, text2.IndexOf(":")).Trim();
				text2 = text2.Substring(text2.IndexOf(":") + 1).Trim();
			}
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Formula = " + text2));
			}
			if (diagnostics)
			{
				Debug.Log((object)("Remote Control Plugin: Dice Values = " + text));
			}
			string text4 = "";
			string text5 = "";
			DiceOperator val = (DiceOperator)0;
			string text6 = "";
			List<RollResultsGroup> list2 = new List<RollResultsGroup>();
			int num = 0;
			int result = 0;
			while (text2.Trim() != "")
			{
				num++;
				if (num > 10 || text2.IndexOf("D") < 0)
				{
					break;
				}
				text4 = text2.Substring(0, text2.IndexOf("D"));
				text2 = text2.Substring(text2.IndexOf("D") + 1);
				if (!int.TryParse(text4, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result))
				{
					break;
				}
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Num Dice = " + text4));
				}
				if (text2.IndexOf("+") < 0 && text2.IndexOf("-") < 0)
				{
					break;
				}
				if ((text2 + "+-").IndexOf("+") < (text2 + "+-").IndexOf("-"))
				{
					text5 = text2.Substring(0, text2.IndexOf("+"));
					text2 = text2.Substring(text2.IndexOf("+") + 1);
				}
				else
				{
					text5 = text2.Substring(0, text2.IndexOf("-"));
					text2 = text2.Substring(text2.IndexOf("-") + 1);
					val = (DiceOperator)1;
				}
				if (!int.TryParse(text5, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result))
				{
					break;
				}
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Num Sides = " + text5));
				}
				if (text2.IndexOf("+") > -1)
				{
					text6 = text2.Substring(0, text2.IndexOf("+"));
					text2 = text2.Substring(text2.IndexOf("+") + 1);
				}
				else
				{
					text6 = text2;
					text2 = "";
				}
				if (!int.TryParse(text6, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out result))
				{
					break;
				}
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Operator = " + Convert.ToString(val)));
				}
				short[] array = new short[int.Parse(text4, CultureInfo.InvariantCulture)];
				for (int i = 0; i < array.Count(); i++)
				{
					if (list.Count > 0)
					{
						if (short.TryParse(list.ElementAt(0), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var result2))
						{
							array[i] = result2;
						}
						else
						{
							array[i] = 1;
						}
						list.RemoveAt(0);
					}
					else
					{
						array[i] = 1;
					}
				}
				list2.Add(new RollResultsGroup(text3, new RollOperand(new RollResult(new DieKind(ushort.Parse(text5, CultureInfo.InvariantCulture)), new BList<short>(array)))));
				list2.Add(new RollResultsGroup(text3, new RollOperand(new RollValue(short.Parse(text6, CultureInfo.InvariantCulture)))));
			}
			RollResults val2 = new RollResults(default(RollId), LocalClient.Id, new BList<RollResultsGroup>(list2));
			DiceManager obj = Object.FindObjectOfType<DiceManager>();
			MethodInfo methodInfo = null;
			foreach (MethodInfo runtimeMethod in typeof(DiceManager).GetRuntimeMethods())
			{
				if (runtimeMethod.Name == "SendDiceResult")
				{
					methodInfo = runtimeMethod;
				}
			}
			methodInfo.Invoke(obj, new object[2] { false, val2 });
		}
		catch (Exception ex)
		{
			SystemMessage.DisplayInfoText("Invalid Roll Result Provided:\r\n" + msg, 2.5f);
			Debug.LogWarning((object)ex);
		}
	}

	public static ClientGuid FindCreatureByName(string name)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: 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_0115: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
		{
			if (!(GetBareCreatureName(item) == name))
			{
				continue;
			}
			foreach (KeyValuePair<PlayerGuid, PlayerInfo> item2 in CampaignSessionManager.PlayersInfo)
			{
				if (!CreatureManager.PlayerOwnsCreature(item2.Key, item.CreatureId))
				{
					continue;
				}
				if (diagnostics)
				{
					Debug.Log((object)("Remote Control Plugin: Player '" + item2.Value.Name + "' Has Ownership Of '" + name + "'"));
				}
				for (int i = 0; i < BoardSessionManager.ClientsPlayerGuids.Count; i++)
				{
					ClientGuid result = default(ClientGuid);
					if (BoardSessionManager.ClientsPlayerGuids.TryGetKeyByValue(item2.Key, ref result))
					{
						return result;
					}
				}
				return new ClientGuid(item2.Key.Value);
			}
		}
		if (diagnostics)
		{
			Debug.Log((object)("Remote Control Plugin: Ownership Of '" + name + "' Unknown. Using Default."));
		}
		return LocalClient.Id;
	}

	private static string GetBareCreatureName(CreatureBoardAsset asset)
	{
		string text = asset.Name;
		if (text.Contains("<size=0>"))
		{
			text = text.Substring(0, text.IndexOf("<size=0>"));
		}
		return text;
	}
}