Decompiled source of CharacterViewPlugin v3.2.1

CharacterViewPlugin.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using Bounce.Unmanaged;
using HarmonyLib;
using RadialUI;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
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("CharacterViewPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CharacterViewPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("CharacterViewPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("3.2.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("3.2.1.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.characterview", "Character View Plug-In", "3.2.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CharacterViewPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Camera), "FireOnPreRender")]
	public static class CameraPatch
	{
		public static bool Prefix(ref Camera cam)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cam != (Object)null)
			{
				if (characterViewActive)
				{
					CreatureBoardAsset val = default(CreatureBoardAsset);
					CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
					if ((Object)(object)val != (Object)null)
					{
						Transform transform = Utility.GetBaseLoader(val.CreatureId).transform;
						cam.fieldOfView = fieldOfView;
						cam.nearClipPlane = nearClipPlane;
						((Component)cam).transform.position = val.HookHead.position;
						((Component)cam).transform.eulerAngles = new Vector3(headTilt, transform.eulerAngles.y - 90f + headRotation, 0f);
					}
					else
					{
						characterViewActive = false;
						characterViewLookAroundModeActive = false;
					}
				}
			}
			else
			{
				characterViewActive = false;
				characterViewLookAroundModeActive = false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CreatureManager), "OnPlayerGainsControlOfCreature")]
	public static class OnPlayerGainsControlOfCreaturePatch
	{
		public static bool Prefix(PlayerGuid senderId, PlayerGuid playerId, CreatureGuid creatureId)
		{
			if (CampaignSessionManager.CanLocalPlayerGm())
			{
				Debug.Log((object)("Character View Plugin: GM Sending Remote Request To Turn Character View On (With " + ((object)(CreatureGuid)(ref creatureId)).ToString() + " Selected)"));
				AssetDataPlugin.SendInfo("org.lordashes.plugins.characterview", ((object)(PlayerGuid)(ref playerId)).ToString() + "|" + ((object)(CreatureGuid)(ref creatureId)).ToString());
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CreatureManager), "OnPlayerLosesControlOfCreature")]
	public static class OnPlayerLosesControlOfCreaturePatch
	{
		public static bool Prefix(PlayerGuid senderId, PlayerGuid playerId, CreatureGuid creatureId, CreatureGuid[] otherCreaturesUnderPlayerControl)
		{
			if (CampaignSessionManager.CanLocalPlayerGm())
			{
				Debug.Log((object)"Character View Plugin: GM Sending Remote Request To Turn Character View Off");
				AssetDataPlugin.SendInfo("org.lordashes.plugins.characterview", ((object)(PlayerGuid)(ref playerId)).ToString());
			}
			return true;
		}
	}

	public static class RequestHandler
	{
		public static void Process(DatumChange change)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			string[] array = change.value.ToString().Split(new char[1] { '|' });
			string obj = array[0];
			PlayerGuid id = LocalPlayer.Id;
			Debug.Log((object)("Character View Plugin: Received Remote Request For Player " + obj + ". This Is Player " + ((object)(PlayerGuid)(ref id)).ToString()));
			id = LocalPlayer.Id;
			if (!(((object)(PlayerGuid)(ref id)).ToString() == array[0].ToString()))
			{
				return;
			}
			if (array.Length == 1)
			{
				Debug.Log((object)"Character View Plugin: Received Remote Request To Turn Character View Off");
				_self.SetCharacterViewMode(setting: false);
			}
			else if (array.Length == 2)
			{
				Debug.Log((object)("Character View Plugin: Received Remote Request To Turn Character View On (With " + array[1] + " Selected)"));
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(new CreatureGuid(array[1]), ref val);
				if ((Object)(object)val != (Object)null)
				{
					Debug.Log((object)("Character View Plugin: Selecting Creature " + array[1]));
					val.Select();
					Debug.Log((object)"Character View Plugin: Turning Character View On");
					_self.SetCharacterViewMode(setting: true);
				}
			}
		}
	}

	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;
		}

		public static bool StrictKeyCheck(KeyboardShortcut check)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!((KeyboardShortcut)(ref check)).IsUp())
			{
				return false;
			}
			KeyCode[] array = new KeyCode[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			KeyCode[] array2 = (KeyCode[])(object)array;
			foreach (KeyCode val in array2)
			{
				if (Input.GetKey(val) != ((KeyboardShortcut)(ref check)).Modifiers.Contains(val))
				{
					return false;
				}
			}
			return true;
		}

		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 GetBaseLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				CreatureBase match = null;
				StartWith(val, "_base", ref match);
				Transform match2 = null;
				Traverse(((Component)match).transform, "BaseLoader", ref match2);
				if ((Object)(object)match2 != (Object)null)
				{
					return ((Component)match2.GetChild(0)).gameObject;
				}
				Debug.LogWarning((object)"Character View Plugin: Could Not Find Base Loader");
				return null;
			}
			return null;
		}

		public static GameObject GetAssetLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Transform match = null;
				StartWith(val, "_creatureRoot", ref match);
				Transform match2 = null;
				Traverse(match, "AssetLoader", ref match2);
				if ((Object)(object)match2 != (Object)null)
				{
					return ((Component)match2.GetChild(0)).gameObject;
				}
				Debug.LogWarning((object)"Character View Plugin: Could Not Find Asset Loader");
				return null;
			}
			return null;
		}

		public static void StartWith<T>(CreatureBoardAsset asset, string seek, ref T match)
		{
			Type typeFromHandle = typeof(CreatureBoardAsset);
			match = default(T);
			foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
			{
				if (runtimeField.Name == seek)
				{
					match = (T)runtimeField.GetValue(asset);
					break;
				}
			}
		}

		public static void Traverse(Transform root, string seek, ref Transform match)
		{
			if ((Object)(object)match != (Object)null)
			{
				return;
			}
			if (((Object)root).name == seek)
			{
				match = root;
				return;
			}
			foreach (Transform item in ExtensionMethods.Children(root))
			{
				Traverse(item, seek, ref match);
			}
		}
	}

	public const string Name = "Character View Plug-In";

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

	public const string Version = "3.2.1.0";

	public static bool characterViewActive = false;

	public static bool characterViewLookAroundModeActive = false;

	private static float defaultHeadRotation = 0f;

	private static float defaultHeadTilt = 0f;

	private static float headRotation = 0f;

	private static float headTilt = 0f;

	private static float maxHeadRotation = 45f;

	private static float headRotationSpeedScaling = 0.75f;

	private static bool firstPersonViewOnly = false;

	private static bool useLookAroundMode = true;

	private static CharacterViewPlugin _self = null;

	private GUIStyle centeredStatus1 = new GUIStyle();

	private GUIStyle centeredStatus2 = new GUIStyle();

	private Dictionary<string, ConfigEntry<KeyboardShortcut>> triggerKeys { get; set; } = new Dictionary<string, ConfigEntry<KeyboardShortcut>>();


	private ConfigEntry<float> rotateHeadSpeed { get; set; }

	private ConfigEntry<bool> resetHeadRotation { get; set; }

	private static float fieldOfView { get; set; }

	private static float nearClipPlane { get; set; }

	private void Awake()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		//IL_0474: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Expected O, but got Unknown
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0503: Expected O, but got Unknown
		Debug.Log((object)("Character View Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active."));
		_self = this;
		triggerKeys.Add("Toggle", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle View", new KeyboardShortcut((KeyCode)118, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null));
		triggerKeys.Add("Head Up", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Head Up", new KeyboardShortcut((KeyCode)121, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null));
		triggerKeys.Add("Head Down", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Head Down", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null));
		triggerKeys.Add("Head Left", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Head Left", new KeyboardShortcut((KeyCode)103, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null));
		triggerKeys.Add("Head Right", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rotate Head Right", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null));
		triggerKeys.Add("Move Forward", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Move Forward", new KeyboardShortcut((KeyCode)121, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		triggerKeys.Add("Move Backward", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Move Backward", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		triggerKeys.Add("Turn Left", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Turn Left", new KeyboardShortcut((KeyCode)103, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		triggerKeys.Add("Turn Right", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Turn Right", new KeyboardShortcut((KeyCode)106, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		triggerKeys.Add("Move Left", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Slide Left", new KeyboardShortcut((KeyCode)98, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		triggerKeys.Add("Move Right", ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Slide Right", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null));
		firstPersonViewOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "First Person View Only", false, (ConfigDescription)null).Value;
		useLookAroundMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Use Look Around Mode", true, (ConfigDescription)null).Value;
		fieldOfView = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Field Of View Angle", 60f, (ConfigDescription)null).Value;
		maxHeadRotation = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Max Head Rotation From Centre", 45f, (ConfigDescription)null).Value;
		rotateHeadSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Keyboard Rotate Head Angle", 5f, (ConfigDescription)null);
		resetHeadRotation = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Reset Head Rotation", true, (ConfigDescription)null);
		defaultHeadRotation = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Default Head Rotation", 0f, (ConfigDescription)null).Value;
		defaultHeadTilt = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Default Head Tilt", 0f, (ConfigDescription)null).Value;
		nearClipPlane = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Start Render At Distance", 0.5f, (ConfigDescription)null).Value;
		headRotationSpeedScaling = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Head Rotation Scaling Factor Over Distance", 1f, (ConfigDescription)null).Value;
		centeredStatus1.alignment = (TextAnchor)4;
		centeredStatus1.fontSize = 16;
		centeredStatus1.normal.textColor = Color.black;
		centeredStatus2.alignment = (TextAnchor)4;
		centeredStatus2.fontSize = 16;
		centeredStatus2.normal.textColor = Color.white;
		Harmony val = new Harmony("org.lordashes.plugins.characterview");
		val.PatchAll();
		AssetDataPlugin.Subscribe("org.lordashes.plugins.characterview", (Action<DatumChange>)RequestHandler.Process);
		RadialUIPlugin.AddCustomButtonOnCharacter("org.lordashes.plugins.characterview.ViewMode", new ItemArgs
		{
			Action = delegate
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				SelectDesiredAsset(default(CreatureGuid));
				ToggleCharacterViewMode();
			},
			CloseMenuOnActivate = true,
			FadeName = true,
			Icon = Image.LoadSprite("CharacterViewMode.png", (CacheType)999),
			Title = "Character View"
		}, (Func<NGuid, NGuid, bool>)RadialMenuCheck);
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void Update()
	{
		//IL_0011: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0501: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: 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_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: 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_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: 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_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_0473: Unknown result type (might be due to invalid IL or missing references)
		//IL_0478: Unknown result type (might be due to invalid IL or missing references)
		if (Utility.StrictKeyCheck(triggerKeys["Toggle"].Value))
		{
			ToggleCharacterViewMode();
		}
		if (!characterViewActive)
		{
			return;
		}
		if (Utility.StrictKeyCheck(triggerKeys["Head Left"].Value))
		{
			headRotation -= rotateHeadSpeed.Value;
		}
		else if (Utility.StrictKeyCheck(triggerKeys["Head Right"].Value))
		{
			headRotation += rotateHeadSpeed.Value;
		}
		else if (Utility.StrictKeyCheck(triggerKeys["Head Up"].Value))
		{
			headTilt -= rotateHeadSpeed.Value;
		}
		else if (Utility.StrictKeyCheck(triggerKeys["Head Down"].Value))
		{
			headTilt += rotateHeadSpeed.Value;
		}
		else
		{
			try
			{
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
				if ((Object)(object)val != (Object)null)
				{
					Transform transform = Utility.GetBaseLoader(val.CreatureId).transform;
					Transform transform2 = Utility.GetAssetLoader(val.CreatureId).transform;
					Vector3 val2 = default(Vector3);
					((Vector3)(ref val2))..ctor(0f, 0.25f, 0f);
					if (Utility.StrictKeyCheck(triggerKeys["Turn Left"].Value))
					{
						((MovableBoardAsset)val).Rotator.eulerAngles = new Vector3(((MovableBoardAsset)val).Rotator.eulerAngles.x, ((MovableBoardAsset)val).Rotator.eulerAngles.y - 90f, ((MovableBoardAsset)val).Rotator.eulerAngles.z);
					}
					else if (Utility.StrictKeyCheck(triggerKeys["Turn Right"].Value))
					{
						((MovableBoardAsset)val).Rotator.eulerAngles = new Vector3(((MovableBoardAsset)val).Rotator.eulerAngles.x, ((MovableBoardAsset)val).Rotator.eulerAngles.y + 90f, ((MovableBoardAsset)val).Rotator.eulerAngles.z);
					}
					else if (Utility.StrictKeyCheck(triggerKeys["Move Forward"].Value))
					{
						Vector3 val3 = Quaternion.Euler(0f, transform.eulerAngles.y + 90f, 0f) * new Vector3(0f, 0f, 1f);
						CreaturePresenter.TeleportCreature(val, float3.op_Implicit(transform.position - val3 + val2));
					}
					else if (Utility.StrictKeyCheck(triggerKeys["Move Backward"].Value))
					{
						Vector3 val4 = Quaternion.Euler(0f, transform.eulerAngles.y + 90f, 0f) * new Vector3(0f, 0f, -1f);
						CreaturePresenter.TeleportCreature(val, float3.op_Implicit(transform.position - val4 + val2));
					}
					else if (Utility.StrictKeyCheck(triggerKeys["Move Left"].Value))
					{
						Vector3 val5 = Quaternion.Euler(0f, transform.eulerAngles.y - 90f + 90f, 0f) * new Vector3(0f, 0f, 1f);
						CreaturePresenter.TeleportCreature(val, float3.op_Implicit(transform.position - val5 + val2));
					}
					else if (Utility.StrictKeyCheck(triggerKeys["Move Right"].Value))
					{
						Vector3 val6 = Quaternion.Euler(0f, transform.eulerAngles.y + 90f + 90f, 0f) * new Vector3(0f, 0f, 1f);
						CreaturePresenter.TeleportCreature(val, float3.op_Implicit(transform.position - val6 + val2));
					}
					val.DropAtCurrentLocation();
				}
				else
				{
					SystemMessage.DisplayInfoText("No Selected Character.\r\nEnsure A Mini Was Selected\r\nWhen Using This Feature.", 2.5f, 0f);
					characterViewActive = false;
					characterViewLookAroundModeActive = false;
				}
			}
			catch
			{
				SystemMessage.DisplayInfoText("Character View Mode Failed.\r\nEnsure A Mini Was Selected\r\nWhen Using This Feature.", 2.5f, 0f);
				characterViewActive = false;
				characterViewLookAroundModeActive = false;
			}
		}
		if (characterViewLookAroundModeActive)
		{
			Vector3 headOrientation = GetHeadOrientation(Input.mousePosition);
			headRotation = headOrientation.x;
			headTilt = headOrientation.y;
		}
	}

	private void OnGUI()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (characterViewActive)
		{
			GUI.Label(new Rect(1f, 61f, (float)Screen.width, (float)(15 * (1080 / Screen.height))), "Character View Mode: Head Rotation = " + headRotation.ToString("0.0") + ", Head Tilt = " + headTilt.ToString("0.0"), centeredStatus1);
			GUI.Label(new Rect(0f, 60f, (float)Screen.width, (float)(15 * (1080 / Screen.height))), "Character View Mode: Head Rotation = " + headRotation.ToString("0.0") + ", Head Tilt = " + headTilt.ToString("0.0"), centeredStatus2);
		}
	}

	private void SelectDesiredAsset(CreatureGuid creatureId)
	{
		//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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
		{
			item.Deselect();
		}
		CreatureBoardAsset val = null;
		if (creatureId != default(CreatureGuid))
		{
			CreaturePresenter.TryGetAsset(creatureId, ref val);
		}
		else
		{
			CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val);
		}
		if ((Object)(object)val != (Object)null)
		{
			val.Select();
		}
	}

	private void ToggleCharacterViewMode()
	{
		characterViewActive = !characterViewActive;
		SetCharacterViewMode(characterViewActive);
	}

	private void SetCharacterViewMode(bool setting)
	{
		characterViewActive = setting;
		SetPostProcessing(!characterViewActive);
		if (resetHeadRotation.Value)
		{
			headRotation = defaultHeadRotation;
			headTilt = defaultHeadTilt;
		}
		Debug.Log((object)("Character View Plugin: Character View Mode Swicth To " + characterViewActive));
		SetLookAroundMode(characterViewActive);
	}

	private void SetLookAroundMode(bool setting)
	{
		characterViewLookAroundModeActive = setting;
		Debug.Log((object)("Character View Plugin: Character Look Around Mode Swicth To " + characterViewLookAroundModeActive));
	}

	private bool RadialMenuCheck(NGuid arg1, NGuid arg2)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if (!firstPersonViewOnly)
		{
			CreatureBoardAsset val = default(CreatureBoardAsset);
			CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val);
			if ((Object)(object)val != (Object)null)
			{
				return CreatureManager.PlayerCanControlCreature(LocalPlayer.Id, val.CreatureId);
			}
			return false;
		}
		return CampaignSessionManager.CanLocalPlayerGm();
	}

	private Vector3 GetHeadOrientation(Vector3 screenPosition)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		screenPosition.x -= (float)(Screen.width / 2);
		screenPosition.y = -1f * (screenPosition.y - (float)(Screen.height / 2));
		Vector3 val = default(Vector3);
		val.x = (float)Math.Pow(Screen.width / 2, headRotationSpeedScaling);
		val.y = (float)Math.Pow(Screen.height / 2, headRotationSpeedScaling);
		Vector3 val2 = default(Vector3);
		val2.x = (float)((double)Math.Sign(screenPosition.x) * Math.Pow(Math.Abs((double)screenPosition.x), headRotationSpeedScaling));
		val2.y = (float)((double)Math.Sign(screenPosition.y) * Math.Pow(Math.Abs((double)screenPosition.y), headRotationSpeedScaling));
		val2.x /= val.x;
		val2.y /= val.y;
		Vector3 val3 = default(Vector3);
		val3.x = maxHeadRotation * val2.x;
		val3.y = maxHeadRotation * val2.y;
		val3.z = 0f;
		if (val3.x < -1f * maxHeadRotation)
		{
			val3.x = -1f * maxHeadRotation;
		}
		if (val3.x > maxHeadRotation)
		{
			val3.x = maxHeadRotation;
		}
		if (val3.y < -1f * maxHeadRotation)
		{
			val3.y = -1f * maxHeadRotation;
		}
		if (val3.y > maxHeadRotation)
		{
			val3.y = maxHeadRotation;
		}
		return val3;
	}

	private void SetPostProcessing(bool setting)
	{
		PostProcessLayer component = ((Component)Camera.main).GetComponent<PostProcessLayer>();
		((Behaviour)component).enabled = setting;
	}
}