Decompiled source of MW2xRoR2 v0.4.4

MW2RoR2.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
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 System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.BlendableTypes;
using HarmonyLib;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MW2RoR2")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2c20f43f1a1d96f34f8d5603c7918a2c15497ab3")]
[assembly: AssemblyProduct("MW2RoR2")]
[assembly: AssemblyTitle("MW2RoR2")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "Designed, directed and playtested by buhhrad; code written with an AI coding agent")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude, via Claude Code)")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MW2RoR2
{
	internal static class Mw2Pilot
	{
		public static bool AttackPulse;

		public static bool StreakPulse;

		public static bool CrouchPulse;

		public static bool PronePulse;

		public static bool InteractPulse;

		public static int GunPulse = -1;

		public static bool Active => false;

		public static bool Ran => false;

		public static bool Attack => false;

		public static bool Ads => false;

		public static bool Sprint => false;

		public static bool Jump => false;

		public static bool Interact => false;

		public static bool Reload => false;

		public static bool Moving => false;

		public static bool Frag => false;

		public static bool Smoke => false;

		public static bool Melee => false;

		public static bool FrontCam => false;

		public static float Fwd => 0f;

		public static float Right => 0f;

		public static Vector3 ViewForward => Vector3.forward;

		public static bool ThirdOnlyTest => false;

		public static bool ThirdOnlyConfigTest => false;

		public static void Steer(Transform cam)
		{
		}

		public static void AfterCamera(Transform cam)
		{
		}

		public static bool Consume(ref bool pulse)
		{
			return false;
		}

		public static bool Wants(string step)
		{
			return false;
		}
	}
	internal static class Mw2Cinema
	{
		public static bool On => false;

		public static bool HideHud => false;

		public static bool ShowStreakHud => false;

		public static bool Recording => false;

		public static bool InputBlocked => false;

		public static int Frame => 0;

		public static void SwapDissolve(GameObject oldRoot, GameObject newRoot)
		{
		}
	}
	internal sealed class Mw2Admin
	{
		public bool Open => false;

		public bool InfiniteAmmo => false;

		public void Apply(CharacterBody body)
		{
		}
	}
	internal static class In
	{
		private static int typingFrame = -1;

		private static bool typing;

		private static float nextChatScan;

		private static ChatBox[] chats;

		private static readonly FieldInfo showInput = AccessTools.Field(typeof(ChatBox), "_showInput");

		public static bool Typing
		{
			get
			{
				if (Time.frameCount == typingFrame)
				{
					return typing;
				}
				typingFrame = Time.frameCount;
				typing = false;
				if ((Object)(object)ConsoleWindow.instance != (Object)null || Mw2Menus.Editing || Mw2Cinema.InputBlocked)
				{
					return typing = true;
				}
				if (Time.unscaledTime >= nextChatScan)
				{
					nextChatScan = Time.unscaledTime + 1f;
					chats = Object.FindObjectsOfType<ChatBox>();
				}
				if (chats != null && showInput != null)
				{
					ChatBox[] array = chats;
					foreach (ChatBox val in array)
					{
						if ((Object)(object)val != (Object)null && (bool)showInput.GetValue(val))
						{
							return typing = true;
						}
					}
				}
				return typing;
			}
		}

		public static KeyCode CrouchKey => (KeyCode)(((??)Mw2Binds.Crouch) ?? Plugin.Instance.CrouchKey.Value);

		public static KeyCode ProneKey => (KeyCode)(((??)Mw2Binds.Prone) ?? Plugin.Instance.ProneKey.Value);

		public static bool Reload
		{
			get
			{
				if (!Key((KeyCode)114))
				{
					return Mw2Pilot.Reload;
				}
				return true;
			}
		}

		public static bool StreakKeyDown
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				if (!KeyDown(Plugin.Instance.StreakKey.Value))
				{
					return Mw2Pilot.Consume(ref Mw2Pilot.StreakPulse);
				}
				return true;
			}
		}

		public static bool Key(KeyCode k)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!Typing)
			{
				return Input.GetKey(k);
			}
			return false;
		}

		public static bool KeyDown(KeyCode k)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!Typing)
			{
				return Input.GetKeyDown(k);
			}
			return false;
		}

		public static bool Attack(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !b.skill1.down)
			{
				return Mw2Pilot.Attack;
			}
			return true;
		}

		public static bool AttackPressed(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !((ButtonState)(ref b.skill1)).justPressed)
			{
				return Mw2Pilot.Consume(ref Mw2Pilot.AttackPulse);
			}
			return true;
		}

		public static bool Ads(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !b.skill2.down)
			{
				return Mw2Pilot.Ads;
			}
			return true;
		}

		public static bool Sprint(InputBankTest b)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (Mw2Pilot.Sprint)
			{
				return true;
			}
			KeyCode? sprint = Mw2Binds.Sprint;
			if (sprint.HasValue)
			{
				KeyCode valueOrDefault = sprint.GetValueOrDefault();
				return Key(valueOrDefault);
			}
			if ((Object)(object)b != (Object)null && b.sprint.down && !Key(CrouchKey))
			{
				return !Key(ProneKey);
			}
			return false;
		}

		public static bool Jump(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !b.jump.down)
			{
				return Mw2Pilot.Jump;
			}
			return true;
		}

		public static bool Interact(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !b.interact.down)
			{
				return Mw2Pilot.Interact;
			}
			return true;
		}

		public static bool InteractPressed(InputBankTest b)
		{
			if (!((Object)(object)b != (Object)null) || !((ButtonState)(ref b.interact)).justPressed)
			{
				return Mw2Pilot.Consume(ref Mw2Pilot.InteractPulse);
			}
			return true;
		}

		public static int GunPick()
		{
			if (KeyDown((KeyCode)49))
			{
				return 0;
			}
			if (KeyDown((KeyCode)50))
			{
				return 1;
			}
			if (KeyDown((KeyCode)51))
			{
				return 2;
			}
			int gunPulse = Mw2Pilot.GunPulse;
			Mw2Pilot.GunPulse = -1;
			return gunPulse;
		}

		public static Vector3 Move(InputBankTest b)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0058: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (!Mw2Pilot.Moving || (Object)(object)b == (Object)null)
			{
				if (!((Object)(object)b != (Object)null))
				{
					return Vector3.zero;
				}
				return b.moveVector;
			}
			Vector3 val = b.aimDirection;
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.z, 0f, 0f - val.x);
			return Vector3.ClampMagnitude(val * Mw2Pilot.Fwd + val2 * Mw2Pilot.Right, 1f);
		}
	}
	internal class Mw2Audio
	{
		private bool warned;

		private static object masterVar;

		private static object sfxVar;

		private static object msxVar;

		private static string msxRtpc;

		private static MethodInfo getString;

		private static Func<bool> paused;

		private static bool probed;

		public void Attach(GameObject go)
		{
		}

		private static void Probe()
		{
			probed = true;
			try
			{
				Assembly assembly = typeof(CharacterBody).Assembly;
				Type[] types = assembly.GetTypes();
				foreach (Type type in types)
				{
					FieldInfo field = type.GetField("cvVolumeMaster", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (!(field == null))
					{
						masterVar = field.GetValue(null);
						sfxVar = type.GetField("cvVolumeSfx", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
						msxVar = type.GetField("cvVolumeMsx", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
						msxRtpc = msxVar?.GetType().GetField("rtpcName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(msxVar) as string;
						getString = masterVar?.GetType().GetMethod("GetString", Type.EmptyTypes);
						break;
					}
				}
				Type type2 = assembly.GetType("RoR2.PauseManager");
				PropertyInfo prop = type2?.GetProperty("isPaused", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo field2 = type2?.GetField("isPaused", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (prop != null)
				{
					paused = () => (bool)prop.GetValue(null);
				}
				else if (field2 != null)
				{
					paused = () => (bool)field2.GetValue(null);
				}
				Plugin.Log.LogInfo((object)("MW2 audio follows game volume: " + ((masterVar != null) ? "yes" : "no") + ", pause: " + ((paused != null) ? "yes" : "no")));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("MW2 audio: couldn't read game volume settings (" + ex.GetType().Name + "); using WeaponVolume only."));
			}
		}

		private static float Percent(object convar)
		{
			if (convar == null || getString == null)
			{
				return 1f;
			}
			try
			{
				float result;
				return float.TryParse(getString.Invoke(convar, null) as string, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? Mathf.Clamp01((result > 1f) ? (result / 100f) : result) : 1f;
			}
			catch
			{
				return 1f;
			}
		}

		public static int PlayUi(string alias, float scale = 1f)
		{
			if (string.IsNullOrEmpty(alias))
			{
				return 0;
			}
			float num = Plugin.Instance.Volume.Value * GameVolume() * scale;
			if (!(num > 0.001f))
			{
				return 1;
			}
			return Native.PlayAlias(alias, num);
		}

		public unsafe static uint LoopStart(string alias)
		{
			if (string.IsNullOrEmpty(alias))
			{
				return 0u;
			}
			byte[] bytes = Encoding.UTF8.GetBytes(alias);
			fixed (byte* name = bytes)
			{
				return Native.mw2_loop_start(name, (UIntPtr)(ulong)bytes.Length, 0f);
			}
		}

		public static void LoopVolume(uint id, float scale)
		{
			if (id != 0)
			{
				float volume = (GamePaused() ? 0f : (Plugin.Instance.Volume.Value * GameVolume() * scale));
				Native.mw2_loop_volume(id, volume);
			}
		}

		public static void MusicVolume(uint id)
		{
			if (id != 0)
			{
				if (!probed)
				{
					Probe();
				}
				Native.mw2_loop_volume(id, Plugin.Instance.Volume.Value * Percent(masterVar) * Percent(msxVar));
			}
		}

		public static void Ror2Music(bool on)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!probed)
			{
				Probe();
			}
			if (string.IsNullOrEmpty(msxRtpc))
			{
				return;
			}
			try
			{
				AkSoundEngine.SetRTPCValue(msxRtpc, on ? (Percent(msxVar) * 100f) : 0f);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("RoR2 music mute: " + ex.Message));
			}
		}

		public static void LoopStop(uint id)
		{
			if (id != 0)
			{
				Native.mw2_loop_stop(id);
			}
		}

		private static float GameVolume()
		{
			if (!probed)
			{
				Probe();
			}
			return Percent(masterVar) * Percent(sfxVar);
		}

		private static bool GamePaused()
		{
			if (!probed)
			{
				Probe();
			}
			try
			{
				return paused != null && paused();
			}
			catch
			{
				return false;
			}
		}

		public void Play(uint weapon, uint kind)
		{
			if (weapon != 0 && !GamePaused() && Native.mw2_weapon_sound(weapon, kind) != 0)
			{
				float num = Plugin.Instance.Volume.Value * GameVolume();
				if (!(num <= 0.001f) && Native.mw2_play_weapon_sound(weapon, kind, num) == 0 && !warned)
				{
					warned = true;
					Plugin.Log.LogWarning((object)"MW2 audio: no output device could be opened; weapon sounds are off.");
				}
			}
		}

		public void PlayWeapon(uint weapon, float scale)
		{
			if (weapon != 0 && !GamePaused())
			{
				float num = Plugin.Instance.Volume.Value * GameVolume() * scale;
				if (num > 0.001f)
				{
					Native.mw2_play_weapon_sound(weapon, 0u, num);
				}
			}
		}

		public void PlayAlias(string alias, float scale = 1f)
		{
			if (!GamePaused())
			{
				float num = Plugin.Instance.Volume.Value * GameVolume() * scale;
				if (num > 0.001f)
				{
					Native.PlayAlias(alias, num);
				}
			}
		}

		public void OnEvents(uint weapon, uint events, int clipAfter, bool notetracks = false)
		{
			if (events != 0)
			{
				if (notetracks)
				{
					events &= 0xFFFFFFC3u;
				}
				if ((events & 1) != 0)
				{
					Play(weapon, (clipAfter == 0 && Native.mw2_weapon_sound(weapon, 1u) != 0) ? 1u : 0u);
				}
				if ((events & 2) != 0)
				{
					Play(weapon, 2u);
				}
				bool flag = Native.mw2_weapon_sound(weapon, 5u) != 0;
				if ((events & 4) != 0)
				{
					Play(weapon, flag ? 5u : ((clipAfter == 0 && Native.mw2_weapon_sound(weapon, 4u) != 0) ? 4u : 3u));
				}
				if ((events & 8) != 0 && flag)
				{
					Play(weapon, 3u);
				}
				if ((events & 0x10) != 0 && flag)
				{
					Play(weapon, 6u);
				}
				if ((events & 0x20) != 0)
				{
					Play(weapon, 7u);
				}
				if ((events & 0x200) != 0)
				{
					Play(weapon, 10u);
				}
			}
		}
	}
	internal class Mw2BindSkillDef : SkillDef
	{
		public bool right;

		public override Sprite GetCurrentIcon(GenericSkill skillSlot)
		{
			return Mw2BindIcons.Get(right, Mw2BindIcons.OnGamepad());
		}
	}
	internal static class Mw2BindIcons
	{
		private static readonly Sprite[] cache = (Sprite[])(object)new Sprite[4];

		private static readonly Sprite[] arrows = (Sprite[])(object)new Sprite[2];

		private static Sprite plus;

		public static bool OnGamepad()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			MPEventSystem val = ((firstLocalUser != null) ? firstLocalUser.eventSystem : null);
			if ((Object)(object)val != (Object)null)
			{
				return (int)val.currentInputSource == 1;
			}
			return false;
		}

		public static Sprite Arrow(bool right)
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			int num = (right ? 1 : 0);
			if ((Object)(object)arrows[num] != (Object)null)
			{
				return arrows[num];
			}
			Color32[] array = (Color32[])(object)new Color32[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num2 = (right ? ((float)j + 0.5f) : (128f - ((float)j + 0.5f)));
					float num3 = Mathf.Abs((float)i + 0.5f - 64f);
					float num4 = Mathf.Abs(num2 - 44f - (40f - num3));
					bool flag = num2 >= 40f && num2 <= 88f && num3 <= 42f && num4 < 11f;
					array[i * 128 + j] = (flag ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : default(Color32));
				}
			}
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = (right ? "mw2_next" : "mw2_prev"),
				filterMode = (FilterMode)1
			};
			val.SetPixels32(array);
			val.Apply(false, true);
			return arrows[num] = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
		}

		public static Sprite Plus()
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)plus != (Object)null)
			{
				return plus;
			}
			Color32[] array = (Color32[])(object)new Color32[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num = Mathf.Abs((float)j + 0.5f - 64f);
					float num2 = Mathf.Abs((float)i + 0.5f - 64f);
					bool flag = (num < 7f && num2 < 38f) || (num2 < 7f && num < 38f);
					bool flag2 = Mathf.Max(num, num2) > 54f && Mathf.Max(num, num2) < 60f;
					array[i * 128 + j] = (flag ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue) : (flag2 ? new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)140) : default(Color32)));
				}
			}
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = "mw2_plus",
				filterMode = (FilterMode)1
			};
			val.SetPixels32(array);
			val.Apply(false, true);
			return plus = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
		}

		public static Sprite Get(bool ads, bool pad)
		{
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_02b0: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: 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_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			int num = (ads ? 1 : 0) + (pad ? 2 : 0);
			if ((Object)(object)cache[num] != (Object)null)
			{
				return cache[num];
			}
			Color32[] array = (Color32[])(object)new Color32[16384];
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)70);
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)200);
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					Color32 val4 = default(Color32);
					if (!pad)
					{
						bool num2 = Box(j, i, 34f, 14f, 94f, 114f, 28f);
						bool flag = Box(j, i, 39f, 19f, 89f, 109f, 23f);
						if (num2 && !flag)
						{
							val4 = val3;
						}
						else if (flag && i >= 72)
						{
							bool num3 = Mathf.Abs((float)j + 0.5f - 64f) < 2.5f;
							bool flag2 = Mathf.Abs((float)i + 0.5f - 72f) < 2.5f;
							bool flag3 = (ads ? (j >= 64) : (j < 64));
							val4 = ((num3 || flag2) ? val3 : (flag3 ? val2 : val));
						}
					}
					else
					{
						bool num4 = Box(j, i, 14f, 18f, 114f, 76f, 26f);
						bool flag4 = Box(j, i, 19f, 23f, 109f, 71f, 21f);
						bool flag5 = Box(j, i, 20f, 82f, 50f, 112f, 10f);
						bool flag6 = Box(j, i, 78f, 82f, 108f, 112f, 10f);
						if (num4 && !flag4)
						{
							val4 = val3;
						}
						else if (flag5)
						{
							val4 = (ads ? val2 : val);
						}
						else if (flag6)
						{
							val4 = (ads ? val : val2);
						}
					}
					array[i * 128 + j] = val4;
				}
			}
			Texture2D val5 = new Texture2D(128, 128, (TextureFormat)4, false)
			{
				name = $"mw2_bind_{num}",
				filterMode = (FilterMode)1
			};
			val5.SetPixels32(array);
			val5.Apply(false, true);
			return cache[num] = Sprite.Create(val5, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
			static bool Box(int x, int y, float x0, float y0, float x1, float y1, float r)
			{
				float num5 = Mathf.Clamp((float)x + 0.5f, x0 + r, x1 - r);
				float num6 = Mathf.Clamp((float)y + 0.5f, y0 + r, y1 - r);
				float num7 = (float)x + 0.5f - num5;
				float num8 = (float)y + 0.5f - num6;
				if ((float)x + 0.5f >= x0 && (float)x + 0.5f <= x1 && (float)y + 0.5f >= y0 && (float)y + 0.5f <= y1)
				{
					return num7 * num7 + num8 * num8 <= r * r;
				}
				return false;
			}
		}
	}
	internal static class Mw2Binds
	{
		public static readonly Dictionary<string, KeyCode> Keys = new Dictionary<string, KeyCode>();

		public static string Source;

		private static readonly Regex Bind = new Regex("^\\s*bind\\s+(\\S+)\\s+\"([^\"]+)\"", RegexOptions.IgnoreCase);

		public static KeyCode? Sprint => Keyboard(For("+breath_sprint", "+sprint"));

		public static KeyCode? Crouch => Keyboard(For("togglecrouch", "+movedown", "lowerstance"));

		public static KeyCode? Prone => Keyboard(For("toggleprone", "+prone", "goprone"));

		public static KeyCode? Use => Keyboard(For("+activate", "+usereload"));

		public static void Load(string commonMpPath)
		{
			try
			{
				string text = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(commonMpPath))) ?? "", "players");
				if (!Directory.Exists(text))
				{
					return;
				}
				string[] array = new string[3] { "config_mp.cfg", "iw4x_config.cfg", "config.cfg" };
				foreach (string path in array)
				{
					string text2 = Path.Combine(text, path);
					if (File.Exists(text2))
					{
						Parse(File.ReadAllLines(text2));
						Source = text2;
						break;
					}
				}
				if (Source != null)
				{
					Plugin.Log.LogInfo((object)("MW2 binds from " + Source + ": " + string.Join(", ", Describe())));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("MW2 binds: " + ex.Message));
			}
		}

		private static void Parse(string[] lines)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			foreach (string input in lines)
			{
				Match match = Bind.Match(input);
				if (!match.Success)
				{
					continue;
				}
				KeyCode val = ToKey(match.Groups[1].Value);
				if ((int)val != 0 && (int)val != 325)
				{
					string key = match.Groups[2].Value.Trim().ToLowerInvariant();
					if ((!Keys.TryGetValue(key, out var value) || (int)value >= 323 || (int)val < 323) && (!Keys.ContainsKey(key) || (int)val < 323))
					{
						Keys[key] = val;
					}
				}
			}
		}

		private static KeyCode? Keyboard(KeyCode? k)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if (!k.HasValue || (int)k.Value >= 323)
			{
				return null;
			}
			return k;
		}

		public static KeyCode? For(params string[] commands)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			foreach (string key in commands)
			{
				if (Keys.TryGetValue(key, out var value))
				{
					return value;
				}
			}
			return null;
		}

		public unsafe static string Label(KeyCode k)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0017: 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_003b: Expected I4, but got Unknown
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected I4, but got Unknown
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected I4, but got Unknown
			if ((int)k >= 48 && (int)k <= 57)
			{
				return (k - 48).ToString();
			}
			switch (k - 303)
			{
			default:
				return (k - 323) switch
				{
					0 => "MOUSE1", 
					1 => "MOUSE2", 
					3 => "MOUSE4", 
					4 => "MOUSE5", 
					_ => ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant(), 
				};
			case 0:
			case 1:
				return "SHIFT";
			case 2:
			case 3:
				return "CTRL";
			case 4:
			case 5:
				return "ALT";
			}
		}

		private static IEnumerable<string> Describe()
		{
			string[] array = new string[9] { "+actionslot 4", "+frag", "+smoke", "+breath_sprint", "+holdbreath", "togglecrouch", "toggleprone", "+movedown", "+prone" };
			foreach (string text in array)
			{
				if (Keys.TryGetValue(text, out var value))
				{
					yield return text + "=" + Label(value);
				}
			}
		}

		private static KeyCode ToKey(string name)
		{
			string text = name.Trim().ToUpperInvariant();
			if (text.Length == 1 && text[0] >= '0' && text[0] <= '9')
			{
				return (KeyCode)(48 + (text[0] - 48));
			}
			if (text.Length == 1 && text[0] >= 'A' && text[0] <= 'Z')
			{
				return (KeyCode)(97 + (text[0] - 65));
			}
			if (text.StartsWith("F") && int.TryParse(text.Substring(1), out var result) && result >= 1 && result <= 15)
			{
				return (KeyCode)(282 + (result - 1));
			}
			if (text.StartsWith("MOUSE") && int.TryParse(text.Substring(5), out var result2) && result2 >= 1 && result2 <= 7)
			{
				return (KeyCode)(323 + (result2 - 1));
			}
			return (KeyCode)(text switch
			{
				"SHIFT" => 304, 
				"CTRL" => 306, 
				"ALT" => 308, 
				"SPACE" => 32, 
				"TAB" => 9, 
				"ENTER" => 13, 
				"BACKSPACE" => 8, 
				"CAPSLOCK" => 301, 
				"UPARROW" => 273, 
				"DOWNARROW" => 274, 
				"LEFTARROW" => 276, 
				"RIGHTARROW" => 275, 
				_ => 0, 
			});
		}
	}
	internal static class Mw2Blend
	{
		public struct Layer
		{
			public string material;

			public Rect rect;

			public Rect uv;

			public Color color;

			public float rotationDeg;
		}

		private class Cache
		{
			public Texture2D tex;

			public string builtKey;

			public string pendingKey;

			public Rect builtRect;

			public Rect pendingRect;

			public volatile Color32[] ready;

			public int readyW;

			public int readyH;

			public Task worker;
		}

		private const uint ColorWriteRgb = 134217728u;

		private const uint ColorWriteAlpha = 268435456u;

		private const int Zero = 1;

		private const int One = 2;

		private const int SrcColor = 3;

		private const int InvSrcColor = 4;

		private const int SrcAlpha = 5;

		private const int InvSrcAlpha = 6;

		private const int DestAlpha = 7;

		private const int InvDestAlpha = 8;

		private static readonly Dictionary<string, uint> bits = new Dictionary<string, uint>();

		private static readonly Dictionary<int, Cache> caches = new Dictionary<int, Cache>();

		public unsafe static uint Bits(string material)
		{
			if (bits.TryGetValue(material, out var value))
			{
				return value;
			}
			byte[] bytes = Encoding.UTF8.GetBytes(material);
			uint* ptr = stackalloc uint[2];
			int num;
			fixed (byte* name = bytes)
			{
				num = Native.mw2_material_state_bits(name, (UIntPtr)(ulong)bytes.Length, ptr);
			}
			value = ((num == 1) ? (*ptr) : 0u);
			bits[material] = value;
			return value;
		}

		public static bool Special(uint w0)
		{
			if (w0 == 0)
			{
				return false;
			}
			uint num = w0 & 0x18000000;
			int num2 = (int)(w0 & 0xF);
			int num3 = (int)((w0 >> 4) & 0xF);
			if (num == 402653184 && num2 != 7 && num2 != 8 && num3 != 7)
			{
				return num3 == 8;
			}
			return true;
		}

		public unsafe static void Draw(List<Layer> layers, int slot)
		{
			//IL_0076: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0195: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: 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)
			if (layers.Count == 0)
			{
				return;
			}
			if (!caches.TryGetValue(slot, out var c))
			{
				caches[slot] = (c = new Cache());
			}
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			float num3 = float.MinValue;
			float num4 = float.MinValue;
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Layer layer in layers)
			{
				float num5 = num;
				Rect val = layer.rect;
				num = Mathf.Min(num5, ((Rect)(ref val)).xMin);
				float num6 = num2;
				val = layer.rect;
				num2 = Mathf.Min(num6, ((Rect)(ref val)).yMin);
				float num7 = num3;
				val = layer.rect;
				num3 = Mathf.Max(num7, ((Rect)(ref val)).xMax);
				float num8 = num4;
				val = layer.rect;
				num4 = Mathf.Max(num8, ((Rect)(ref val)).yMax);
				StringBuilder stringBuilder2 = stringBuilder.Append(layer.material).Append('|');
				val = layer.rect;
				StringBuilder stringBuilder3 = stringBuilder2.Append(((Rect)(ref val)).x.ToString("F0")).Append(',');
				val = layer.rect;
				StringBuilder stringBuilder4 = stringBuilder3.Append(((Rect)(ref val)).y.ToString("F0")).Append(',');
				val = layer.rect;
				StringBuilder stringBuilder5 = stringBuilder4.Append(((Rect)(ref val)).width.ToString("F0")).Append(',');
				val = layer.rect;
				StringBuilder stringBuilder6 = stringBuilder5.Append(((Rect)(ref val)).height.ToString("F0")).Append('|');
				val = layer.uv;
				StringBuilder stringBuilder7 = stringBuilder6.Append(((Rect)(ref val)).x.ToString("F4")).Append(',');
				val = layer.uv;
				StringBuilder stringBuilder8 = stringBuilder7.Append(((Rect)(ref val)).y.ToString("F4")).Append(',');
				val = layer.uv;
				StringBuilder stringBuilder9 = stringBuilder8.Append(((Rect)(ref val)).width.ToString("F4")).Append(',');
				val = layer.uv;
				StringBuilder stringBuilder10 = stringBuilder9.Append(((Rect)(ref val)).height.ToString("F4")).Append('|');
				Color color = layer.color;
				stringBuilder10.Append(((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).ToString()).Append('|').Append(layer.rotationDeg.ToString("F1"))
					.Append(';');
			}
			num = Mathf.Max(0f, Mathf.Floor(num));
			num2 = Mathf.Max(0f, Mathf.Floor(num2));
			num3 = Mathf.Min((float)Screen.width, Mathf.Ceil(num3));
			num4 = Mathf.Min((float)Screen.height, Mathf.Ceil(num4));
			int w = (int)(num3 - num);
			int h = (int)(num4 - num2);
			if (w <= 0 || h <= 0 || w * h > 4000000)
			{
				return;
			}
			string text = stringBuilder.ToString();
			Color32[] ready = c.ready;
			if (ready != null)
			{
				c.ready = null;
				Upload(c, ready, c.readyW, c.readyH);
				c.builtKey = c.pendingKey;
				c.builtRect = c.pendingRect;
			}
			if (text != c.builtKey && text != c.pendingKey && (c.worker == null || c.worker.IsCompleted))
			{
				List<(Layer l, uint w0)> input = new List<(Layer, uint)>();
				foreach (Layer layer2 in layers)
				{
					input.Add((layer2, Bits(layer2.material)));
				}
				int ox = (int)num;
				int oy = (int)num2;
				c.pendingKey = text;
				c.pendingRect = new Rect(num, num2, (float)w, (float)h);
				c.worker = Task.Run(delegate
				{
					List<(Layer, byte[], int, int, uint)> list = new List<(Layer, byte[], int, int, uint)>();
					foreach (var (item, item2) in input)
					{
						if (Mw2Icons.Pixels(item.material, out var px, out var w2, out var h2))
						{
							list.Add((item, px, w2, h2, item2));
						}
					}
					Color32[] ready2 = Build(list, ox, oy, w, h);
					c.readyW = w;
					c.readyH = h;
					c.ready = ready2;
				});
			}
			if ((Object)(object)c.tex != (Object)null && c.builtKey != null)
			{
				GUI.DrawTexture(c.builtRect, (Texture)(object)c.tex, (ScaleMode)0, true);
			}
		}

		private static void Upload(Cache c, Color32[] px, int w, int h)
		{
			//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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			if ((Object)(object)c.tex == (Object)null || ((Texture)c.tex).width != w || ((Texture)c.tex).height != h)
			{
				if ((Object)(object)c.tex != (Object)null)
				{
					Object.Destroy((Object)(object)c.tex);
				}
				c.tex = new Texture2D(w, h, (TextureFormat)4, false)
				{
					wrapMode = (TextureWrapMode)1,
					filterMode = (FilterMode)1
				};
			}
			c.tex.SetPixels32(px);
			c.tex.Apply(false, false);
		}

		private static Color32[] Build(List<(Layer l, byte[] px, int tw, int th, uint w0)> jobs, int ox, int oy, int w, int h)
		{
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: 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_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: 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_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: 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_0388: Unknown result type (might be due to invalid IL or missing references)
			int num = w * h;
			float[] array = new float[num];
			float[] array2 = new float[num];
			float[] array3 = new float[num];
			float[] array4 = new float[num];
			float[] array5 = new float[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = 1f;
			}
			foreach (var job in jobs)
			{
				Layer item = job.l;
				byte[] item2 = job.px;
				int item3 = job.tw;
				int item4 = job.th;
				uint item5 = job.w0;
				bool flag = item5 == 0 || (item5 & 0x8000000) != 0;
				bool flag2 = item5 == 0 || (item5 & 0x10000000) != 0;
				int num2 = (int)((item5 == 0) ? 5 : (item5 & 0xF));
				int num3 = (int)((item5 == 0) ? 6 : ((item5 >> 4) & 0xF));
				int num4 = (int)((item5 == 0) ? 1 : ((item5 >> 8) & 7));
				int f = (int)((item5 >> 16) & 0xF);
				int f2 = (int)((item5 >> 20) & 0xF);
				int num5 = (int)((item5 >> 24) & 7);
				if (num5 == 0)
				{
					f = num2;
					f2 = num3;
					num5 = num4;
				}
				Rect val = item.rect;
				int num6 = Mathf.Max(ox, Mathf.FloorToInt(((Rect)(ref val)).xMin));
				int num7 = ox + w;
				val = item.rect;
				int num8 = Mathf.Min(num7, Mathf.CeilToInt(((Rect)(ref val)).xMax));
				val = item.rect;
				int num9 = Mathf.Max(oy, Mathf.FloorToInt(((Rect)(ref val)).yMin));
				int num10 = oy + h;
				val = item.rect;
				int num11 = Mathf.Min(num10, Mathf.CeilToInt(((Rect)(ref val)).yMax));
				bool flag3 = Mathf.Abs(item.rotationDeg) > 0.01f;
				float num12 = Mathf.Cos(item.rotationDeg * (MathF.PI / 180f));
				float num13 = Mathf.Sin(item.rotationDeg * (MathF.PI / 180f));
				val = item.rect;
				float num14 = Mathf.Max(((Rect)(ref val)).width, 0.001f);
				val = item.rect;
				float num15 = Mathf.Max(((Rect)(ref val)).height, 0.001f);
				val = item.rect;
				float x = ((Rect)(ref val)).center.x;
				val = item.rect;
				float y = ((Rect)(ref val)).center.y;
				for (int j = num9; j < num11; j++)
				{
					val = item.uv;
					float y2 = ((Rect)(ref val)).y;
					float num16 = (float)j + 0.5f;
					val = item.rect;
					float num17 = (num16 - ((Rect)(ref val)).y) / num15;
					val = item.uv;
					float num18 = y2 + num17 * ((Rect)(ref val)).height;
					int num19 = Mathf.Clamp((int)((1f - num18) * (float)item4), 0, item4 - 1);
					for (int k = num6; k < num8; k++)
					{
						val = item.uv;
						float x2 = ((Rect)(ref val)).x;
						float num20 = (float)k + 0.5f;
						val = item.rect;
						float num21 = (num20 - ((Rect)(ref val)).x) / num14;
						val = item.uv;
						float num22 = x2 + num21 * ((Rect)(ref val)).width;
						if (flag3)
						{
							float num23 = (float)k + 0.5f - x;
							float num24 = (float)j + 0.5f - y;
							float num25 = (num12 * num23 - num13 * num24) / num14 + 0.5f;
							float num26 = (num13 * num23 + num12 * num24) / num15 + 0.5f;
							if (num25 < 0f || num25 > 1f || num26 < 0f || num26 > 1f)
							{
								continue;
							}
							val = item.uv;
							float x3 = ((Rect)(ref val)).x;
							val = item.uv;
							num22 = x3 + num25 * ((Rect)(ref val)).width;
							val = item.uv;
							float y3 = ((Rect)(ref val)).y;
							val = item.uv;
							num19 = Mathf.Clamp((int)((1f - (y3 + num26 * ((Rect)(ref val)).height)) * (float)item4), 0, item4 - 1);
						}
						int num27 = Mathf.Clamp((int)(num22 * (float)item3), 0, item3 - 1);
						int num28 = (num19 * item3 + num27) * 4;
						float num29 = (float)(int)item2[num28] / 255f * item.color.r;
						float num30 = (float)(int)item2[num28 + 1] / 255f * item.color.g;
						float num31 = (float)(int)item2[num28 + 2] / 255f * item.color.b;
						float num32 = (float)(int)item2[num28 + 3] / 255f * item.color.a;
						int num33 = (j - oy) * w + (k - ox);
						float num34 = array5[num33];
						if (flag)
						{
							switch (num4)
							{
							case 0:
								array[num33] = 0f;
								array2[num33] = num29;
								array3[num33] = num30;
								array4[num33] = num31;
								break;
							case 1:
							case 2:
							case 3:
							{
								float num35 = Factor(num2, num29, num30, num31, num32, num34);
								float num36 = Factor(num3, num29, num30, num31, num32, num34);
								float num37 = ((num4 == 3) ? (0f - num35) : num35);
								float num38 = ((num4 == 2) ? (0f - num36) : num36);
								array[num33] *= num38;
								array2[num33] = num29 * num37 + array2[num33] * num38;
								array3[num33] = num30 * num37 + array3[num33] * num38;
								array4[num33] = num31 * num37 + array4[num33] * num38;
								break;
							}
							}
						}
						if (flag2)
						{
							float num41;
							switch (num5)
							{
							case 0:
								num41 = num32;
								break;
							case 4:
								num41 = Mathf.Min(num32, num34);
								break;
							case 5:
								num41 = Mathf.Max(num32, num34);
								break;
							default:
							{
								float num39 = AlphaFactor(f, num32, num34);
								float num40 = AlphaFactor(f2, num32, num34);
								num41 = num5 switch
								{
									3 => num34 * num40 - num32 * num39, 
									2 => num32 * num39 - num34 * num40, 
									_ => num32 * num39 + num34 * num40, 
								};
								break;
							}
							}
							array5[num33] = Mathf.Clamp01(num41);
						}
					}
				}
			}
			Color32[] array6 = (Color32[])(object)new Color32[num];
			for (int l = 0; l < h; l++)
			{
				for (int m = 0; m < w; m++)
				{
					int num42 = l * w + m;
					float num43 = Mathf.Clamp01(1f - array[num42]);
					float num44 = ((num43 > 0.0001f) ? (1f / num43) : 0f);
					array6[(h - 1 - l) * w + m] = new Color32((byte)(Mathf.Clamp01(array2[num42] * num44) * 255f), (byte)(Mathf.Clamp01(array3[num42] * num44) * 255f), (byte)(Mathf.Clamp01(array4[num42] * num44) * 255f), (byte)(num43 * 255f));
				}
			}
			return array6;
		}

		private static float Factor(int f, float sr, float sg, float sb, float sa, float da)
		{
			return f switch
			{
				1 => 0f, 
				2 => 1f, 
				3 => (sr + sg + sb) / 3f, 
				4 => 1f - (sr + sg + sb) / 3f, 
				5 => sa, 
				6 => 1f - sa, 
				7 => da, 
				8 => 1f - da, 
				_ => 1f, 
			};
		}

		private static float AlphaFactor(int f, float sa, float da)
		{
			switch (f)
			{
			case 1:
				return 0f;
			case 2:
				return 1f;
			case 3:
			case 5:
				return sa;
			case 4:
			case 6:
				return 1f - sa;
			case 7:
				return da;
			case 8:
				return 1f - da;
			default:
				return 1f;
			}
		}
	}
	internal static class Space
	{
		public static float Scale = 0.0254f;

		public static Vector3 ToUnity(Vec3f p)
		{
			//IL_0013: 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)
			return new Vector3(0f - p.y, p.z, p.x) * Scale;
		}

		public static Vec3f ToIw(Vector3 u)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = u / Scale;
			return new Vec3f(val.z, 0f - val.x, val.y);
		}

		public static Vector3 DirToUnity(Vec3f d)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(0f - d.y, d.z, d.x);
		}

		public static Vec3f DirToIw(Vector3 d)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return new Vec3f(d.z, 0f - d.x, d.y);
		}
	}
	internal static class UnityWorld
	{
		public static int Mask;

		private const float ClipEpsilonUnits = 0.125f;

		private static float walkNormalZ;

		private const float SkinMetres = 0.001f;

		private const float SnagUnits = 2f;

		public static int SeamSkips;

		private const uint MissileMask = 41969713u;

		public static void SetWalkableSlope(float survivorMaxDegrees)
		{
			float num = Mathf.Clamp(survivorMaxDegrees, 45.57f, 70f);
			walkNormalZ = Mathf.Min(0.7f, Mathf.Cos(num * (MathF.PI / 180f)));
			Plugin.Log.LogInfo((object)$"MW2 walkable slope: {num:F0} degrees (normal z >= {walkNormalZ:F3}; survivor's {survivorMaxDegrees:F0})");
		}

		public unsafe static void Trace(IntPtr user, Vec3f* start, Vec3f* end, Vec3f* mins, Vec3f* maxs, uint mask, Mw2Trace* r)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: 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_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: 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_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: 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_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: 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_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: 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_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: 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_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			Vec3f vec3f = new Vec3f((mins->x + maxs->x) * 0.5f, (mins->y + maxs->y) * 0.5f, (mins->z + maxs->z) * 0.5f);
			Vec3f vec3f2 = new Vec3f((maxs->x - mins->x) * 0.5f, (maxs->y - mins->y) * 0.5f, (maxs->z - mins->z) * 0.5f);
			Vector3 val = new Vector3(vec3f2.y, vec3f2.z, vec3f2.x) * Space.Scale - new Vector3(0.001f, 0.001f, 0.001f);
			val = Vector3.Max(val, new Vector3(0.001f, 0.001f, 0.001f));
			Vec3f p = new Vec3f(start->x + vec3f.x, start->y + vec3f.y, start->z + vec3f.z);
			Vec3f p2 = new Vec3f(end->x + vec3f.x, end->y + vec3f.y, end->z + vec3f.z);
			Vector3 val2 = Space.ToUnity(p);
			Vector3 val3 = Space.ToUnity(p2);
			r->fraction = 1f;
			r->endpos = *end;
			r->normal = default(Vec3f);
			r->startsolid = 0;
			r->allsolid = 0;
			r->walkable = 0;
			r->surfaceFlags = 0u;
			if (Physics.CheckBox(val2, val, Quaternion.identity, Mask, (QueryTriggerInteraction)1))
			{
				r->fraction = 0f;
				r->endpos = *start;
				r->startsolid = 1;
				r->allsolid = (Physics.CheckBox(val3, val, Quaternion.identity, Mask, (QueryTriggerInteraction)1) ? ((byte)1) : ((byte)0));
				r->normal = new Vec3f(0f, 0f, 1f);
				return;
			}
			Vector3 val4 = val3 - val2;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			if (magnitude < 1E-06f)
			{
				return;
			}
			Vector3 val5 = val4 / magnitude;
			float num = 0.125f * Space.Scale;
			RaycastHit val6 = default(RaycastHit);
			bool flag = Physics.BoxCast(val2, val, val5, ref val6, Quaternion.identity, magnitude, Mask, (QueryTriggerInteraction)1);
			if (flag && Vector3.Dot(val5, ((RaycastHit)(ref val6)).normal) >= -0.001f)
			{
				Vector3 val7 = val2 + ((RaycastHit)(ref val6)).normal * num;
				flag = !Physics.CheckBox(val7, val, Quaternion.identity, Mask, (QueryTriggerInteraction)1) && Physics.BoxCast(val7, val, val5, ref val6, Quaternion.identity, magnitude, Mask, (QueryTriggerInteraction)1) && Vector3.Dot(val5, ((RaycastHit)(ref val6)).normal) < -0.001f;
			}
			if (flag && ((RaycastHit)(ref val6)).normal.y < walkNormalZ && Mathf.Abs(val5.y) < 0.5f)
			{
				float num2 = 2f * Space.Scale;
				float num3 = val2.y + val5.y * ((RaycastHit)(ref val6)).distance - val.y;
				RaycastHit val8 = default(RaycastHit);
				if (((RaycastHit)(ref val6)).point.y < num3 + num2 && Physics.Raycast(new Vector3(((RaycastHit)(ref val6)).point.x, num3 + num2, ((RaycastHit)(ref val6)).point.z), Vector3.down, ref val8, 2f * num2, Mask, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val8)).normal.y >= walkNormalZ)
				{
					Vector3 val9 = val2 + Vector3.up * num2;
					if (!Physics.CheckBox(val9, val, Quaternion.identity, Mask, (QueryTriggerInteraction)1))
					{
						RaycastHit val10 = default(RaycastHit);
						bool flag2 = Physics.BoxCast(val9, val, val5, ref val10, Quaternion.identity, magnitude, Mask, (QueryTriggerInteraction)1) && Vector3.Dot(val5, ((RaycastHit)(ref val10)).normal) < -0.001f;
						float num4 = (flag2 ? ((RaycastHit)(ref val10)).distance : magnitude);
						if (num4 > ((RaycastHit)(ref val6)).distance + 0.0001f && !Physics.CheckBox(val2 + val5 * Mathf.Max(num4 - num, 0f), val, Quaternion.identity, Mask, (QueryTriggerInteraction)1))
						{
							SeamSkips++;
							flag = flag2;
							if (flag2)
							{
								val6 = val10;
							}
						}
					}
				}
			}
			if (flag)
			{
				float num5 = Mathf.Max(0f - Vector3.Dot(val5, ((RaycastHit)(ref val6)).normal), 0.001f);
				float num6 = (r->fraction = Mathf.Clamp01((((RaycastHit)(ref val6)).distance - num / num5) / magnitude));
				r->endpos = new Vec3f(start->x + (end->x - start->x) * num6, start->y + (end->y - start->y) * num6, start->z + (end->z - start->z) * num6);
				Vec3f vec3f3 = (r->normal = Space.DirToIw(((RaycastHit)(ref val6)).normal));
				r->walkable = ((vec3f3.z >= walkNormalZ) ? ((byte)1) : ((byte)0));
				r->surfaceFlags = (uint)((Mw2Gunfire.SurfaceIndex(((RaycastHit)(ref val6)).collider) & 0x1F) << 20);
			}
			if (mask == 41969713)
			{
				EnemySweep(val2, val, val5, magnitude, start, end, r);
			}
		}

		private unsafe static void EnemySweep(Vector3 su, Vector3 halfU, Vector3 dir, float dist, Vec3f* start, Vec3f* end, Mw2Trace* r)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0102: 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)
			CharacterBody val = (((Object)(object)Plugin.Instance != (Object)null) ? Plugin.Instance.Bridge.LocalBody : null);
			TeamIndex val2 = (TeamIndex)((!((Object)(object)val != (Object)null) || !((Object)(object)val.teamComponent != (Object)null)) ? 1 : ((int)val.teamComponent.teamIndex));
			float num = float.MaxValue;
			RaycastHit val3 = default(RaycastHit);
			Quaternion identity = Quaternion.identity;
			LayerIndex entityPrecise = LayerIndex.entityPrecise;
			RaycastHit[] array = Physics.BoxCastAll(su, halfU, dir, identity, dist, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask), (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val4 = array[i];
				HurtBox val5 = (((Object)(object)((RaycastHit)(ref val4)).collider != (Object)null) ? ((Component)((RaycastHit)(ref val4)).collider).GetComponent<HurtBox>() : null);
				if (!((Object)(object)val5 == (Object)null) && !((Object)(object)val5.healthComponent == (Object)null) && val5.healthComponent.alive && val5.teamIndex != val2)
				{
					float num2 = ((((RaycastHit)(ref val4)).distance > 0f) ? ((RaycastHit)(ref val4)).distance : 0f);
					if (num2 < num)
					{
						num = num2;
						val3 = val4;
					}
				}
			}
			if (num == float.MaxValue)
			{
				return;
			}
			float num3 = Mathf.Clamp01(num / dist);
			if (num3 >= r->fraction)
			{
				return;
			}
			r->fraction = num3;
			r->endpos = new Vec3f(start->x + (end->x - start->x) * num3, start->y + (end->y - start->y) * num3, start->z + (end->z - start->z) * num3);
			Vector3 d;
			if (((RaycastHit)(ref val3)).distance > 0f)
			{
				Vector3 normal = ((RaycastHit)(ref val3)).normal;
				if (((Vector3)(ref normal)).sqrMagnitude > 0.5f)
				{
					d = ((RaycastHit)(ref val3)).normal;
					goto IL_01ce;
				}
			}
			d = -dir;
			goto IL_01ce;
			IL_01ce:
			r->normal = Space.DirToIw(d);
			r->walkable = 0;
			r->surfaceFlags = (uint)((Mw2Gunfire.FleshSurface & 0x1F) << 20);
		}

		static UnityWorld()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			LayerIndex world = LayerIndex.world;
			Mask = LayerMask.op_Implicit(((LayerIndex)(ref world)).mask);
			walkNormalZ = 0.7f;
		}
	}
	internal static class UnityWorldProbe
	{
		public unsafe static void Log(Vec3f origin)
		{
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			Vec3f vec3f = new Vec3f(-15f, -15f, 0f);
			Vec3f vec3f2 = new Vec3f(15f, 15f, 70f);
			(string, Vec3f)[] array = new(string, Vec3f)[6]
			{
				("+x", new Vec3f(8f, 0f, 0f)),
				("-x", new Vec3f(-8f, 0f, 0f)),
				("+y", new Vec3f(0f, 8f, 0f)),
				("-y", new Vec3f(0f, -8f, 0f)),
				("down", new Vec3f(0f, 0f, -2f)),
				("up", new Vec3f(0f, 0f, 8f))
			};
			Mw2Trace mw2Trace = default(Mw2Trace);
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				(string, Vec3f) tuple = array[i];
				string item = tuple.Item1;
				Vec3f item2 = tuple.Item2;
				Vec3f vec3f3 = origin;
				Vec3f vec3f4 = new Vec3f(origin.x + item2.x, origin.y + item2.y, origin.z + item2.z);
				UnityWorld.Trace(IntPtr.Zero, &vec3f3, &vec3f4, &vec3f, &vec3f2, 0u, &mw2Trace);
				Vector3 val = Space.ToUnity(new Vec3f(origin.x, origin.y, origin.z + 35f));
				Vector3 val2 = new Vector3(15f, 35f, 15f) * Space.Scale - Vector3.one * 0.001f;
				Vector3 val3 = Space.DirToUnity(item2);
				Vector3 normalized = ((Vector3)(ref val3)).normalized;
				object obj;
				if (!Physics.BoxCast(val, val2, normalized, ref val4, Quaternion.identity, (item2.z != 0f) ? (Mathf.Abs(item2.z) * Space.Scale) : (8f * Space.Scale), UnityWorld.Mask, (QueryTriggerInteraction)1))
				{
					obj = "nothing";
				}
				else
				{
					object[] obj2 = new object[5]
					{
						((Object)((RaycastHit)(ref val4)).collider).name,
						((object)((RaycastHit)(ref val4)).collider).GetType().Name,
						null,
						null,
						null
					};
					Collider collider = ((RaycastHit)(ref val4)).collider;
					Collider obj3 = ((collider is MeshCollider) ? collider : null);
					obj2[2] = ((obj3 != null) ? new bool?(((MeshCollider)obj3).convex) : ((bool?)null));
					obj2[3] = ((RaycastHit)(ref val4)).distance / Space.Scale;
					obj2[4] = ((RaycastHit)(ref val4)).point;
					obj = string.Format("{0} ({1}, convex {2}) at {3:F2}u point {4}", obj2);
				}
				string text = (string)obj;
				Collider[] source = Physics.OverlapBox(val, val2, Quaternion.identity, UnityWorld.Mask, (QueryTriggerInteraction)1);
				Plugin.Log.LogInfo((object)string.Format("[probe] {0}: fraction {1:F2} startsolid {2} allsolid {3} normal ({4:F2}, {5:F2}, {6:F2}) | cast hits {7} | overlaps {8}", item, mw2Trace.fraction, mw2Trace.startsolid, mw2Trace.allsolid, mw2Trace.normal.x, mw2Trace.normal.y, mw2Trace.normal.z, text, string.Join(", ", source.Select((Collider c) => ((Object)c).name))));
			}
		}
	}
	internal class Mw2Bridge
	{
		private class ScavBag
		{
			public GameObject go;

			public Vector3 at;

			public float until;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static ModifyOutgoingDamageCallback <0>__ArmorPiercing;
		}

		private const float Mw2WalkUnitsPerSec = 190f;

		private const float Ror2SurvivorWalkMetresPerSec = 7f;

		private IntPtr sim;

		private CharacterBody body;

		private CharacterMotor motor;

		private Vector3 footToTransform;

		private Vector3 target;

		private bool haveTarget;

		private float msAccumulator;

		private Mw2State last;

		private string[] loadout = new string[0];

		private int loadoutSlot;

		private string weaponName = "";

		private bool reloadHeld;

		private readonly Mw2Shot[] shotBuffer = new Mw2Shot[64];

		private GameObject tracer;

		private GameObject hitspark;

		private readonly Mw2Audio audio = new Mw2Audio();

		private readonly Mw2Lock lockOn = new Mw2Lock();

		private readonly Mw2Gun gun = new Mw2Gun();

		private readonly Mw2Viewmodel viewmodel = new Mw2Viewmodel();

		private readonly Mw2Viewmodel viewmodelLeft = new Mw2Viewmodel
		{
			Hand = 1u
		};

		private readonly Mw2Killstreaks streaks = new Mw2Killstreaks();

		public readonly Mw2Admin Admin = new Mw2Admin();

		private readonly Mw2Progress progress = new Mw2Progress();

		private bool rankBadgeWired;

		public int Stance;

		private bool sprintWasDown;

		private bool jumpUsedForStance;

		private const float StandViewHeight = 60f;

		private Stage attachedStage;

		private uint netEvents;

		private bool wantOn;

		private readonly Mw2View view = new Mw2View();

		private bool? wantFp;

		private bool thirdOnlyWas;

		private Camera lastCam;

		private int fxFrame = -1;

		private Camera restingFor;

		private Vector3 resting;

		private Quaternion restingRot;

		private bool restoreTilt;

		private bool hudBound;

		private int fragsLeft;

		private int smokesLeft;

		private uint iconsLethal;

		private uint iconsTactical;

		private string savedWeapon;

		private int savedClip;

		private int savedStock;

		private Vec3f pendingLaunch;

		private int launchTicks;

		private bool airborneSinceLaunch;

		private bool markerSlot;

		private int markerSavedTacticals;

		private bool tiThrowing;

		private float tiStarted;

		private int tiSavedTacticals;

		private int tiSavedLethals;

		private uint tiFlare;

		private uint rideLaptop;

		private bool callInClicked;

		private Mw2WeaponView weaponView;

		private Mw2Character character = new Mw2Character();

		private bool characterTried;

		public string SkinKey;

		private CharacterModel characterHid;

		private uint characterEvents;

		private uint lastHit;

		private float nextPain;

		private readonly Queue<Action> warm = new Queue<Action>();

		private float nextWarm;

		public bool Scoped;

		internal static bool ScopeUp;

		private bool scopeThermal;

		private Mw2ViewSway sway;

		private bool wasHolding;

		private float nextHeartbeat;

		public bool Manual;

		public bool OmaPending;

		private bool omaChanging;

		private float omaFrom;

		private float omaUntil;

		private string omaLabel;

		private const string OmaBag = "onemanarmy_mp";

		private string omaReturnTo;

		public const float ClassGraceSeconds = 15f;

		public int PendingClass;

		private CharacterBody lifeBody;

		private float lifeStart;

		private bool combatThisLife;

		private string notice;

		private float noticeUntil;

		private string beforeLastStand;

		private float sprintInches;

		private const float ViewKickScale = 0.2f;

		private const float ViewKickMin = 5f;

		private const float ViewKickMax = 90f;

		private const float ViewKickRandom = 0.4f;

		private Vector3 dmgKick;

		private float dmgKickAt = -10f;

		public float CameraFov = 60f;

		private bool ror2Moving;

		private static readonly MethodInfo findJetpack = AccessTools.Method(typeof(JetpackController), "FindJetpackController", (Type[])null, (Type[])null);

		private int airJumps;

		private bool jumpWasDown;

		private bool crouchPressed;

		private bool pronePressed;

		private uint lethalWeapon;

		private uint tacticalWeapon;

		private int lethalMax;

		private int tacticalMax;

		private readonly Dictionary<uint, (int clip, int stock)> stowedAmmo = new Dictionary<uint, (int, int)>();

		private uint altFrom;

		private float lastDamageAt = -1f;

		private float lastDamage;

		private readonly List<ScavBag> scavBags = new List<ScavBag>();

		private string scavModel;

		private readonly Dictionary<uint, float> launcherCd = new Dictionary<uint, float>();

		private float lethalCd;

		private float tacticalCd;

		private int magSize;

		private float frozenYaw;

		private float frozenPitch;

		private float lastHitSound;

		private float stuckFor;

		private readonly HashSet<uint> maxedThisLife = new HashSet<uint>();

		private float pushStillFor;

		private float lastStuckLog = -10f;

		private Vector3 pushDir;

		private Vec3f pushFrom;

		private int stuckStreak;

		private Vector3 nodeAt;

		private const float JumpHeight = 39f;

		private float divergedFor;

		private static int stuckShots;

		public int LockStage => lockOn.Stage;

		public string LockWhy => lockOn.Why;

		public Mw2Viewmodel ViewmodelForTest => viewmodel;

		private bool Akimbo => last.clipLeft >= 0;

		public Mw2Progress Progress => progress;

		public CharacterBody Body => body;

		public CharacterBody LocalBody => Plugin.CurrentBody();

		public Mw2State State => last;

		public Mw2ViewSway Sway => sway;

		public Mw2Killstreaks Streaks => streaks;

		public string[] Loadout => loadout;

		public byte CharacterStance => (byte)(Mw2Deathstreaks.InLastStand ? 3u : (((last.pmFlags & 1) != 0) ? 2u : (((last.pmFlags & 2) != 0) ? 1u : 0u)));

		public CharacterBody LocalBody2
		{
			get
			{
				if (!Active)
				{
					return null;
				}
				return body;
			}
		}

		public Mw2State Last => last;

		public Transform LocalCharacterRoot => character.Root;

		public string WeaponName => weaponName;

		public bool ShieldHeld
		{
			get
			{
				if (Active && Armed)
				{
					return Mw2Shield.Is(last.weapon);
				}
				return false;
			}
		}

		public bool ShieldBack
		{
			get
			{
				if (Active && !ShieldHeld)
				{
					return Array.Exists(loadout, (string w) => Mw2Shield.Is(Native.WeaponIndex(w)));
				}
				return false;
			}
		}

		public Mw2Killstreaks StreaksRef => streaks;

		private bool wantFirstPerson
		{
			get
			{
				if (ThirdOnly)
				{
					return false;
				}
				if (!wantFp.HasValue)
				{
					wantFp = Mw2Pilot.Active || !Plugin.Instance.ThirdPersonStart.Value;
				}
				return wantFp.Value;
			}
			set
			{
				wantFp = value;
			}
		}

		public bool FirstPerson => wantFirstPerson;

		internal static bool ThirdOnly
		{
			get
			{
				if (!Mw2Pilot.ThirdOnlyTest)
				{
					if (Plugin.Instance.ThirdPersonOnly.Value)
					{
						if (Mw2Pilot.Active)
						{
							return Mw2Pilot.ThirdOnlyConfigTest;
						}
						return true;
					}
					return false;
				}
				return true;
			}
		}

		public uint TiFlare
		{
			get
			{
				if (tiFlare == 0)
				{
					return tiFlare = Native.WeaponIndex("flare_mp");
				}
				return tiFlare;
			}
		}

		public uint AnimWeapon
		{
			get
			{
				if (sim == IntPtr.Zero || !Armed)
				{
					return 0u;
				}
				if (streaks.FreezesPlayer && rideLaptop != 0)
				{
					return rideLaptop;
				}
				return Native.mw2_offhand_viewmodel_weapon(sim);
			}
		}

		public bool CanHoldBreath => sway.canHold != 0;

		public bool HoldingBreath => sway.holding != 0;

		public bool Active => sim != IntPtr.Zero;

		public bool WantOn
		{
			get
			{
				return wantOn;
			}
			set
			{
				wantOn = value;
			}
		}

		public bool InClassGrace
		{
			get
			{
				if (Active && !combatThisLife)
				{
					return Time.time - lifeStart < 15f;
				}
				return false;
			}
		}

		private static bool HeldStill
		{
			get
			{
				if (!Mw2Prematch.Frozen)
				{
					return Mw2Menus.IsOpen;
				}
				return true;
			}
		}

		public Vector3 Kick => (Vector3)(Armed ? new Vector3(last.kickAngles.x, last.kickAngles.y, last.kickAngles.z) : Vector3.zero) + DamageKick();

		public bool RoR2MovingForTest => ror2Moving;

		private bool Armed
		{
			get
			{
				if (Active)
				{
					return last.weapon != 0;
				}
				return false;
			}
		}

		private static float Mw2JumpSpeed => 250f * Mathf.Sqrt(Mathf.Clamp(Plugin.Instance.JumpHeightScale.Value, 0.5f, 4f));

		internal bool ViewFirstPerson => view.FirstPerson;

		public int StuckCount { get; private set; }

		public int MovedCount { get; private set; }

		public int PartedCount { get; private set; }

		public int NodeOutCount { get; private set; }

		public int HopCount { get; private set; }

		public void GiveWeapon(string name)
		{
			Give(name);
		}

		public void PilotLoadout(params string[] names)
		{
			loadout = names;
			loadoutSlot = 0;
			Give(names[0]);
		}

		public void AddXp(int xp)
		{
			progress.Add(xp);
		}

		public uint TakeNetEvents()
		{
			uint result = netEvents;
			netEvents = 0u;
			return result;
		}

		public void LateFrame()
		{
		}

		public void ToggleFirstPerson()
		{
			if (ThirdOnly)
			{
				if (view.FirstPerson)
				{
					view.Exit();
				}
				return;
			}
			wantFirstPerson = !wantFirstPerson;
			if (Active && !((Object)(object)body == (Object)null))
			{
				if (wantFirstPerson)
				{
					view.Enter(body, 60f * Space.Scale);
				}
				else
				{
					view.Exit();
				}
				Plugin.Log.LogInfo((object)("MW2 view: " + (view.FirstPerson ? "first person" : "third person")));
			}
		}

		public void RestCamera(Camera cam)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_003c: 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)
			if (!((Object)(object)cam == (Object)null))
			{
				if ((Object)(object)cam != (Object)(object)restingFor)
				{
					restingFor = cam;
					resting = ((Component)cam).transform.localPosition;
					restingRot = ((Component)cam).transform.localRotation;
				}
				((Component)cam).transform.localPosition = resting;
				if (restoreTilt)
				{
					restoreTilt = false;
					((Component)cam).transform.localRotation = restingRot;
					view.ForgetKick();
				}
			}
		}

		public void RestoreCameraTilt()
		{
			restoreTilt = true;
		}

		public void RenderFx(Camera cam)
		{
			if (fxFrame != Time.frameCount && !((Object)(object)cam == (Object)null))
			{
				fxFrame = Time.frameCount;
				Camera cam2 = (((Object)(object)Mw2Fx.View != (Object)null) ? Mw2Fx.View : cam);
				Mw2Fx.Render(cam2, Time.deltaTime);
				Mw2Gunfire.Render(cam2, Time.deltaTime);
			}
		}

		private unsafe void DrawMenuHud()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			if (!hudBound)
			{
				hudBound = true;
				KeyCode? val = Mw2Binds.For("+holdbreath", "+breath_sprint");
				object label;
				if (val.HasValue)
				{
					KeyCode valueOrDefault = val.GetValueOrDefault();
					label = Mw2Binds.Label(valueOrDefault);
				}
				else
				{
					label = "SHIFT";
				}
				Bind("+holdbreath", (string)label);
				Bind("+actionslot 4", Mw2Binds.Label(Plugin.Instance.StreakKey.Value));
				progress.MenuBar = true;
			}
			if (Native.mw2_offhand_ammo(sim, out fragsLeft, out smokesLeft) != 1)
			{
				fragsLeft = (smokesLeft = 0);
			}
			if (lethalWeapon != 0 && (lethalWeapon != iconsLethal || tacticalWeapon != iconsTactical))
			{
				iconsLethal = lethalWeapon;
				iconsTactical = tacticalWeapon;
				byte[] bytes = Encoding.UTF8.GetBytes(Native.WeaponString(lethalWeapon, 0u));
				byte[] bytes2 = Encoding.UTF8.GetBytes(Native.WeaponString(tacticalWeapon, 0u));
				fixed (byte* frag = bytes)
				{
					fixed (byte* smoke = bytes2)
					{
						Native.mw2_hud_set_offhand(frag, (UIntPtr)(ulong)bytes.Length, smoke, (UIntPtr)(ulong)bytes2.Length);
					}
				}
			}
			Vec3f vec3f = Space.DirToIw(((Object)(object)lastCam != (Object)null) ? ((Component)lastCam).transform.forward : Vector3.forward);
			Mw2MenuHud.Draw(new Mw2HudState
			{
				screenW = Screen.width,
				screenH = Screen.height,
				timeMs = (int)(Time.unscaledTime * 1000f),
				weapon = last.weapon,
				altWeapon = (Akimbo ? last.weapon : 0u),
				clip = last.clip,
				clipSize = MagSize(),
				stock = last.stock,
				altClip = (Akimbo ? last.clipLeft : 0),
				altClipSize = (Akimbo ? MagSize() : 0),
				frags = fragsLeft,
				smokes = smokesLeft,
				yawDeg = Mathf.Atan2(vec3f.y, vec3f.x) * 57.29578f,
				adsFrac = last.adsFrac,
				weaponstate = last.weaponstate,
				xpFrac = progress.XpFrac,
				rank = progress.RankId,
				showBreathHint = (byte)((CanHoldBreath && !HoldingBreath && sway.breathMs == 0 && last.adsFrac > 0.99f) ? 1u : 0u),
				lowAmmoOk = ((!(weaponName == "onemanarmy_mp")) ? ((byte)1) : ((byte)0))
			});
		}

		private unsafe static void Bind(string command, string label)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(command);
			byte[] bytes2 = Encoding.UTF8.GetBytes(label);
			fixed (byte* command2 = bytes)
			{
				fixed (byte* label2 = bytes2)
				{
					Native.mw2_hud_set_binding(command2, (UIntPtr)(ulong)bytes.Length, label2, (UIntPtr)(ulong)bytes2.Length);
				}
			}
		}

		public bool Launch(CharacterMotor m, Vector3 velocity)
		{
			//IL_001e: 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)
			if (!Owns(m) || sim == IntPtr.Zero)
			{
				return false;
			}
			pendingLaunch = Space.DirToIw(velocity / Mathf.Max(Space.Scale, 0.0001f));
			launchTicks = 10;
			return true;
		}

		private void MarkerThrow(ref uint buttons)
		{
			if (sim == IntPtr.Zero)
			{
				return;
			}
			string markerInHand = streaks.MarkerInHand;
			Native.mw2_offhand_ammo(sim, out var lethal, out var tactical);
			if (markerInHand != null)
			{
				if (!markerSlot)
				{
					markerSlot = true;
					markerSavedTacticals = tactical;
					Native.mw2_set_offhand(sim, lethalWeapon, lethal, Native.WeaponIndex(markerInHand), 1);
				}
				else if (tactical == 0)
				{
					streaks.MarkerThrown();
				}
				else if (streaks.PlayerAttack)
				{
					buttons |= 32768u;
				}
			}
			else if (markerSlot && !streaks.CallingIn)
			{
				markerSlot = false;
				Native.mw2_set_offhand(sim, lethalWeapon, lethal, tacticalWeapon, markerSavedTacticals);
			}
		}

		public bool ThrowTacticalInsertion()
		{
			if (!Active || sim == IntPtr.Zero || tiThrowing || markerSlot || TiFlare == 0 || HeldStill)
			{
				return false;
			}
			Native.mw2_offhand_ammo(sim, out var lethal, out var tactical);
			tiSavedTacticals = tactical;
			tiSavedLethals = lethal;
			Native.mw2_set_offhand(sim, 0u, 0, TiFlare, 1);
			tiThrowing = true;
			tiStarted = Time.time;
			return true;
		}

		private void TacticalInsertionThrow(ref uint buttons)
		{
			if (tiThrowing && !(sim == IntPtr.Zero))
			{
				float num = Time.time - tiStarted;
				Native.mw2_offhand_ammo(sim, out var _, out var tactical);
				if (tactical > 0 && num < 0.45f)
				{
					buttons |= 32768u;
				}
				if ((tactical == 0 && num > 0.5f) || num > 3f)
				{
					tiThrowing = false;
					Native.mw2_set_offhand(sim, lethalWeapon, tiSavedLethals, tacticalWeapon, tiSavedTacticals);
				}
			}
		}

		private void CallInWeapon(string name)
		{
			if (Active)
			{
				rideLaptop = Native.WeaponIndex(name);
				savedWeapon = weaponName;
				if (Native.mw2_weapon_ammo(sim, out savedClip, out savedStock) != 1)
				{
					savedWeapon = null;
				}
				Give(name);
				Native.mw2_set_ammo(sim, 1, 0);
			}
		}

		private void RestoreWeapon()
		{
			if (Active && savedWeapon != null)
			{
				Give(savedWeapon);
				Native.mw2_set_ammo(sim, savedClip, savedStock);
				savedWeapon = null;
			}
		}

		public void OnCamera(Camera cam)
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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)
			//IL_0920: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_01be: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			lastCam = cam;
			CameraFov = cam.fieldOfView;
			UpdateSway(Time.deltaTime);
			if (view.FirstPerson && Active && last.viewHeight > 0f)
			{
				Transform transform = ((Component)cam).transform;
				transform.position += Vector3.down * Mathf.Max(60f - last.viewHeight, 0f) * Space.Scale;
			}
			if (Mw2Pilot.Active && view.FirstPerson)
			{
				Mw2Pilot.Steer(((Component)cam).transform);
			}
			Vector3 kickNow = ((Mw2Pilot.Active && Mw2Cinema.Recording) ? Vector3.zero : (Kick + new Vector3(sway.pitch, sway.yaw, 0f)));
			view.OnCamera(cam, kickNow, (Armed && (view.FirstPerson || ThirdOnly)) ? ZoomK() : 1f);
			if (Mw2Pilot.Active && view.FirstPerson)
			{
				Mw2Pilot.AfterCamera(((Component)cam).transform);
			}
			if (Mw2Pilot.FrontCam && !view.FirstPerson && (Object)(object)character.Root != (Object)null)
			{
				Transform root = character.Root;
				Vector3 val = root.position + Vector3.up * 1.1f * root.localScale.x;
				((Component)cam).transform.position = val + (root.forward * 2.6f + root.right * 1.2f + Vector3.up * 0.3f) * root.localScale.x;
				((Component)cam).transform.LookAt(val);
			}
			bool flag = streaks.OnCamera(cam);
			RenderFx(cam);
			bool flag2 = view.FirstPerson && Armed && (Object)(object)view.OverlayTransform != (Object)null && !flag && !streaks.BlocksWeapon;
			bool flag3 = weaponName != null && weaponName.StartsWith("javelin", StringComparison.OrdinalIgnoreCase);
			Scoped = (flag2 || (ThirdOnly && Armed && !flag && !streaks.BlocksWeapon)) && (weaponView.hasOverlay != 0 || flag3) && last.adsFrac >= 0.999f;
			ScopeUp = Scoped;
			bool flag4 = Scoped && weaponName != null && weaponName.IndexOf("_thermal", StringComparison.OrdinalIgnoreCase) >= 0;
			if (flag4 != scopeThermal)
			{
				scopeThermal = flag4;
				if (flag4)
				{
					Mw2Thermal.Begin();
				}
				else
				{
					Mw2Thermal.End();
				}
			}
			uint num;
			IntPtr handle;
			int num2;
			int num3;
			if (flag2)
			{
				num = ((sim != IntPtr.Zero) ? Native.mw2_offhand_viewmodel_weapon(sim) : 0u);
				handle = viewmodel.Handle;
				viewmodel.Build(body, (num != 0) ? num : last.weapon, view.OverlayTransform, Mw2View.Layer, (num == 0) ? altFrom : 0u);
				if (handle != IntPtr.Zero && viewmodel.Handle != IntPtr.Zero)
				{
					num2 = ((viewmodel.Handle != handle) ? 1 : 0);
					if (num2 != 0)
					{
						num3 = ((Mw2Viewmodel.SwapsExpected > 0) ? 1 : 0);
						goto IL_03ec;
					}
				}
				else
				{
					num2 = 0;
				}
				num3 = 0;
				goto IL_03ec;
			}
			viewmodel.Step(sim, 0f, visible: false);
			viewmodelLeft.Step(sim, 0f, visible: false);
			goto IL_06de;
			IL_06de:
			if (Plugin.Instance.Mw2Body.Value && !character.Exists && !characterTried && (Object)(object)body != (Object)null)
			{
				characterTried = true;
				SkinKey = Mw2Skins.KeyFor(body);
				if (character.Build(body, SkinKey))
				{
					bool flag5 = character.UseViewhands();
					Plugin.Log.LogInfo((object)("MW2 viewhands: " + (flag5 ? "the character's own" : "base") + " (" + SkinKey + ")"));
					viewmodel.Destroy();
					viewmodelLeft.Destroy();
					Transform val2 = (((Object)(object)body.modelLocator != (Object)null) ? body.modelLocator.modelTransform : null);
					characterHid = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<CharacterModel>() : null);
					if ((Object)(object)characterHid != (Object)null)
					{
						CharacterModel obj = characterHid;
						int invisibilityCount = obj.invisibilityCount;
						obj.invisibilityCount = invisibilityCount + 1;
					}
					Mw2ItemDisplays.Bind(characterHid, character);
				}
			}
			if (character.Exists)
			{
				StepCharacter((!view.FirstPerson || flag) && (!ThirdOnly || !Scoped || flag));
				gun.SetVisible(visible: false);
				return;
			}
			if (Armed && (!flag2 || !viewmodel.Exists))
			{
				try
				{
					gun.Build(body, last.weapon, Space.Scale);
				}
				catch (Exception arg)
				{
					Plugin.Log.LogWarning((object)$"MW2 gun model failed: {arg}");
				}
			}
			if (Armed && (!flag2 || !viewmodel.Exists))
			{
				gun.PoseView(((Component)cam).transform, firstPerson: false, ((Object)(object)body != (Object)null && (Object)(object)body.inputBank != (Object)null) ? body.inputBank.aimDirection : ((Component)cam).transform.forward, last.adsFrac, Space.Scale);
			}
			gun.SetVisible(!flag2 || !viewmodel.Exists);
			return;
			IL_03ec:
			bool flag6 = (byte)num3 != 0;
			if (num2 != 0 && Mw2Viewmodel.SwapBlend > 0f && !flag6)
			{
				Plugin.Log.LogInfo((object)$"[cinema] unplanned viewmodel rebuild: weapon {Native.WeaponString(last.weapon, 2u)}, offhand {num} (no dissolve)");
			}
			if (flag6)
			{
				Mw2Viewmodel.SwapsExpected--;
			}
			if (Mw2Viewmodel.SwapBlend > 0f && flag6)
			{
				if (Mw2Viewmodel.PilotSlot >= 0)
				{
					float num4 = Native.mw2_viewmodel_match_phase(viewmodel.Handle, handle, (uint)Mw2Viewmodel.PilotSlot, Mw2Viewmodel.PilotFrac);
					if (num4 >= 0f)
					{
						Mw2Viewmodel.PilotFrac = num4;
					}
				}
				Native.mw2_viewmodel_blend_from(viewmodel.Handle, handle, Mw2Viewmodel.SwapBlend);
				Mw2Cinema.SwapDissolve(viewmodel.PreviousRoot, viewmodel.RootObject);
			}
			viewmodel.Step(sim, Time.deltaTime, !Scoped);
			if (weaponName != null && weaponName.IndexOf("_heartbeat", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				Mw2Heartbeat.Update(body, ((Component)cam).transform);
			}
			string[] array = viewmodel.TakeSounds();
			foreach (string text in array)
			{
				if (!(text == Mw2Viewmodel.SkipAlias))
				{
					audio.PlayAlias(text);
					Plugin.Log.LogInfo((object)("[vmsound] " + text));
				}
			}
			if (Akimbo && num == 0)
			{
				IntPtr handle2 = viewmodelLeft.Handle;
				viewmodelLeft.Build(body, last.weapon, view.OverlayTransform, Mw2View.Layer);
				IntPtr intPtr = ((handle2 != IntPtr.Zero) ? handle2 : handle);
				if (Mw2Viewmodel.SwapBlend > 0f && intPtr != IntPtr.Zero && viewmodelLeft.Handle != IntPtr.Zero && viewmodelLeft.Handle != handle2)
				{
					Native.mw2_viewmodel_blend_from(viewmodelLeft.Handle, intPtr, Mw2Viewmodel.SwapBlend);
					if (handle2 != IntPtr.Zero)
					{
						Mw2Cinema.SwapDissolve(viewmodelLeft.PreviousRoot, viewmodelLeft.RootObject);
					}
				}
				viewmodelLeft.Step(sim, Time.deltaTime, visible: true);
				array = viewmodelLeft.TakeSounds();
				foreach (string alias in array)
				{
					audio.PlayAlias(alias);
				}
			}
			else
			{
				viewmodelLeft.Step(sim, 0f, visible: false);
			}
			goto IL_06de;
		}

		private void StepCharacter(bool visible)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Space.DirToUnity(ViewForward(new Vec3f(0f, last.viewangles.y, 0f)));
			float yawDeg = Mathf.Atan2(val.x, val.z) * 57.29578f;
			float num = last.viewangles.y * (MathF.PI / 180f);
			float x = last.velocity.x;
			float y = last.velocity.y;
			Mw2CharacterInput input = new Mw2CharacterInput
			{
				dt = Time.deltaTime,
				stance = CharacterStance,
				sprinting = last.sprinting,
				inAir = ((last.grounded == 0) ? ((byte)1) : ((byte)0)),
				dead = (byte)(((Object)(object)body != (Object)null && (Object)(object)body.healthComponent != (Object)null && !body.healthComponent.alive) ? 1u : 0u),
				moveFwd = x * Mathf.Cos(num) + y * Mathf.Sin(num),
				moveRight = x * Mathf.Sin(num) - y * Mathf.Cos(num),
				aimPitch = last.viewangles.x,
				adsFrac = last.adsFrac,
				weapon = (Armed ? last.weapon : 0u),
				events = characterEvents,
				hit = lastHit
			};
			characterEvents = 0u;
			character.StowedShield = (ShieldBack ? Mw2Shield.Index : 0u);
			character.AnimWeapon = AnimWeapon;
			character.Step(body.footPosition, yawDeg, ref input, visible);
		}

		private unsafe void QueueWarmup(CharacterBody b)
		{
			warm.Clear();
			string[] array = loadout;
			for (int i = 0; i < array.Length; i++)
			{
				Native.mw2_prefetch_weapon(Native.WeaponIndex(array[i]));
			}
			List<string> list = new List<string>();
			array = new string[15]
			{
				"ac130_overlay_grain", "minimap_background", "minimap_scanlines", "compass_radarline", "compassping_player", "compassping_enemy", "damage_feedback", "hit_direction", "blood_splatter", "720_xpbar_empty",
				"720_xpbar_solid", "ammo_counter_riflebullet_mp", "ammo_counter_bullet_mp", "ammo_counter_shotgunshell_mp", "ammo_counter_beltbullet_mp"
			};
			foreach (string img in array)
			{
				list.Add(img);
				warm.Enqueue(delegate
				{
					Mw2Icons.Get(img);
				});
			}
			Mw2StreakState mw2StreakState = streaks.State();
			for (int num = 0; num < mw2StreakState.loadoutLen; num++)
			{
				uint id = mw2StreakState.loadout[num];
				list.Add(Native.StreakString(id, 5u));
				list.Add(Native.StreakString(id, 7u));
				warm.Enqueue(delegate
				{
					Mw2Icons.Get(Native.StreakString(id, 5u));
					Mw2Icons.Get(Native.StreakString(id, 7u));
				});
			}
			string[] array2 = new string[11]
			{
				"com_plasticcase_friendly", "sentry_minigun", "sentry_minigun_obj", "vehicle_little_bird_armed", "vehicle_cobra_helicopter_fly_low", "vehicle_pavelow", "vehicle_apache_mp", "vehicle_ac130_low_mp", "vehicle_av8b_harrier_jet_mp", "vehicle_mig29_desert",
				"vehicle_b2_bomber"
			};
			list.AddRange(array2);
			string[] array3 = ClassLoadout();
			List<string> list2 = new List<string>();
			if (array3 != null && array3.Length > 3)
			{
				list2.Add(array3[2]);
				list2.Add(array3[3]);
			}
			else
			{
				list2.Add(Plugin.Instance.Lethal.Value);
				list2.Add(Plugin.Instance.Tactical.Value);
			}
			for (int num2 = 0;