Decompiled source of Minimal Viewmodels Reborn v1.3.8

BepInEx/plugins/MinimalViewmodelsReborn/MinimalViewmodelsReborn-v1.3.8.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MinimalViewmodelsReborn.Patches;
using MinimalViewmodelsReborn.Utils;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(true)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MinimalViewmodelsReborn")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A remake of the original Minimal Viewmodels, updated with many new features and fixes.")]
[assembly: AssemblyFileVersion("1.3.8.0")]
[assembly: AssemblyInformationalVersion("1.3.8")]
[assembly: AssemblyProduct("MinimalViewmodelsReborn")]
[assembly: AssemblyTitle("MinimalViewmodelsReborn")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}
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 MinimalViewmodelsReborn
{
	[BepInPlugin("kestrel.straftat.minimalviewmodels", "MinimalViewmodelsReborn", "1.3.8")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static readonly string loadBearingColonThree = ":3";

		public static ConfigEntry<float> ViewmodelOffsetX { get; private set; }

		public static ConfigEntry<float> ViewmodelOffsetY { get; private set; }

		public static ConfigEntry<float> ViewmodelOffsetZ { get; private set; }

		public static ConfigEntry<float> ViewmodelFOV { get; private set; }

		public static ConfigEntry<bool> MirrorViewmodel { get; private set; }

		public static ConfigEntry<bool> InvisibleViewmodels { get; private set; }

		public static ConfigEntry<bool> InvisibleArms { get; private set; }

		public static ConfigEntry<float> MuzzleFlashLightIntensity { get; private set; }

		public static ConfigEntry<float> MuzzleFlashScale { get; private set; }

		public static ConfigEntry<bool> HideBulletTrails { get; private set; }

		public static ConfigEntry<float> RunFovIncrease { get; private set; }

		public static ConfigEntry<float> SlideFovIncrease { get; private set; }

		public static ConfigEntry<float> RunSlideFovIncrease { get; private set; }

		public static Vector3 ViewmodelOffset => new Vector3(ViewmodelOffsetX.Value, ViewmodelOffsetY.Value, ViewmodelOffsetZ.Value);

		public static Plugin Instance { get; private set; }

		internal void InitConfigs()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			InvisibleViewmodels = ((BaseUnityPlugin)this).Config.Bind<bool>("Viewmodels.Visibility", "Invisible Viewmodels", false, "Hides your weapon completely.");
			InvisibleArms = ((BaseUnityPlugin)this).Config.Bind<bool>("Viewmodels.Visibility", "Invisible Arms", false, "Hides your arms.");
			ViewmodelFOV = ((BaseUnityPlugin)this).Config.Bind<float>("Viewmodels.Visibility", "Viewmodel FOV", 75f, "Set the FOV of the viewmodel camera.");
			MirrorViewmodel = ((BaseUnityPlugin)this).Config.Bind<bool>("Viewmodels.Visibility", "Mirror Viewmodel", false, "Mirrors your viewmodel.");
			ViewmodelOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Viewmodels.Offset", "Viewmodel X Offset", 0f, new ConfigDescription("Negative values will shift your held weapon left, Positive values will shift it right.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
			ViewmodelOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Viewmodels.Offset", "Viewmodel Y Offset", -0.1f, new ConfigDescription("Negative values will shift your held weapon down, Positive values will shift it up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
			ViewmodelOffsetZ = ((BaseUnityPlugin)this).Config.Bind<float>("Viewmodels.Offset", "Viewmodel Z Offset", 0f, new ConfigDescription("Negative values will shift your held weapon back, Positive values will shift it forward.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
			HideBulletTrails = ((BaseUnityPlugin)this).Config.Bind<bool>("VFX.General", "Hide Bullet Trails", false, "Hides bullet trails.");
			MuzzleFlashScale = ((BaseUnityPlugin)this).Config.Bind<float>("VFX.MuzzleFlashes", "Muzzle Flash Scale", 1f, "A multiplier applied to the scale of muzzle flashes. Requires a map restart to apply.");
			RunFovIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicFov.General", "Run Fov Increase", 15f, "When sprinting, your FOV will be increased by this amount.");
			SlideFovIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicFov.General", "Slide Fov Increase", 12f, "When sliding, your FOV will be increased by this amount.");
			RunSlideFovIncrease = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicFov.General", "Run Slide Fov Increase", 15f, "When sprinting and sliding, your FOV will be increased by this amount.");
		}

		private void Awake()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (loadBearingColonThree != ":3")
			{
				Application.Quit();
			}
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			InitConfigs();
			((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
			new Harmony("kestrel.straftat.minimalviewmodels").PatchAll();
			Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
		}

		private static void OnSettingChanged(object sender, SettingChangedEventArgs e)
		{
			ViewmodelModifier.Apply();
			MuzzleFlashModifier.Apply();
			DynamicFovModifier.Apply();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "kestrel.straftat.minimalviewmodels";

		public const string PLUGIN_NAME = "MinimalViewmodelsReborn";

		public const string PLUGIN_VERSION = "1.3.8";
	}
}
namespace MinimalViewmodelsReborn.Utils
{
	internal static class GameObjectExtensions
	{
		internal static void SetLayer(this GameObject obj, LayerMask layer)
		{
			//IL_0001: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			obj.layer = LayerMask.op_Implicit(layer);
			foreach (Transform item in obj.transform)
			{
				((Component)item).gameObject.layer = LayerMask.op_Implicit(layer);
			}
		}
	}
	internal static class PatchHelpers
	{
		internal static MethodBase GetRpcLogicMethod(this Type type, string methodName)
		{
			return type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic).First((MethodInfo m) => m.Name.StartsWith("RpcLogic___" + methodName + "_"));
		}

		internal static IEnumerable<MethodBase> GetRpcLogicMethods(this IEnumerable<Type> types, string methodName)
		{
			return from m in types.SelectMany((Type t) => t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
				where m.Name.StartsWith("RpcLogic___" + methodName + "_")
				select m;
		}
	}
	internal static class TypeHelpers
	{
		internal static IEnumerable<Type> WeaponTypes { get; private set; } = from t in AccessTools.AllTypes()
			where t != typeof(Weapon) && typeof(Weapon).IsAssignableFrom(t)
			select t;
	}
}
namespace MinimalViewmodelsReborn.Patches
{
	public static class DynamicFovModifier
	{
		[HarmonyPatch(typeof(FirstPersonController))]
		public static class FirstPersonControllerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			public static void ApplyOnStart(FirstPersonController __instance)
			{
				m_controller = __instance;
				Apply();
			}
		}

		private static FirstPersonController m_controller;

		public static void Apply()
		{
			if (Object.op_Implicit((Object)(object)m_controller))
			{
				m_controller.distToRunFov = Plugin.RunFovIncrease.Value;
				m_controller.distToSlideFov = Plugin.SlideFovIncrease.Value;
				m_controller.distToRunSlideFov = Plugin.RunSlideFovIncrease.Value;
			}
		}
	}
	public static class MuzzleFlashModifier
	{
		[HarmonyPatch(typeof(Weapon))]
		public static class WeaponPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPrefix]
			public static void ModifyBrightness(Weapon __instance, ref float ___lightIntensity, GameObject ___muzzleFlash)
			{
				//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_003e: 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)
				if (Object.op_Implicit((Object)(object)___muzzleFlash) && !m_modifiedMuzzleFlashes.Contains(___muzzleFlash))
				{
					ParticleSystem[] componentsInChildren = ___muzzleFlash.GetComponentsInChildren<ParticleSystem>(true);
					foreach (ParticleSystem obj in componentsInChildren)
					{
						MainModule main = obj.main;
						((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
						((Component)obj).gameObject.transform.localScale = Vector3.one * Plugin.MuzzleFlashScale.Value;
					}
					m_modifiedMuzzleFlashes.Add(___muzzleFlash);
				}
			}
		}

		private static HashSet<GameObject> m_modifiedMuzzleFlashes = new HashSet<GameObject>();

		public static void Apply()
		{
			m_modifiedMuzzleFlashes.Clear();
		}
	}
	public static class VfxPatches
	{
		[HarmonyPatch]
		public static class SpawnBulletTrailPatch
		{
			[HarmonyTargetMethods]
			private static IEnumerable<MethodBase> TargetMethods()
			{
				return TypeHelpers.WeaponTypes.GetRpcLogicMethods("SpawnBulletTrail");
			}

			[HarmonyPrefix]
			private static bool FixHitPoint(Weapon __instance, ref Vector3 hitPoint, Camera ___cam, LineRenderer ___bulletTrailLocal)
			{
				//IL_0023: 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_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: 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)
				if (!((NetworkBehaviour)__instance).IsOwner)
				{
					return true;
				}
				if (Plugin.HideBulletTrails.Value)
				{
					return false;
				}
				hitPoint = ((Component)ViewmodelModifier.WeaponCam).transform.position + (hitPoint - ((Component)___cam).transform.position);
				if (Object.op_Implicit((Object)(object)___bulletTrailLocal))
				{
					((Component)___bulletTrailLocal).gameObject.SetLayer(m_heldLayer);
				}
				return true;
			}

			[HarmonyPostfix]
			private static void ResetVfxLayers(Weapon __instance, LineRenderer ___bulletTrailLocal)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)___bulletTrailLocal) && ((NetworkBehaviour)__instance).IsOwner)
				{
					((Component)___bulletTrailLocal).gameObject.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch(typeof(Weapon), "OnShoot")]
		public static class WeaponPatch
		{
			[HarmonyPrefix]
			public static void SetVfxLayers(Weapon __instance, GameObject ___ejectCaseVfx)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)___ejectCaseVfx) && ((NetworkBehaviour)__instance).IsOwner)
				{
					___ejectCaseVfx.SetLayer(m_heldLayer);
				}
			}

			[HarmonyPostfix]
			public static void ResetVfxLayers(Weapon __instance, GameObject ___ejectCaseVfx)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)___ejectCaseVfx) && ((NetworkBehaviour)__instance).IsOwner)
				{
					___ejectCaseVfx.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch]
		public static class MuzzleFlashFix
		{
			[HarmonyTargetMethods]
			private static IEnumerable<MethodBase> TargetMethods()
			{
				return from m in TypeHelpers.WeaponTypes.Except(new <>z__ReadOnlySingleElementList<Type>(typeof(BeamGun))).SelectMany((Type t) => t.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic))
					where m.Name.StartsWith("RpcLogic___ShootObserversEffect_")
					select m;
			}

			[HarmonyPrefix]
			private static void SetVfxLayers(Weapon __instance, GameObject ___muzzleFlash)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)___muzzleFlash) && ((NetworkBehaviour)__instance).IsOwner)
				{
					___muzzleFlash.SetLayer(m_heldLayer);
				}
			}

			[HarmonyPostfix]
			private static void ResetVfxLayers(Weapon __instance, GameObject ___muzzleFlash)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)___muzzleFlash) && ((NetworkBehaviour)__instance).IsOwner)
				{
					___muzzleFlash.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch(typeof(DualLauncher), "Update")]
		public static class DualLauncherPatch
		{
			[HarmonyPrefix]
			public static void SetVfxLayers(DualLauncher __instance, bool ___grenadeOpen, ParticleSystem ___grenadeSmoke)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (___grenadeOpen && ((NetworkBehaviour)__instance).IsOwner)
				{
					((Component)___grenadeSmoke).gameObject.SetLayer(m_heldLayer);
				}
			}

			[HarmonyPostfix]
			public static void ResetVfxLayers(DualLauncher __instance, bool ___grenadeOpen, ParticleSystem ___grenadeSmoke)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (___grenadeOpen && ((NetworkBehaviour)__instance).IsOwner)
				{
					((Component)___grenadeSmoke).gameObject.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch(typeof(BeamGun))]
		public static class BeamGunMuzzleFlash2Patch
		{
			[HarmonyTargetMethod]
			private static MethodBase TargetMethod()
			{
				return typeof(BeamGun).GetRpcLogicMethod("ShootObserversEffect");
			}

			[HarmonyPrefix]
			public static void SetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash2)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash2))
				{
					___muzzleFlash2.SetLayer(m_heldLayer);
				}
			}

			[HarmonyPostfix]
			public static void ResetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash2)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash2))
				{
					___muzzleFlash2.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch(typeof(BeamGun))]
		public static class BeamGunMuzzleFlashPatch
		{
			[HarmonyTargetMethod]
			private static MethodBase TargetMethod()
			{
				return typeof(BeamGun).GetRpcLogicMethod("ShootObserversEffect2");
			}

			[HarmonyPrefix]
			public static void SetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
				{
					___muzzleFlash.SetLayer(m_heldLayer);
				}
			}

			[HarmonyPostfix]
			public static void ResetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
				{
					___muzzleFlash.SetLayer(m_defaultLayer);
				}
			}
		}

		[HarmonyPatch(typeof(WeaponHandSpawner))]
		public static class WeaponHandSpawnerPatch
		{
			[HarmonyPatch("HandlePlacement")]
			[HarmonyPostfix]
			private static void FixPlacementHologram(Transform ___previewObject)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				((Component)___previewObject.GetChild(0)).gameObject.layer = LayerMask.op_Implicit(m_defaultLayer);
			}
		}

		private static LayerMask m_heldLayer = LayerMask.op_Implicit(LayerMask.NameToLayer("HeldWeapon"));

		private static LayerMask m_defaultLayer = LayerMask.op_Implicit(LayerMask.NameToLayer("Default"));
	}
	public static class ViewmodelModifier
	{
		[HarmonyPatch(typeof(PlayerSetup))]
		public static class PlayerSetupPatch
		{
			[HarmonyPatch("OnStartClient")]
			[HarmonyPostfix]
			private static void FixCameras(PlayerSetup __instance, Camera[] ___cameras, LayerMask ___highMask, GameObject[] ___fpArms)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				if (((NetworkBehaviour)__instance).IsOwner)
				{
					___cameras[0].cullingMask = LayerMask.op_Implicit(___highMask);
					WeaponCam = ___cameras[1];
					m_armRenderers = ___fpArms.Select((GameObject obj) => obj.GetComponent<SkinnedMeshRenderer>()).ToArray();
					((Behaviour)WeaponCam).enabled = true;
					if (Settings.Instance.qualitySetting < 2)
					{
						((Behaviour)((Component)WeaponCam).GetComponent<PostProcessLayer>()).enabled = false;
					}
					Apply();
				}
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static CameraCallback <0>__OnPreRender;

			public static CameraCallback <1>__OnPostRender;
		}

		private static SkinnedMeshRenderer[] m_armRenderers;

		public static Camera WeaponCam { get; private set; }

		public static void Apply()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//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_010e: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_0132: 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_013d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)WeaponCam))
			{
				return;
			}
			bool value = Plugin.InvisibleArms.Value;
			SkinnedMeshRenderer[] armRenderers = m_armRenderers;
			for (int i = 0; i < armRenderers.Length; i++)
			{
				((Renderer)armRenderers[i]).enabled = !value;
			}
			((Behaviour)WeaponCam).enabled = !Plugin.InvisibleViewmodels.Value;
			if (Plugin.InvisibleViewmodels.Value)
			{
				return;
			}
			((Component)WeaponCam).transform.localPosition = -Plugin.ViewmodelOffset;
			WeaponCam.projectionMatrix = ConstructCameraProjectionMatrix();
			CameraCallback onPreRender = Camera.onPreRender;
			object obj = <>O.<0>__OnPreRender;
			if (obj == null)
			{
				CameraCallback val = OnPreRender;
				<>O.<0>__OnPreRender = val;
				obj = (object)val;
			}
			Camera.onPreRender = (CameraCallback)Delegate.Remove((Delegate?)(object)onPreRender, (Delegate?)obj);
			CameraCallback onPostRender = Camera.onPostRender;
			object obj2 = <>O.<1>__OnPostRender;
			if (obj2 == null)
			{
				CameraCallback val2 = OnPostRender;
				<>O.<1>__OnPostRender = val2;
				obj2 = (object)val2;
			}
			Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)onPostRender, (Delegate?)obj2);
			if (Plugin.MirrorViewmodel.Value)
			{
				CameraCallback onPreRender2 = Camera.onPreRender;
				object obj3 = <>O.<0>__OnPreRender;
				if (obj3 == null)
				{
					CameraCallback val3 = OnPreRender;
					<>O.<0>__OnPreRender = val3;
					obj3 = (object)val3;
				}
				Camera.onPreRender = (CameraCallback)Delegate.Combine((Delegate?)(object)onPreRender2, (Delegate?)obj3);
				CameraCallback onPostRender2 = Camera.onPostRender;
				object obj4 = <>O.<1>__OnPostRender;
				if (obj4 == null)
				{
					CameraCallback val4 = OnPostRender;
					<>O.<1>__OnPostRender = val4;
					obj4 = (object)val4;
				}
				Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)onPostRender2, (Delegate?)obj4);
			}
		}

		private static void OnPreRender(Camera cam)
		{
			if ((Object)(object)cam == (Object)(object)WeaponCam)
			{
				GL.invertCulling = true;
			}
		}

		private static void OnPostRender(Camera cam)
		{
			if ((Object)(object)cam == (Object)(object)WeaponCam)
			{
				GL.invertCulling = false;
			}
		}

		private static Matrix4x4 ConstructCameraProjectionMatrix()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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)
			float num = (float)Screen.width / (float)Screen.height;
			Matrix4x4 val = Matrix4x4.Perspective(Plugin.ViewmodelFOV.Value, num, 0.1f, 100f);
			if (Plugin.MirrorViewmodel.Value)
			{
				val *= Matrix4x4.Scale(new Vector3(-1f, 1f, 1f));
			}
			return val;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}