Decompiled source of Aiyke code mod pack v4.0.0

h3vr_code_mod.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Aiyke")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A collection of code mods doing a variety of things for H3VR.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("h3vr_code_mod")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace plugin
{
	[BepInPlugin("Aiyke.code_mod", "code_mod", "3.0.0")]
	[BepInProcess("h3vr.exe")]
	public class code_mod : BaseUnityPlugin
	{
		private struct em_mod
		{
			public Sosig obj;

			public int id;

			public bool trigger_hold;

			public float t_fire;

			public float t_fire2;

			public float t_burst;

			public em_mod(Sosig instance, int index)
			{
				obj = null;
				id = 0;
				trigger_hold = false;
				t_fire = 0f;
				t_fire2 = 0f;
				t_burst = 0f;
				obj = instance;
				id = ((Object)instance).GetInstanceID();
			}
		}

		public static ConfigEntry<bool> bullet_pen_mod;

		public static ConfigEntry<float> pl_in_dmg_mult;

		private static float pl_in_dmg_mult_prev = 0f;

		private static bool pl_in_dmg_mult_changed = false;

		public static ConfigEntry<float> pl_out_dmg_mult;

		public static ConfigEntry<bool> hit_sound;

		public static ConfigEntry<float> hit_sound_vol;

		public static ConfigEntry<bool> tracer_spin;

		public static ConfigEntry<bool> em_aim_mod;

		public static ConfigEntry<float> em_acc_mult;

		public static ConfigEntry<bool> em_wpn_mod;

		public static ConfigEntry<bool> em_wpn_coll_mod;

		public static ConfigEntry<bool> em_alert_mod;

		public static ConfigEntry<float> em_move_mod_amt;

		public static ConfigEntry<float> em_stagger_mod;

		public static ConfigEntry<float> em_suppress_mod;

		public static ConfigEntry<bool> red_blood;

		public static ConfigEntry<bool> obj_sinking;

		public static ConfigEntry<bool> fix_grip_pos;

		public static ConfigEntry<bool> better_reflex_sights;

		public static ConfigEntry<bool> pistol_slide_tilt;

		public static ConfigEntry<bool> metric_box_txt;

		public static ConfigEntry<float> las_vis;

		public static ConfigEntry<float> expl_mod;

		public static ConfigEntry<bool> flash_mod;

		public static ConfigEntry<bool> red_hit_fx;

		public static ConfigEntry<bool> health_warn;

		public static ConfigEntry<bool> aim_assist;

		public static ConfigEntry<float> aim_assist_amt;

		public static ConfigEntry<bool> short_teleport;

		public static ConfigEntry<float> short_teleport_amt;

		public static ConfigEntry<bool> spectator_zoom;

		public static ConfigEntry<float> spec_zoom_hold_time;

		public static ConfigEntry<float> spec_zoom_aim_radius;

		public static ConfigEntry<float> spec_fov_norm;

		public static ConfigEntry<float> spec_fov_zoomed;

		public static ConfigEntry<bool> tah_all_panels;

		public static ConfigEntry<bool> correct_cz52;

		private static Collider[] collider_array = (Collider[])(object)new Collider[2048];

		private static List<em_mod> em_states = new List<em_mod>();

		private static bool half_frame = false;

		private static bool in_radius = false;

		private static float time_inside_radius = 0f;

		private static float print_timer = 0f;

		private static bool log_bullet_events = false;

		private static int impact_frame = 0;

		private static byte armor_lv = 0;

		private static bool flat_bullet = false;

		private static bool was_this_bullet_able_to_pierce_armor_normally = false;

		private static Renderer[] renderers_array = (Renderer[])(object)new Renderer[8];

		private static Collider[] colliders_array = (Collider[])(object)new Collider[8];

		private static float low_health_warning_timer = 0f;

		private static float health_percent_prev = 0f;

		private static float half_health_warn_tmr = 0f;

		private static float quarter_health_warn_tmr = 0f;

		private static Rigidbody[] rigidbodies_array = (Rigidbody[])(object)new Rigidbody[2];

		private static Stopwatch timer { get; } = new Stopwatch();

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogMessage((object)"code_mod plugin active.");
			bullet_pen_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Bullets and damage", "Modified bullet penetration", true, "Modified bullet penetration system.\n12-gauge slugs kill enemies with level 1 armor in 2 shots.");
			pl_in_dmg_mult = ((BaseUnityPlugin)this).Config.Bind<float>("Bullets and damage", "Incoming damage multiplier", 0.9f, "Multiplier for damage you take.");
			pl_out_dmg_mult = ((BaseUnityPlugin)this).Config.Bind<float>("Bullets and damage", "Output damage multiplier", 1f, "Multiplier for damage enemies take.");
			hit_sound = ((BaseUnityPlugin)this).Config.Bind<bool>("Bullets and damage", "Hit confirm sound", false, "Plays a bullet hit sound when you hit an enemy over 5 m away.");
			hit_sound_vol = ((BaseUnityPlugin)this).Config.Bind<float>("Bullets and damage", "Hit sound volume", 0.5f, "Volume of the hit confirm sound");
			tracer_spin = ((BaseUnityPlugin)this).Config.Bind<bool>("Bullets and damage", "Tracer spinning", true, "Makes tracers spin in flight.");
			fix_grip_pos = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Fixed grip positions", true, "Fixes the grip positions for some guns, including the Evo3 series and some MP5s.");
			better_reflex_sights = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Better reflex sights", true, "Reduces the excessive tint on reflex sights and disables the grain effect on holographic sights.\nIf it doesn't work at first, detach and re-attach to apply the changes.");
			pistol_slide_tilt = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Pistol slide pull tilt", true, "Tilts pistols upwards when the slide is all the way back.");
			metric_box_txt = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Metric ammo box text", true, "Makes cartridge boxes show metric units.\nAlso shows kinetic energy (Joules) and armor piercing power as apostrophes (')");
			obj_sinking = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Gibs and casings sinking", true, "Makes gibs and empty casings sink into the ground after a while.");
			las_vis = ((BaseUnityPlugin)this).Config.Bind<float>("Weapons and other objects", "Laser visibility", 2f, "Adjusts the visibility of laser beams.\nDoes not work with built-in lasers like on the PMM.");
			correct_cz52 = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Correct CZ 52", true, "Changes the CZ 52 to use 7.62x25 mm instead of 9x19 mm.");
			tah_all_panels = ((BaseUnityPlugin)this).Config.Bind<bool>("Weapons and other objects", "Take and Hold force all sub-panels", false, "Forces recycler, ammo, and magazine panels to all spawn at every supply point; as long as those types are available in the character definition.");
			expl_mod = ((BaseUnityPlugin)this).Config.Bind<float>("Explosives", "Explosive damage radius multiplier", 2f, "Adjusts explosive 'splash damage' radius.");
			flash_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Explosives", "More blinding flash grenades", true, "Does as stated.");
			em_aim_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Chest aim", true, "Makes enemies aim for your chest instead of your head.\nThis makes crouching and/or staying behind cover more effective.");
			em_acc_mult = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "Accuracy multiplier", 1f, "Adjusts the spread and recoil of their guns.");
			em_wpn_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Full auto usage", true, "Makes enemies shoot fully automatic guns in bursts.\nWARNING: this can make combat significantly harder.");
			em_wpn_coll_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Disable gun collision", true, "Makes enemy guns no longer act as impenetrable shields.");
			em_alert_mod = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Better alertness", true, "Makes them realise they're being shot at more consistently.\nWithout it, they sometimes don't hear gunshots right next to them.");
			em_move_mod_amt = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "Movement while engaging multiplier", 1.5f, "Adjusts how much they hold still while engaging.\nHigher = less movement");
			em_stagger_mod = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "Stagger resistance", 1f, "Adjusts how resistant they are to confusion, staggering, and being knocked unconscious.\nHigher = less confusion");
			em_suppress_mod = ((BaseUnityPlugin)this).Config.Bind<float>("Enemies", "Suppression resistance", 2f, "Adjusts how resistant they are to suppression.\nHigher = less suppression");
			red_blood = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "Ketchup", true, "Makes 'blood' red instead of yellow.");
			red_hit_fx = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Red hit flash effect", true, "Changes the hit flash colour from white to red.");
			health_warn = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Low wealth warning", true, "Shows subtle periodic flashing if health is below half, and gets more intense the lower it is.");
			aim_assist = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Aim assistance*", false, "Experimental aim assistance.\nIt works when you're aiming within 5 degrees of an enemy.\nIt messes up sometimes.");
			aim_assist_amt = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Aim assistance amount", 0.5f, "Strength of the aim assistance.");
			short_teleport = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Short teleport", true, "Enables short forward and backward teleport using the stick up and down with teleport movement mode.\nUseful for engaging from behind cover.");
			short_teleport_amt = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Short teleport amount", 0.2f, "Short teleport distance (metres)");
			spectator_zoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Spectator", "Spectator zoom when aiming", false, "Zooms the spectator camera when aiming a loaded gun.\nTry to keep the sights in the middle of your field of vision.");
			spec_zoom_hold_time = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Aim hold time", 0.3f, "How long aiming has to be held before zooming in.\nThis prevents unwanted zooming out when shooting.");
			spec_zoom_aim_radius = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Aim radius", 15f, "Size of the 'circle' around the spectator camera's center in which zooming can occur.");
			spec_fov_zoomed = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Spectator zoomed in FOV", 30f, "Spectator FOV when aiming.\nSmaller = more magnification.");
			spec_fov_norm = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Spectator normal FOV", 55f, "Normal FOV for the spectator when not aiming.");
			Harmony.CreateAndPatchAll(typeof(code_mod), (string)null);
		}

		private void Update()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			float deltaTime = Time.deltaTime;
			if (half_frame)
			{
				half_frame = false;
			}
			else
			{
				half_frame = true;
				if (Random.value < 0.5f && (Object)(object)collider_array[0] != (Object)null)
				{
					for (int i = 0; i < collider_array.Length; i++)
					{
						collider_array[i] = null;
					}
				}
			}
			if (pl_in_dmg_mult_prev != pl_in_dmg_mult.Value)
			{
				pl_in_dmg_mult_changed = true;
			}
			if (pl_in_dmg_mult.Value < 0.001f)
			{
				pl_in_dmg_mult.Value = 0.001f;
			}
			pl_in_dmg_mult_prev = pl_in_dmg_mult.Value;
			if (pl_out_dmg_mult.Value < 0.001f)
			{
				pl_out_dmg_mult.Value = 0.001f;
			}
			if (em_acc_mult.Value < 0.01f)
			{
				em_acc_mult.Value = 0.01f;
			}
			if (spectator_zoom.Value)
			{
				if (in_radius)
				{
					time_inside_radius += deltaTime;
				}
				else
				{
					time_inside_radius -= deltaTime;
				}
				if (time_inside_radius > spec_zoom_hold_time.Value)
				{
					GM.Options.SpectatorCamera.CurrentSettings.CameraFov = spec_fov_zoomed.Value;
				}
				else
				{
					GM.Options.SpectatorCamera.CurrentSettings.CameraFov = spec_fov_norm.Value;
				}
			}
			if (time_inside_radius > 1f)
			{
				time_inside_radius = 1f;
			}
			if (time_inside_radius < 0f)
			{
				time_inside_radius = 0f;
			}
			if (!GM.CurrentPlayerBody.HasAGunInHand() || !spectator_zoom.Value)
			{
				time_inside_radius = 0f;
				GM.Options.SpectatorCamera.CurrentSettings.CameraFov = spec_fov_norm.Value;
			}
			print_timer += deltaTime;
			if (print_timer > 1f)
			{
				print_timer = 0f;
			}
		}

		private static float fabs(float x)
		{
			return Mathf.Abs(x);
		}

		private static float pow(float x, float p)
		{
			return Mathf.Pow(x, p);
		}

		private static float spow(float x, float p)
		{
			float num = Mathf.Pow(x, p);
			if (x < 0f)
			{
				return 0f - num;
			}
			return num;
		}

		[HarmonyPatch(typeof(FVRFireArm), "FVRUpdate")]
		[HarmonyPostfix]
		private static void FVRFireArm_FVRUpdate_postfix(FVRFireArm __instance)
		{
			//IL_003d: 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)
			if (!spectator_zoom.Value || !((FVRInteractiveObject)__instance).IsHeld)
			{
				return;
			}
			Transform transform = ((Component)GM.CurrentPlayerBody.FilteredHead).transform;
			Transform currentMuzzle = __instance.CurrentMuzzle;
			if (!__instance.IsLoaded())
			{
				in_radius = false;
				return;
			}
			if (Vector3.Angle(transform.forward, currentMuzzle.forward) < spec_zoom_aim_radius.Value)
			{
				in_radius = true;
			}
			else
			{
				in_radius = false;
			}
			if (!__instance.IsForegripStabilized() && !__instance.IsShoulderStabilized() && !__instance.IsTwoHandStabilized())
			{
				in_radius = false;
			}
		}

		[HarmonyPatch(typeof(FVRSceneSettings), "UpdateSpectatorCamera")]
		[HarmonyPostfix]
		private static void FVRSceneSettings_UpdateSpectatorCamera_postfix(FVRSceneSettings __instance)
		{
			if (spectator_zoom.Value && !((Object)(object)__instance.m_specCam == (Object)null))
			{
				__instance.m_specCam.fieldOfView = (__instance.m_specCam.fieldOfView * 39f + GM.Options.SpectatorCamera.CurrentSettings.CameraFov * 1f) / 40f;
			}
		}

		[HarmonyPatch(typeof(FVRFireArm), "Fire")]
		[HarmonyPrefix]
		private static bool FVRFireArm_Fire_prefix(FVRFireArm __instance, FVRFireArmChamber chamber, Transform muzzle, bool doBuzz, float velMult = 1f, float rangeOverride = -1f)
		{
			//IL_0173: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: 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_01e3: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: 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_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: 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_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: 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_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			if (!aim_assist.Value)
			{
				return true;
			}
			bool flag = false;
			for (int i = 0; i < GM.CurrentMovementManager.Hands.Length; i++)
			{
				if ((Object)(object)((FVRInteractiveObject)__instance).m_hand == (Object)(object)GM.CurrentMovementManager.Hands[i])
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return true;
			}
			bool flag2 = false;
			if (flag2)
			{
				Logger.LogInfo((object)"> BallisticProjectile_Fire_prefix < <");
				timer.Start();
			}
			if (doBuzz && (Object)(object)((FVRInteractiveObject)__instance).m_hand != (Object)null)
			{
				((FVRInteractiveObject)__instance).m_hand.Buzz(((FVRInteractiveObject)__instance).m_hand.Buzzer.Buzz_GunShot);
				if ((Object)(object)((FVRPhysicalObject)__instance).AltGrip != (Object)null && (Object)(object)((FVRInteractiveObject)((FVRPhysicalObject)__instance).AltGrip).m_hand != (Object)null)
				{
					((FVRInteractiveObject)((FVRPhysicalObject)__instance).AltGrip).m_hand.Buzz(((FVRInteractiveObject)__instance).m_hand.Buzzer.Buzz_GunShot);
				}
			}
			if (!((FVRInteractiveObject)__instance).IsHeld && !((FVRPhysicalObject)__instance).IsKinematicLocked && !((FVRPhysicalObject)__instance).IsPivotLocked && (Object)(object)((FVRPhysicalObject)__instance).RootRigidbody != (Object)null)
			{
				((FVRPhysicalObject)__instance).RootRigidbody.AddForceAtPosition(Vector3.Slerp(-muzzle.forward, Random.onUnitSphere, 0.1f) * Random.Range(0.4f, 0.8f), muzzle.position, (ForceMode)2);
			}
			GM.CurrentSceneSettings.OnShotFired(__instance);
			if (__instance.IsSuppressed())
			{
				GM.CurrentPlayerBody.VisibleEvent(0.1f);
			}
			else
			{
				GM.CurrentPlayerBody.VisibleEvent(2f);
			}
			float chamberVelMult = AM.GetChamberVelMult(chamber.RoundType, Vector3.Distance(((Component)chamber).transform.position, muzzle.position));
			float num = __instance.GetCombinedFixedDrop(__instance.AccuracyClass) * 0.0166667f;
			Vector2 val = __instance.GetCombinedFixedDrift(__instance.AccuracyClass) * 0.0166667f;
			float num2 = 5f;
			float num3 = num2;
			SosigLink val2 = null;
			_ = Vector3.zero;
			float num4 = 500f;
			bool flag3 = false;
			int num5 = Physics.OverlapSphereNonAlloc(((Component)__instance).transform.position, num4, collider_array, LayerMask.op_Implicit(AM.PLM), (QueryTriggerInteraction)2);
			if (flag2)
			{
				Logger.LogInfo((object)("Physics.OverlapSphereNonAlloc found " + num5 + " collidable entities within " + num4 + " m."));
				Logger.LogInfo((object)"Now attempting to find closest head to barrel forward vector...");
			}
			if (num5 == 0)
			{
				flag3 = false;
				if (flag2)
				{
					Logger.LogError((object)"no enemies found");
				}
			}
			else
			{
				for (int j = 0; j < num5; j++)
				{
					if (!((Object)(object)collider_array[j].attachedRigidbody != (Object)null))
					{
						continue;
					}
					if (flag2)
					{
						Logger.LogInfo((object)("[" + j + "]: " + ((Object)collider_array[j].attachedRigidbody).name));
					}
					SosigLink component = ((Component)collider_array[j].attachedRigidbody).gameObject.GetComponent<SosigLink>();
					if ((Object)(object)component != (Object)null && (int)component.BodyPart == 0)
					{
						Vector3 val3 = ((Component)component).transform.position - ((Component)__instance).transform.position;
						Vector3 normalized = ((Vector3)(ref val3)).normalized;
						num2 = Vector3.Angle(((Component)__instance).transform.forward, normalized);
						if (num2 < num3)
						{
							val2 = component;
							num3 = num2;
						}
					}
				}
				if ((Object)(object)val2 != (Object)null)
				{
					flag3 = true;
					num4 = Vector3.Distance(((Component)val2).gameObject.transform.position, muzzle.position);
					if (num4 < 5f)
					{
						if (flag2)
						{
							Logger.LogError((object)"no enemies found");
						}
						flag3 = false;
					}
				}
				else
				{
					if (flag2)
					{
						Logger.LogError((object)"no enemies found");
					}
					flag3 = false;
				}
			}
			if (flag2)
			{
				Logger.LogInfo((object)"Proceeding to firing code\t-\t-\t-\t-\t-");
			}
			for (int k = 0; k < chamber.GetRound().NumProjectiles; k++)
			{
				float num6 = chamber.GetRound().ProjectileSpread + __instance.m_internalMechanicalMOA + __instance.GetCombinedMuzzleDeviceAccuracy();
				if (!((Object)(object)chamber.GetRound().BallisticProjectilePrefab != (Object)null))
				{
					continue;
				}
				Vector3 val4 = muzzle.forward * 0.005f;
				GameObject val5 = Object.Instantiate<GameObject>(chamber.GetRound().BallisticProjectilePrefab, muzzle.position - val4, muzzle.rotation);
				Transform transform = val5.transform;
				Vector2 val6 = (Random.insideUnitCircle + Random.insideUnitCircle + Random.insideUnitCircle) * (1f / 3f) * num6;
				Quaternion rotation = muzzle.rotation;
				Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
				if (flag3)
				{
					transform.LookAt(((Component)val2).gameObject.transform.position);
					Quaternion val7 = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);
					Quaternion rotation2 = ((Component)transform).transform.rotation;
					float x = ((Quaternion)(ref rotation2)).eulerAngles.x;
					rotation2 = ((Component)transform).transform.rotation;
					float y = ((Quaternion)(ref rotation2)).eulerAngles.y;
					rotation2 = ((Component)transform).transform.rotation;
					Quaternion val8 = Quaternion.Euler(x, y, ((Quaternion)(ref rotation2)).eulerAngles.z);
					float num7 = 0.1f;
					if (num3 > 3f && num3 < 5f)
					{
						num7 = 0.1f;
					}
					else if (num3 > 2f && num3 < 3f)
					{
						num7 = 0.2f;
					}
					else if (num3 > 1f && num3 < 2f)
					{
						num7 = 0.5f;
					}
					else if ((double)num3 < 1.0)
					{
						num7 = 0.7f;
					}
					num7 *= Mathf.Clamp(Random.Range(aim_assist_amt.Value - 0.1f, aim_assist_amt.Value + 0.1f), 0.1f, 1f);
					if (flag2)
					{
						Logger.LogInfo((object)("aim assist amount = " + (int)(num7 * 100f)));
					}
					Quaternion rotation3 = Quaternion.Lerp(val7, val8, num7);
					val5.transform.rotation = rotation3;
					rotation2 = val5.transform.rotation;
					Vector3 eulerAngles2 = ((Quaternion)(ref rotation2)).eulerAngles;
					rotation2 = muzzle.rotation;
					float num8 = Vector3.Angle(eulerAngles2, ((Quaternion)(ref rotation2)).eulerAngles);
					if (flag2)
					{
						Logger.LogInfo((object)" > Angles adjusted. <");
					}
					if (num8 > 5f)
					{
						if (flag2)
						{
							Logger.LogError((object)"This gun just tried to shoot the ground for some reason.");
						}
						val5.transform.rotation = rotation;
						if (flag2)
						{
							Logger.LogInfo((object)" > Firing bullet normally instead. <");
						}
					}
					val5.transform.Rotate(new Vector3(val6.x + val.y + num, val6.y + val.x, 0f));
				}
				else
				{
					if (flag2)
					{
						Logger.LogInfo((object)" > Firing bullet normally. <");
					}
					val5.transform.Rotate(new Vector3(val6.x + val.y + num, val6.y + val.x, Random.value * 90f));
				}
				BallisticProjectile component2 = val5.GetComponent<BallisticProjectile>();
				component2.Fire(component2.MuzzleVelocityBase * chamber.ChamberVelocityMultiplier * velMult * chamberVelMult, val5.transform.forward, __instance, true);
				if (rangeOverride > 0f)
				{
					component2.ForceSetMaxDist(rangeOverride);
				}
			}
			if (flag2)
			{
				timer.Stop();
				Logger.LogInfo((object)("FVRFireArm_Fire_prefix exec time = " + timer.ElapsedMilliseconds + " ms\n"));
				timer.Reset();
			}
			return false;
		}

		[HarmonyPatch(typeof(BallisticProjectile), "MoveBullet")]
		[HarmonyPrefix]
		private static void BallisticProjectile_MoveBullet_prefix_for_dmg(BallisticProjectile __instance)
		{
			if (__instance.m_distanceTraveled > 0.1f || !__instance.IsMoving() || !(__instance.m_distanceTraveled <= 0.01f))
			{
				return;
			}
			if (__instance.m_hasTracer)
			{
				renderers_array = ((Component)__instance).GetComponentsInChildren<Renderer>();
				for (int i = 0; i < renderers_array.Length; i++)
				{
					if ((Object)(object)renderers_array[i] != (Object)null)
					{
						renderers_array[i].shadowCastingMode = (ShadowCastingMode)0;
						renderers_array[i].receiveShadows = false;
					}
				}
			}
			if (((Object)__instance).name.StartsWith("32FL"))
			{
				__instance.MuzzleVelocityBase = (__instance.MuzzleVelocityBase + 365f) / 2f;
				__instance.Mass = (__instance.Mass + 0.006f) / 2f;
				__instance.FrontArea = (__instance.FrontArea + 6.749E-05f) / 2f;
			}
			if (((Object)__instance).name.EndsWith("JHP(Clone)") || ((Object)__instance).name.EndsWith("SP(Clone)"))
			{
				__instance.AirDragMultiplier *= 1.5f;
			}
			__instance.Mass *= pl_out_dmg_mult.Value;
		}

		[HarmonyPatch(typeof(BallisticProjectile), "UpdateBulletPath")]
		[HarmonyPostfix]
		private static void BallisticProjectile_UpdateBulletPath_postfix(BallisticProjectile __instance)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			if (!em_alert_mod.Value || Time.frameCount % 5 == 0 || __instance.Source_IFF != GM.CurrentPlayerBody.m_playerIFF || !__instance.IsMoving())
			{
				return;
			}
			bool flag = false;
			if (Random.value < 0.5f)
			{
				float num = 2f + __instance.Dimensions.x * 10f + __instance.Mass * 100f + ((Vector3)(ref __instance.m_velocity)).magnitude / 300f;
				int num2 = Physics.OverlapSphereNonAlloc(((Component)__instance).transform.position, num, collider_array, LayerMask.op_Implicit(AM.PLM), (QueryTriggerInteraction)2);
				for (int i = 0; i < num2; i++)
				{
					if ((Object)(object)collider_array[i] != (Object)null && !((Object)(object)collider_array[i].attachedRigidbody == (Object)null) && !(((Object)collider_array[i].attachedRigidbody).name != "Head"))
					{
						SosigLink component = ((Component)collider_array[i].attachedRigidbody).gameObject.GetComponent<SosigLink>();
						if ((Object)(object)component != (Object)null && component.S.m_hasPriority)
						{
							AIEvent val = new AIEvent((((Component)GM.CurrentPlayerBody).transform.position + ((Component)__instance).transform.position) / 2f, (AIEType)3, 1f, 1f);
							component.S.Priority.ProcessEvent(val);
							Sosig s = component.S;
							s.m_aggrolevel += 0.75f;
						}
					}
				}
				flag = true;
			}
			if (Random.value < 0.5f && !flag)
			{
				GM.CurrentSceneSettings.OnPerceiveableSound((__instance.Mass * 1000f + 50f) / 2f, (10f + ((Vector3)(ref __instance.m_velocity)).magnitude / 100f) / 3f, ((Component)__instance).transform.position, GM.CurrentPlayerBody.GetPlayerIFF(), GM.CurrentPlayerBody.PlayerEntities[0]);
			}
		}

		[HarmonyPatch(typeof(BallisticProjectile), "MoveBullet")]
		[HarmonyPrefix]
		private static bool BallisticProjectile_MoveBullet_prefix(BallisticProjectile __instance, float t)
		{
			//IL_009c: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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_026a: 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_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_179d: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Invalid comparison between Unknown and I4
			//IL_0723: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Invalid comparison between Unknown and I4
			//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_095a: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_096a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0971: Invalid comparison between Unknown and I4
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Invalid comparison between Unknown and I4
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097c: Invalid comparison between Unknown and I4
			//IL_0867: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Invalid comparison between Unknown and I4
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Invalid comparison between Unknown and I4
			//IL_0871: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Unknown result type (might be due to invalid IL or missing references)
			//IL_0878: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Invalid comparison between Unknown and I4
			//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_088a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_0676: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07de: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0800: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0817: Expected O, but got Unknown
			//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4d: Invalid comparison between Unknown and I4
			//IL_0cc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cce: Invalid comparison between Unknown and I4
			//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Invalid comparison between Unknown and I4
			//IL_0fa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fac: Unknown result type (might be due to invalid IL or missing references)
			//IL_1122: Unknown result type (might be due to invalid IL or missing references)
			//IL_1127: Unknown result type (might be due to invalid IL or missing references)
			//IL_1129: Unknown result type (might be due to invalid IL or missing references)
			//IL_1130: Unknown result type (might be due to invalid IL or missing references)
			//IL_1135: Unknown result type (might be due to invalid IL or missing references)
			//IL_113a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1143: Unknown result type (might be due to invalid IL or missing references)
			//IL_1148: Unknown result type (might be due to invalid IL or missing references)
			//IL_114a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1152: Unknown result type (might be due to invalid IL or missing references)
			//IL_1157: Unknown result type (might be due to invalid IL or missing references)
			//IL_115c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1172: Unknown result type (might be due to invalid IL or missing references)
			//IL_1177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fcd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ffd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1002: Unknown result type (might be due to invalid IL or missing references)
			//IL_1004: Unknown result type (might be due to invalid IL or missing references)
			//IL_100c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1011: Unknown result type (might be due to invalid IL or missing references)
			//IL_1016: Unknown result type (might be due to invalid IL or missing references)
			//IL_102c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1031: Unknown result type (might be due to invalid IL or missing references)
			//IL_1033: Unknown result type (might be due to invalid IL or missing references)
			//IL_1035: Unknown result type (might be due to invalid IL or missing references)
			//IL_1204: Unknown result type (might be due to invalid IL or missing references)
			//IL_10a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_10bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_10c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_10df: Unknown result type (might be due to invalid IL or missing references)
			//IL_1227: Unknown result type (might be due to invalid IL or missing references)
			//IL_1229: Unknown result type (might be due to invalid IL or missing references)
			//IL_121a: Unknown result type (might be due to invalid IL or missing references)
			//IL_121c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1221: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1102: Unknown result type (might be due to invalid IL or missing references)
			//IL_124f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1254: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1110: Unknown result type (might be due to invalid IL or missing references)
			//IL_1115: Unknown result type (might be due to invalid IL or missing references)
			//IL_125f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1266: Invalid comparison between Unknown and I4
			//IL_12c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_12cd: Invalid comparison between Unknown and I4
			//IL_12af: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d8: Invalid comparison between Unknown and I4
			//IL_12ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_1306: Expected O, but got Unknown
			//IL_1309: Unknown result type (might be due to invalid IL or missing references)
			//IL_163a: Unknown result type (might be due to invalid IL or missing references)
			//IL_163f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1642: Unknown result type (might be due to invalid IL or missing references)
			//IL_1648: Invalid comparison between Unknown and I4
			//IL_131f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1324: Unknown result type (might be due to invalid IL or missing references)
			//IL_1326: Unknown result type (might be due to invalid IL or missing references)
			//IL_133d: Expected I4, but got Unknown
			//IL_1652: Unknown result type (might be due to invalid IL or missing references)
			//IL_1657: Unknown result type (might be due to invalid IL or missing references)
			//IL_164b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1650: Unknown result type (might be due to invalid IL or missing references)
			//IL_161a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1622: Unknown result type (might be due to invalid IL or missing references)
			//IL_162d: Unknown result type (might be due to invalid IL or missing references)
			//IL_15ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_1600: Unknown result type (might be due to invalid IL or missing references)
			//IL_160b: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_13fe: Expected I4, but got Unknown
			//IL_1689: Unknown result type (might be due to invalid IL or missing references)
			//IL_168e: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_16af: Unknown result type (might be due to invalid IL or missing references)
			//IL_16b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_16c7: Expected I4, but got Unknown
			//IL_1588: Unknown result type (might be due to invalid IL or missing references)
			//IL_158d: Unknown result type (might be due to invalid IL or missing references)
			//IL_159a: Unknown result type (might be due to invalid IL or missing references)
			//IL_159f: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1765: Unknown result type (might be due to invalid IL or missing references)
			//IL_1767: Unknown result type (might be due to invalid IL or missing references)
			//IL_176e: Unknown result type (might be due to invalid IL or missing references)
			//IL_174a: Unknown result type (might be due to invalid IL or missing references)
			//IL_174c: Unknown result type (might be due to invalid IL or missing references)
			//IL_16e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_16f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_16f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_16fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_170b: Expected I4, but got Unknown
			//IL_1713: Unknown result type (might be due to invalid IL or missing references)
			//IL_1718: Unknown result type (might be due to invalid IL or missing references)
			//IL_1719: Unknown result type (might be due to invalid IL or missing references)
			//IL_171e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1721: Unknown result type (might be due to invalid IL or missing references)
			//IL_1729: Unknown result type (might be due to invalid IL or missing references)
			//IL_1736: Expected I4, but got Unknown
			if (__instance.Source_IFF != GM.CurrentPlayerBody.m_playerIFF)
			{
				return true;
			}
			__instance.movesThisFrame++;
			if (__instance.movesThisFrame > 2)
			{
				return false;
			}
			if (__instance.m_velocity.y < 0f && __instance.DeletesOnStraightDown)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(__instance.m_velocity.x, 0f, __instance.m_velocity.z);
				if (((Vector3)(ref val)).magnitude < 0.1f && ((Component)__instance).transform.position.y < GM.CurrentSceneSettings.CatchHeight)
				{
					goto IL_17b0;
				}
			}
			if (((Component)__instance).transform.position.y >= -350f)
			{
				Vector3 val2 = ((Component)__instance).transform.position;
				if (__instance.m_isInReferenceTransform && (Object)(object)__instance.m_transReference != (Object)null)
				{
					val2 = __instance.m_transReference.TransformPoint(__instance.m_localReferencePoint);
				}
				__instance.m_isInReferenceTransform = false;
				__instance.m_transReference = null;
				Vector3 normalized = ((Vector3)(ref __instance.m_velocity)).normalized;
				float magnitude = ((Vector3)(ref __instance.m_velocity)).magnitude;
				float num = magnitude * t * __instance.FlightVelocityMultiplier * __instance.m_debugFlightVelGlobal;
				if (__instance.needsSecondCast)
				{
					num = Mathf.Clamp(num - __instance.distMoved, 0f, num);
				}
				__instance.needsSecondCast = false;
				if (!Physics.Raycast(val2, normalized, ref __instance.m_hit, num, LayerMask.op_Implicit(__instance.LM), (QueryTriggerInteraction)2))
				{
					((Component)__instance).transform.position = val2 + __instance.m_velocity * t * __instance.FlightVelocityMultiplier * __instance.m_debugFlightVelGlobal;
					if (!__instance.m_hasPlayedWhoosh && __instance.Source_IFF != GM.CurrentPlayerBody.GetPlayerIFF())
					{
						Vector3 closestValidPoint = __instance.GetClosestValidPoint(val2, ((Component)__instance).transform.position, __instance.m_cachedHead.position);
						float num2 = Vector3.Distance(closestValidPoint, __instance.m_cachedHead.position);
						if (num2 < 3f)
						{
							float num3 = Mathf.Lerp(1f, 0.2f, Mathf.Clamp(num2 - 1f, 0f, 2f) * 0.5f);
							Vector3 val3 = __instance.m_cachedHead.position - val2;
							if (Vector3.Dot(((Vector3)(ref val3)).normalized, normalized) > 0f)
							{
								__instance.m_hasPlayedWhoosh = true;
								SM.PlayBulletImpactHit((BulletImpactSoundType)28, closestValidPoint, num3, 1f);
							}
						}
					}
					if (!(((Vector3)(ref __instance.m_velocity)).normalized != Vector3.zero))
					{
					}
				}
				else
				{
					__instance.m_isTumbling = true;
					if ((Object)(object)__instance.m_lastColliderHit != (Object)null && (Object)(object)((RaycastHit)(ref __instance.m_hit)).collider == (Object)(object)__instance.m_lastColliderHit)
					{
						__instance.needsSecondCast = true;
						__instance.distMoved = ((RaycastHit)(ref __instance.m_hit)).distance;
						((Component)__instance).transform.position = ((RaycastHit)(ref __instance.m_hit)).point - ((RaycastHit)(ref __instance.m_hit)).normal * 0.001f;
						if (log_bullet_events)
						{
							Logger.LogDebug((object)"MoveBullet will now call itself.");
						}
						__instance.MoveBullet(t);
						return false;
					}
					bool flag = false;
					if ((Object)(object)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody != (Object)null)
					{
						flag = true;
					}
					__instance.m_lastColliderHit = ((RaycastHit)(ref __instance.m_hit)).collider;
					if (log_bullet_events)
					{
						Logger.LogWarning((object)Time.frameCount);
						Logger.LogDebug((object)("bullet hit " + ((object)((RaycastHit)(ref __instance.m_hit)).collider)?.ToString() + ", attachedRigidbody = " + ((Object)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).name));
					}
					bool flag2 = false;
					IFVRDamageable component = ((Component)((Component)((RaycastHit)(ref __instance.m_hit)).collider).transform).gameObject.GetComponent<IFVRDamageable>();
					if (component == null && flag)
					{
						component = ((Component)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).gameObject.GetComponent<IFVRDamageable>();
					}
					if (component != null)
					{
						flag2 = true;
					}
					if (__instance.DoesIgniteOnHit && Random.Range(0f, 1f) < __instance.IgnitionChance)
					{
						FVRIgnitable component2 = ((Component)((Component)((RaycastHit)(ref __instance.m_hit)).collider).transform).gameObject.GetComponent<FVRIgnitable>();
						if ((Object)(object)component2 != (Object)null)
						{
							FXM.Ignite(component2, 1f);
						}
						else if (flag)
						{
							component2 = ((Component)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).GetComponent<FVRIgnitable>();
							if ((Object)(object)component2 != (Object)null)
							{
								FXM.Ignite(component2, 1f);
							}
						}
					}
					if (flag && __instance.DoesVaporizeOnHit && Random.Range(0f, 1f) < __instance.VaporizeChange)
					{
						IVaporizable component3 = ((Component)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).gameObject.GetComponent<IVaporizable>();
						if (component3 != null)
						{
							component3.Vaporize(__instance.Source_IFF);
						}
					}
					bool flag3 = false;
					PMat component4 = ((Component)((Component)((RaycastHit)(ref __instance.m_hit)).collider).transform).gameObject.GetComponent<PMat>();
					if ((Object)(object)component4 == (Object)null && flag)
					{
						component4 = ((Component)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).gameObject.GetComponent<PMat>();
					}
					if ((Object)(object)component4 != (Object)null && (Object)(object)component4.MatDef != (Object)null)
					{
						flag3 = true;
					}
					Rigidbody val4 = null;
					bool flag4 = false;
					if (flag)
					{
						val4 = ((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody;
						flag4 = true;
						__instance.m_isInReferenceTransform = true;
						__instance.m_transReference = ((Component)((RaycastHit)(ref __instance.m_hit)).collider.attachedRigidbody).gameObject.transform;
					}
					MatDef val5 = (flag3 ? component4.MatDef : PM.DefaultMatDef);
					if (__instance.GeneratesImpactSound && (int)GM.Options.SimulationOptions.HitSoundMode2 == 1)
					{
						float num4 = 0.8f;
						float num5 = 1f;
						if ((int)__instance.ImpactFXMagnitude == 4 || (int)__instance.ImpactFXMagnitude == 1)
						{
							num5 = 0.4f;
							num4 = 1.3f;
						}
						else if ((int)__instance.ImpactFXMagnitude == 2)
						{
							num5 = 0.7f;
							num4 = 1f;
						}
						num5 *= Mathf.InverseLerp(0f, __instance.m_initialMuzzleVelocity, magnitude);
						SM.PlayBulletImpactHit(val5.BulletImpactSound, ((RaycastHit)(ref __instance.m_hit)).point, 25f, num5, num4);
						if (hit_sound.Value && (int)val5.BulletImpactSound == 13 && Vector3.Distance(((RaycastHit)(ref __instance.m_hit)).point, GM.CurrentPlayerBody.Head.position) >= 5f)
						{
							SM.PlayBulletImpactHit(val5.BulletImpactSound, GM.CurrentPlayerBody.Head.position + GM.CurrentPlayerBody.Head.forward * 1f, 10f, Random.Range(0.4f, 0.7f) * hit_sound_vol.Value, 2f - (__instance.Dimensions.x + __instance.Dimensions.z + __instance.Mass * 5f));
						}
					}
					if (em_alert_mod.Value)
					{
						float num6 = 5f + (__instance.Dimensions.x * 10f + __instance.Mass * 100f);
						int num7 = Physics.OverlapSphereNonAlloc(((Component)__instance).transform.position, num6, collider_array, LayerMask.op_Implicit(AM.PLM), (QueryTriggerInteraction)2);
						for (int i = 0; i < num7; i++)
						{
							if ((Object)(object)collider_array[i] != (Object)null && !((Object)(object)collider_array[i].attachedRigidbody == (Object)null) && !(((Object)collider_array[i].attachedRigidbody).name != "Head"))
							{
								SosigLink component5 = ((Component)collider_array[i].attachedRigidbody).gameObject.GetComponent<SosigLink>();
								if ((Object)(object)component5 != (Object)null && component5.S.m_hasPriority)
								{
									_ = (((Component)GM.CurrentPlayerBody).transform.position + ((Component)__instance).transform.position) / 2f;
									AIEvent val6 = new AIEvent(((Component)collider_array[i]).transform.position, (AIEType)3, 1f, 1f);
									component5.S.Priority.ProcessEvent(val6);
									Sosig s = component5.S;
									s.m_aggrolevel += 0.5f;
								}
							}
						}
					}
					if (!flag && __instance.GeneratesImpactDecals && (int)GM.Options.SimulationOptions.HitDecalMode2 == 1)
					{
						BulletHoleDecalType val7 = val5.BulletHoleType;
						if ((int)val7 != 0 && (int)__instance.BulletHoleDecalOverride != 0)
						{
							val7 = __instance.BulletHoleDecalOverride;
						}
						float num8 = Mathf.Clamp(__instance.Dimensions.x, 0.0001f, 0.02f);
						if ((int)val7 != 0)
						{
							FXM.SpawnBulletDecal(val7, ((RaycastHit)(ref __instance.m_hit)).point, ((RaycastHit)(ref __instance.m_hit)).normal, num8);
						}
					}
					BallisticMatSeries matSeries = PM.GetMatSeries(val5.BallisticType, __instance.ProjType);
					float ricochetLimit = matSeries.RicochetLimit;
					float num9 = Vector3.Angle(normalized, -((RaycastHit)(ref __instance.m_hit)).normal);
					bool flag5 = false;
					bool flag6 = false;
					bool flag7 = false;
					bool flag8 = false;
					float num10 = 0.5f * __instance.Mass * Mathf.Pow(magnitude, 2f) / __instance.FrontArea * 0.01f / 140f;
					float num11 = 0.5f * __instance.Mass * Mathf.Pow(magnitude, 2f);
					float num12 = 0f;
					Vector3 val8 = normalized;
					Vector3 velocity = __instance.m_velocity;
					bool flag9 = false;
					if (((int)matSeries.MaterialType == 110 || (int)matSeries.MaterialType == 61) && flag4)
					{
						flag9 = true;
					}
					if (num9 >= ricochetLimit)
					{
						flag5 = true;
					}
					float num13 = 1f - num9 / 90f;
					num13 = Mathf.Max(num13, matSeries.MinAngularAbsord);
					float num14 = Mathf.Lerp(0f, matSeries.Absorption, num13);
					float num15 = num10 * num13;
					bool flag10 = false;
					float num16 = 1f;
					if (flag9 && bullet_pen_mod.Value)
					{
						if (log_bullet_events)
						{
							Logger.LogDebug((object)("matSeries.PenThreshold = " + matSeries.PenThreshold + ", pressure2_num11 = " + num15));
						}
						if (num15 < matSeries.PenThreshold)
						{
							if (log_bullet_events)
							{
								Logger.LogWarning((object)"> This bullet could not normally penetrate armor.\t<\t<");
							}
							flag10 = true;
							if ((int)matSeries.MaterialType == 110)
							{
								Logger.LogInfo((object)(((Object)__instance).name + " " + ((Object)__instance).GetInstanceID() + " hit Lv 1 armor"));
								impact_frame = Time.frameCount;
								armor_lv = 1;
							}
							else if ((int)matSeries.MaterialType == 61)
							{
								Logger.LogInfo((object)(((Object)__instance).name + " " + ((Object)__instance).GetInstanceID() + " hit Lv 2 armor"));
								impact_frame = Time.frameCount;
								armor_lv = 2;
							}
							else
							{
								Logger.LogDebug((object)"???");
								impact_frame = Time.frameCount - 100;
								armor_lv = 0;
							}
							if (((Object)__instance).name.EndsWith("JHP(Clone)") || ((Object)__instance).name.EndsWith("SP(Clone)"))
							{
								if (log_bullet_events)
								{
									if (((Object)__instance).name.EndsWith("JHP(Clone)"))
									{
										Logger.LogWarning((object)(((Object)__instance).name + " " + ((Object)__instance).GetInstanceID() + " is a hollow-point, penetration reduced."));
									}
									if (((Object)__instance).name.EndsWith("SP(Clone)"))
									{
										Logger.LogWarning((object)(((Object)__instance).name + " " + ((Object)__instance).GetInstanceID() + " is a soft-point, which is not only toxic and harmful to the environment because it's exposed lead, but it's banned under the Hague conventions.\nAlso, penetration reduced."));
									}
								}
								if (flag10)
								{
									num16 = 0.6f;
									flat_bullet = true;
								}
							}
							else
							{
								flat_bullet = false;
								if (flag10)
								{
									if (log_bullet_events)
									{
										Logger.LogDebug((object)"edit_penetration == true");
									}
									if (armor_lv == 1)
									{
										num16 = 0.1f;
										was_this_bullet_able_to_pierce_armor_normally = false;
										if (log_bullet_events)
										{
											Logger.LogInfo((object)("armor_lv = 1, penmod = " + num16 + " was_this_bullet_able_to_pierce_armor_normally = false"));
										}
									}
									else if (armor_lv == 2)
									{
										num16 = 0.1f;
										was_this_bullet_able_to_pierce_armor_normally = false;
										if (log_bullet_events)
										{
											Logger.LogInfo((object)("armor_lv = 2, penmod = " + num16 + " was_this_bullet_able_to_pierce_armor_normally = false"));
										}
									}
								}
							}
						}
					}
					else if (log_bullet_events)
					{
						Logger.LogDebug((object)"hit_armor == true; bullet_pen_mod == true; was_this_bullet_able_to_pierce_armor_normally set to true");
					}
					if (!bullet_pen_mod.Value || !flag10)
					{
						num16 = 1f;
					}
					if (log_bullet_events && flag9)
					{
						Logger.LogDebug((object)("was_this_bullet_able_to_pierce_armor_normally = " + was_this_bullet_able_to_pierce_armor_normally));
					}
					if (log_bullet_events && ((int)matSeries.MaterialType == 50 || flag9))
					{
						Logger.LogDebug((object)("matSeries.MinAngularAbsord = " + matSeries.MinAngularAbsord + ", Absorption = " + matSeries.Absorption + ", Roughness = " + matSeries.Roughness));
						Logger.LogDebug((object)("impact_aspect = " + num13 + " (after limiting),\n\tabsorption = " + num14 + ",\n\tpressure2 = " + num10 + " * " + num13 + " = " + num15));
						Logger.LogDebug((object)("penmod = " + num16));
					}
					float num18;
					float num19;
					if (num15 > matSeries.PenThreshold * num16 && !__instance.IsDisabledOnFirstImpact)
					{
						flag6 = true;
						float num17 = Mathf.Clamp(matSeries.PenThreshold * num16 / num15 + num14, 0f, 1f);
						num12 = num17 * num11;
						num18 = num11 - num12;
						num19 = num17 * num10;
						if (flag9 && log_bullet_events)
						{
							Logger.LogWarning((object)"> bullet penetrated armor <");
							Logger.LogDebug((object)("impact_force_num8 = " + num12 + ", \n\tpiercing_amount = " + num17 + ", \n\tKE after penetration = " + num18 + ", \n\tpiercing damage = " + num19 + " <"));
						}
					}
					else if (num12 > matSeries.ShatterThreshold || __instance.IsDisabledOnFirstImpact)
					{
						flag7 = true;
						num12 = num11;
						num18 = 0f;
						num19 = num10;
						if (flag9 && log_bullet_events)
						{
							Logger.LogDebug((object)"bullet shattered?");
						}
					}
					else
					{
						num12 = num11 * num13;
						num18 = num11 - num12;
						num19 = num10 * num13;
						flag5 = true;
						float num20 = Mathf.Clamp(num12 / num11 + num14, 0f, 1f);
						num12 = num20 * num11;
						num18 = num11 - num12;
						num19 = num10 * num20;
						if (flag9 && log_bullet_events)
						{
							Logger.LogDebug((object)("bullet failed to pierce armor?\n\tKE after impact = " + num18 + "\n\tpiercing_damage_num14 = " + num10 + " * " + num20 + " = " + num18));
						}
					}
					if (__instance.m_usesSubmunitions)
					{
						flag7 = true;
						flag8 = true;
					}
					Vector3 val9 = val8;
					Vector3 onUnitSphere = Random.onUnitSphere;
					Vector3 val10;
					if (flag5 && !flag7)
					{
						val10 = ((RaycastHit)(ref __instance.m_hit)).point + ((RaycastHit)(ref __instance.m_hit)).normal * 0.001f;
						val8 = Vector3.Lerp(Vector3.Reflect(normalized, ((RaycastHit)(ref __instance.m_hit)).normal), onUnitSphere, matSeries.Roughness);
						val8 = Vector3.Lerp(Vector3.ProjectOnPlane(val8, ((RaycastHit)(ref __instance.m_hit)).normal), val8, Mathf.Clamp(num13 * num13, 0.1f, 1f));
						val9 = val8;
						if (flag9 && log_bullet_events)
						{
							Logger.LogDebug((object)("bullet bounced off " + ((object)Unsafe.As<MatBallisticType, MatBallisticType>(ref matSeries.MaterialType)/*cast due to .constrained prefix*/).ToString()));
						}
					}
					else if (flag6 && !flag7)
					{
						if (matSeries.StopsOnPen)
						{
							num12 = num11;
							num18 = 0f;
							num19 = num10;
							flag8 = true;
						}
						val10 = ((RaycastHit)(ref __instance.m_hit)).point - ((RaycastHit)(ref __instance.m_hit)).normal * 0.001f;
						val8 = Vector3.Lerp(normalized, onUnitSphere, matSeries.Roughness * num13);
						if (Vector3.Angle(val8, ((RaycastHit)(ref __instance.m_hit)).normal) < 90f)
						{
							val8 = Vector3.Reflect(val8, ((RaycastHit)(ref __instance.m_hit)).normal);
						}
						if (matSeries.DownGradesOnPen)
						{
							__instance.ProjType = matSeries.DownGradesTo;
						}
					}
					else
					{
						val10 = ((RaycastHit)(ref __instance.m_hit)).point;
						val9 = Vector3.Lerp(Vector3.Reflect(normalized, ((RaycastHit)(ref __instance.m_hit)).normal), onUnitSphere, matSeries.Roughness);
						val9 = Vector3.Lerp(Vector3.ProjectOnPlane(val8, ((RaycastHit)(ref __instance.m_hit)).normal), val8, Mathf.Clamp(num13 * num13, 0.1f, 1f));
					}
					float num21 = 0f;
					if (!flag8 && !flag7 && num18 > 0f)
					{
						num21 = Mathf.Sqrt(2f * num18) / Mathf.Sqrt(__instance.Mass);
						velocity = val8 * num21;
						if (flag9 && log_bullet_events)
						{
							Logger.LogDebug((object)("V was " + ((Vector3)(ref velocity)).magnitude + ", is now " + ((Vector3)(ref val8)).magnitude * num21));
						}
					}
					((Component)__instance).transform.position = val10;
					if (__instance.m_isInReferenceTransform)
					{
						__instance.m_localReferencePoint = __instance.m_transReference.InverseTransformPoint(val10);
					}
					__instance.m_velocity = velocity;
					if (flag8 || flag7 || num21 <= 0f || num18 <= 0f)
					{
						__instance.m_isMoving = false;
						__instance.m_velocity = Vector3.zero;
						if ((flag9 || (int)matSeries.MaterialType == 51) && log_bullet_events)
						{
							Logger.LogDebug((object)("bullet stopped in " + ((object)Unsafe.As<MatBallisticType, MatBallisticType>(ref matSeries.MaterialType)/*cast due to .constrained prefix*/).ToString()));
						}
						if ((Object)(object)__instance.Trail != (Object)null)
						{
							__instance.Trail.AddPosition(((Component)__instance).transform.position);
						}
					}
					float num22 = num12;
					float num23 = 0f;
					if ((int)matSeries.MaterialType == 51 || (int)matSeries.MaterialType == 50)
					{
						num23 = Mathf.Clamp(num18, 0f, matSeries.PenThreshold * 2f * num13);
					}
					if (flag2)
					{
						Damage val11 = new Damage();
						val11.Class = (DamageClass)1;
						val11.Dam_TotalKinetic = num12;
						if (flag6)
						{
							BallisticProjectileType projType = __instance.ProjType;
							switch ((int)projType)
							{
							case 0:
								val11.Dam_Piercing = num19 * 0.3f;
								val11.Dam_Blunt = num12 * 0.7f;
								break;
							case 1:
								val11.Dam_Piercing = num19 * 0.5f;
								val11.Dam_Blunt = num12 * 0.5f;
								break;
							case 2:
								val11.Dam_Piercing = num19 * 0.7f;
								val11.Dam_Blunt = num12 * 0.3f;
								break;
							case 3:
								val11.Dam_Piercing = num19 * 0.9f;
								val11.Dam_Blunt = num12 * 0.1f;
								break;
							}
							val11.Dam_Piercing += num23 * 1f;
						}
						else if (flag7)
						{
							BallisticProjectileType projType = __instance.ProjType;
							switch ((int)projType)
							{
							case 0:
								val11.Dam_Piercing = num19 * 0.1f;
								val11.Dam_Blunt = num12 * 0.9f;
								break;
							case 1:
								val11.Dam_Piercing = num19 * 0.3f;
								val11.Dam_Blunt = num12 * 0.7f;
								break;
							case 2:
								val11.Dam_Piercing = num19 * 0.4f;
								val11.Dam_Blunt = num12 * 0.6f;
								break;
							case 3:
								val11.Dam_Piercing = num19 * 0.5f;
								val11.Dam_Blunt = num12 * 0.5f;
								break;
							}
						}
						else if (flag5)
						{
							val11.Dam_Blunt = num12;
						}
						if (__instance.DoesIgniteOnHit)
						{
							val11.Dam_Thermal = 50f;
						}
						if (__instance.Source_IFF == GM.CurrentPlayerBody.GetPlayerIFF() && (GM.CurrentPlayerBody.isDamPowerUp || GM.CurrentPlayerBody.IsDamPowerDown))
						{
							float damageMult = GM.CurrentPlayerBody.GetDamageMult();
							val11.Dam_Piercing *= damageMult;
							val11.Dam_Blunt *= damageMult;
							val11.Dam_Cutting *= damageMult;
							val11.Dam_TotalKinetic *= damageMult;
							val11.Dam_Blinding *= damageMult;
							val11.Dam_Chilling *= damageMult;
							val11.Dam_EMP *= damageMult;
							val11.Dam_Stunning *= damageMult;
							val11.Dam_Thermal *= damageMult;
							val11.Dam_TotalEnergetic *= damageMult;
						}
						val11.point = ((RaycastHit)(ref __instance.m_hit)).point;
						val11.hitNormal = ((RaycastHit)(ref __instance.m_hit)).normal;
						val11.strikeDir = normalized;
						val11.damageSize = __instance.Dimensions.x;
						val11.Source_IFF = __instance.Source_IFF;
						num22 = val11.Dam_Blunt;
						component.Damage(val11);
					}
					if (flag4)
					{
						if (bullet_pen_mod.Value)
						{
							val4.AddForceAtPosition(normalized * Mathf.Sqrt(num22 * (num11 / 500f)), ((RaycastHit)(ref __instance.m_hit)).point, (ForceMode)0);
						}
						else
						{
							val4.AddForceAtPosition(normalized * Mathf.Sqrt(num22), ((RaycastHit)(ref __instance.m_hit)).point, (ForceMode)0);
						}
					}
					BallisticImpactEffectType val12 = val5.ImpactEffectType;
					if ((int)__instance.ImpactEffectTypeOverride != -1)
					{
						val12 = __instance.ImpactEffectTypeOverride;
					}
					Color val13 = Color.white;
					bool flag11 = false;
					if (GM.Options.SimulationOptions.TracerColorOverride > 0 && __instance.m_hasTracer)
					{
						flag11 = true;
						val13 = __instance.TracerRenderer.sharedMaterial.GetColor("_Color");
					}
					if (flag7 || flag5)
					{
						if (magnitude > 100f)
						{
							FXM.SpawnImpactEffect(((RaycastHit)(ref __instance.m_hit)).point, val9, (int)val12, __instance.ImpactFXMagnitude, false, flag11, val13, __instance.OverrideImpactMat);
						}
					}
					else if (flag6 && magnitude > 100f)
					{
						if (flag8 || num21 == 0f)
						{
							FXM.SpawnImpactEffect(((RaycastHit)(ref __instance.m_hit)).point, -normalized, (int)val12, __instance.ImpactFXMagnitude, false, flag11, val13, __instance.OverrideImpactMat);
						}
						else
						{
							FXM.SpawnImpactEffect(((RaycastHit)(ref __instance.m_hit)).point, -normalized, (int)val12, __instance.ImpactFXMagnitude, true, flag11, val13, __instance.OverrideImpactMat);
						}
					}
					if (__instance.GeneratesSuppressionEvent)
					{
						__instance.GeneratesSuppressionEvent = false;
						GM.CurrentSceneSettings.OnSuppressingEvent(val10, normalized, __instance.Source_IFF, __instance.SuppressionIntensity, __instance.SuppressionRange);
					}
					__instance.FireSubmunitions(val9, normalized, ((RaycastHit)(ref __instance.m_hit)).point, ((Vector3)(ref __instance.m_velocity)).magnitude);
					__instance.m_stallFrames = Random.Range(0, 3);
				}
				__instance.m_distanceTraveled += Vector3.Distance(((Component)__instance).transform.position, val2);
				return false;
			}
			goto IL_17b0;
			IL_17b0:
			__instance.m_isMoving = false;
			return false;
		}

		[HarmonyPatch(typeof(SosigLink), "Damage")]
		[HarmonyPrefix]
		private static bool SosigLink_Damage_prefix(SosigLink __instance, Damage d)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_093e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0944: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Expected O, but got Unknown
			//IL_0cef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf5: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			if ((int)d.Class == 1 && d.Source_IFF == GM.CurrentPlayerBody.m_playerIFF)
			{
				flag = true;
				if (log_bullet_events)
				{
					Logger.LogDebug((object)("Time.frameCount - impact_frame = " + (Time.frameCount - impact_frame)));
					ManualLogSource logger = Logger;
					int num = armor_lv;
					logger.LogDebug((object)("armor_lv = " + num));
				}
				if (Time.frameCount - impact_frame < 5 && armor_lv != 0 && bullet_pen_mod.Value)
				{
					if (was_this_bullet_able_to_pierce_armor_normally)
					{
						if (log_bullet_events)
						{
							Logger.LogWarning((object)"was_this_bullet_able_to_pierce_armor_normally == true; skipping damage edits.");
						}
					}
					else
					{
						flag2 = true;
						if (log_bullet_events)
						{
							Logger.LogWarning((object)"Damage override = true\t<\t<");
							Logger.LogDebug((object)("Time.frameCount - impact_frame = " + (Time.frameCount - impact_frame)));
							Logger.LogDebug((object)("was_this_bullet_able_to_pierce_armor_normally = " + was_this_bullet_able_to_pierce_armor_normally));
						}
						if (armor_lv == 1)
						{
							if (log_bullet_events)
							{
								Logger.LogDebug((object)"Attempting to edit damage params (lv1)...");
							}
							if (d.Dam_Blunt > 200f)
							{
								if (log_bullet_events)
								{
									Logger.LogDebug((object)("d.Dam_Blunt was " + d.Dam_Blunt + ", is now " + (d.Dam_Blunt + 200f) / 2f));
								}
								d.Dam_Blunt = (d.Dam_Blunt + 200f) / 2f;
							}
							if (d.Dam_Blunt > 300f)
							{
								if (log_bullet_events)
								{
									Logger.LogDebug((object)"d.Dam_Blunt limited to 300");
								}
								d.Dam_Blunt = 300f;
							}
							if (flat_bullet)
							{
								if (d.Dam_Blunt > 100f)
								{
									if (log_bullet_events)
									{
										Logger.LogDebug((object)("(flat bullet) d.Dam_Blunt was " + d.Dam_Blunt + ", is now " + (d.Dam_Blunt + 100f) / 2f));
									}
									d.Dam_Blunt = (d.Dam_Blunt + 100f) / 2f;
								}
								if (d.Dam_Blunt > 200f)
								{
									if (log_bullet_events)
									{
										Logger.LogDebug((object)"(flat bullet) d.Dam_Blunt limited to 200");
									}
									d.Dam_Blunt = 200f;
								}
							}
							if (log_bullet_events)
							{
								Logger.LogDebug((object)("d.Dam_Piercing was " + d.Dam_Piercing + ", is now " + (d.Dam_Piercing + d.Dam_Blunt / 100f) / 2f));
							}
							d.Dam_Piercing = (d.Dam_Piercing + d.Dam_Blunt / 100f) / 2f;
						}
						if (armor_lv == 2)
						{
							if (log_bullet_events)
							{
								Logger.LogDebug((object)"Attempting to edit damage params (lv2)...");
							}
							if (d.Dam_Blunt > 200f)
							{
								if (log_bullet_events)
								{
									Logger.LogDebug((object)("d.Dam_Blunt was " + d.Dam_Blunt + ", is now " + (d.Dam_Blunt + 200f) / 3f));
								}
								d.Dam_Blunt = (d.Dam_Blunt + 200f) / 3f;
							}
							if (log_bullet_events)
							{
								Logger.LogDebug((object)("d.Dam_Piercing was " + d.Dam_Piercing + ", is now " + (d.Dam_Piercing + d.Dam_Blunt / 200f) / 2f));
							}
							d.Dam_Piercing = (d.Dam_Piercing + d.Dam_Blunt / 200f) / 2f;
							if (d.Dam_Blunt > 100f)
							{
								if (log_bullet_events)
								{
									Logger.LogDebug((object)"d.Dam_Blunt limited to 100");
								}
								d.Dam_Blunt = 100f;
							}
							if (flat_bullet)
							{
								if (d.Dam_Blunt > 50f)
								{
									if (log_bullet_events)
									{
										Logger.LogDebug((object)("(flat bullet) d.Dam_Blunt was " + d.Dam_Blunt + ", is now " + (d.Dam_Blunt + 50f + 50f) / 3f));
									}
									d.Dam_Blunt = (d.Dam_Blunt + 50f + 50f) / 3f;
								}
								if (d.Dam_Blunt > 100f)
								{
									if (log_bullet_events)
									{
										Logger.LogDebug((object)"(flat bullet) d.Dam_Blunt limited to 100");
									}
									d.Dam_Blunt = 100f;
								}
							}
						}
					}
				}
				float num2 = Vector3.Angle(d.strikeDir, -d.hitNormal);
				float num3 = Mathf.Clamp((1f - num2 / 90f) * 1.5f, 0.4f, 1.5f);
				if (flag && bullet_pen_mod.Value)
				{
					num3 *= pl_out_dmg_mult.Value;
					if (num3 > 1.5f)
					{
						num3 = 1.5f;
					}
					if (num3 < 0.3f)
					{
						num3 = 0.3f;
					}
				}
				d.Dam_Blunt *= num3;
				d.Dam_Cutting *= num3;
				d.Dam_Piercing *= num3;
				d.Dam_TotalKinetic *= num3;
				if (__instance.S.IsFrozen)
				{
					d.Dam_Blunt *= 3f;
					d.Dam_Cutting *= 0.2f;
					d.Dam_Piercing *= 0.02f;
				}
				if ((Object)(object)__instance.S != (Object)null)
				{
					if (flag && em_alert_mod.Value)
					{
						AIEvent val = new AIEvent(GM.CurrentPlayerBody.PlayerEntities[0], (AIEType)3, 10f, 0.1f);
						__instance.S.Priority.ProcessEvent(val);
						Sosig s = __instance.S;
						s.m_aggrolevel += 1f;
					}
					if (__instance.S.IsInvuln)
					{
						return true;
					}
					float num4 = 1f;
					if (__instance.S.IsDamResist || __instance.S.IsDamMult)
					{
						num4 = __instance.S.BuffIntensity_DamResistHarm;
					}
					if (__instance.S.IsFragile)
					{
						num4 *= 100f;
					}
					d.Dam_Blunt *= num4;
					d.Dam_Cutting *= num4;
					d.Dam_Piercing *= num4;
					d.Dam_TotalKinetic *= num4;
					d.Dam_Thermal *= num4;
					d.Dam_Chilling *= num4;
					d.Dam_EMP *= num4;
					d.Dam_Blunt *= __instance.S.DamMult_Projectile;
					d.Dam_Cutting *= __instance.S.DamMult_Projectile;
					d.Dam_Piercing *= __instance.S.DamMult_Projectile;
					d.Dam_TotalKinetic *= __instance.S.DamMult_Projectile;
				}
				d.Dam_Thermal *= __instance.S.DamMult_Thermal;
				d.Dam_Chilling *= __instance.S.DamMult_Chilling;
				d.Dam_EMP *= __instance.S.DamMult_EMP;
				__instance.S.ProcessDamage(d, __instance);
				bool flag3 = false;
				if (__instance.m_integrity > 0f)
				{
					if (flag && log_bullet_events)
					{
						Logger.LogWarning((object)"> BULLET DAMAGED ENEMY <\t<\t<\t<");
						Logger.LogDebug((object)("damage_override = " + flag2));
						Logger.LogDebug((object)("impact_angle = " + num2 + ",\t impact_aspect = " + num3));
						Logger.LogDebug((object)("(sosiglink damage) damage params:\n\tblunt: " + d.Dam_Blunt + "\n\tpiercing: " + d.Dam_Piercing + "\n\tkinetic: " + d.Dam_TotalKinetic + "\n\tDamMult: " + __instance.DamMult));
						float num5 = d.Dam_Blunt * 0.032f;
						num5 += Mathf.Clamp((d.Dam_Piercing - 500f) * 0.008f, 0f, 100f);
						num5 += Mathf.Clamp((d.Dam_Cutting - 500f) * 0.008f, 0f, 100f);
						num5 += Mathf.Clamp(d.Dam_Thermal * 0.01f, 0f, 100f);
						num5 = Mathf.Clamp(num5 * __instance.DamMult, 0f, 100f);
						Logger.LogDebug((object)("integrity damage " + num5));
					}
					flag3 = __instance.DamageIntegrity(d);
				}
				if (d.Dam_TotalKinetic > 80f)
				{
					__instance.S.RequestHitDecal(d.point, d.hitNormal, d.damageSize * 2f, __instance);
				}
				if (__instance.S.Mustard > 0f && !flag3)
				{
					float num6 = (d.Dam_Piercing + d.Dam_Cutting + d.Dam_TotalKinetic / 4f - 50f) * 0.05f;
					float damMult = __instance.DamMult;
					num6 = Mathf.Clamp(num6 * damMult, 0f, 100f);
					__instance.S.SetLastIFFDamageSource(d.Source_IFF);
					if (flag)
					{
						if (!flag2)
						{
							if (log_bullet_events)
							{
								num6 *= pl_out_dmg_mult.Value;
								if (num6 > 100f)
								{
									num6 = 100f;
								}
								Logger.LogDebug((object)("bleeding amount = (" + d.Dam_Piercing + " + " + d.Dam_Cutting + " + " + d.Dam_TotalKinetic / 4f + " - 50f) * 0.05f = " + num6));
							}
						}
						else if (bullet_pen_mod.Value)
						{
							if (armor_lv == 1)
							{
								num6 = (d.Dam_Piercing + d.Dam_Cutting + d.Dam_TotalKinetic / 6f - 60f) * 0.045f;
								damMult = __instance.DamMult;
								num6 = Mathf.Clamp(num6 * damMult, 0f, 100f);
								if (num6 < 5f)
								{
									num6 = (num6 + num6 + 5f) / 3f;
								}
								num6 *= pl_out_dmg_mult.Value;
								if (num6 > 100f)
								{
									num6 = 100f;
								}
								if (log_bullet_events)
								{
									Logger.LogDebug((object)("bleeding amount = (" + d.Dam_Piercing + " + " + d.Dam_Cutting + " + " + d.Dam_TotalKinetic / 6f + " - 60f) * 0.045f (+ dmg mult / 2) = " + num6 + " (lv1)"));
								}
							}
							if (armor_lv == 2)
							{
								num6 = (d.Dam_Piercing + d.Dam_Cutting + d.Dam_TotalKinetic / 8f - 60f) * 0.05f;
								damMult = __instance.DamMult;
								num6 = Mathf.Clamp(num6 * damMult, 0f, 100f);
								if (num6 < 2f)
								{
									num6 = (num6 + 2f + 2f) / 3f;
								}
								num6 *= pl_out_dmg_mult.Value;
								if (num6 > 100f)
								{
									num6 = 100f;
								}
								if (log_bullet_events)
								{
									Logger.LogDebug((object)("bleeding amount = (" + d.Dam_Piercing + " + " + d.Dam_Cutting + " + " + d.Dam_TotalKinetic / 8f + " - 60f) * 0.05f (+ dmg mult / 2) = " + num6 + " (lv2)"));
								}
							}
						}
						if (log_bullet_events)
						{
							if (num6 < 1f)
							{
								Logger.LogError((object)"> Impact is too weak to cause bleeding. <");
							}
							else
							{
								Logger.LogDebug((object)("bleeding amount = " + num6));
							}
						}
					}
					__instance.S.AccurueBleedingHit(__instance, d.point, d.strikeDir, num6);
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Sosig), "Configure")]
		[HarmonyPostfix]
		private static void Sosig_Configure_postfix(Sosig __instance)
		{
			//IL_003d: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			if (red_blood.Value)
			{
				Color val = default(Color);
				((Color)(ref val))..ctor(0.7f, 0f, 0f, 1f);
				((Renderer)__instance.DamageFX_SmallMustardBurst.GetComponent<ParticleSystemRenderer>()).sharedMaterial.SetColor("_Color", val);
				((Renderer)__instance.DamageFX_LargeMustardBurst.GetComponent<ParticleSystemRenderer>()).sharedMaterial.SetColor("_Color", val);
				((Renderer)__instance.DamageFX_MustardSpoutSmall.GetComponent<ParticleSystemRenderer>()).sharedMaterial.SetColor("_Color", val);
				((Renderer)__instance.DamageFX_MustardSpoutLarge.GetComponent<ParticleSystemRenderer>()).sharedMaterial.SetColor("_Color", val);
				((Renderer)__instance.DamageFX_Explosion.GetComponent<ParticleSystemRenderer>()).sharedMaterial.SetColor("_Color", val);
			}
		}

		[HarmonyPatch(typeof(SosigWeapon), "TryToFireGun", new Type[]
		{
			typeof(Vector3),
			typeof(bool),
			typeof(bool),
			typeof(bool),
			typeof(float),
			typeof(bool)
		})]
		[HarmonyPrefix]
		private static bool SosigWeapon_TryToFireGun_prefix1(SosigWeapon __instance, Vector3 targetPos, bool isPanicFiring, bool targetPointIdentified, bool isClutching, float recoilMult, bool isHipfiring)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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)
			if (!em_wpn_mod.Value)
			{
				return true;
			}
			__instance.ForcedRefireMin = 0f;
			if ((int)__instance.UsageState != 0)
			{
				return false;
			}
			if (__instance.m_refireTick > 0f)
			{
				if (__instance.isFullAuto)
				{
					__instance.m_refireTick -= Time.deltaTime * 1.1f;
					return false;
				}
				__instance.m_refireTick -= Time.deltaTime;
				return false;
			}
			if (!targetPointIdentified && !isPanicFiring)
			{
				return false;
			}
			Vector3 val = targetPos - __instance.Muzzle.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > __instance.RangeMinMax.y && !isPanicFiring)
			{
				return false;
			}
			float num = __instance.GetCurrentAngularLimit(magnitude);
			if (isHipfiring)
			{
				num *= 4f;
			}
			float num2 = Vector3.Angle(Vector3.ProjectOnPlane(val, Vector3.up), Vector3.ProjectOnPlane(__instance.Muzzle.forward, Vector3.up));
			float num3 = Vector3.Angle(Vector3.ProjectOnPlane(val, ((Component)__instance).transform.right), Vector3.ProjectOnPlane(__instance.Muzzle.forward, ((Component)__instance).transform.right));
			float num4 = 0.5f;
			if (__instance.UsesBurstLimit && __instance.m_shotsLeftTilBurstLimit < 2)
			{
				num4 = 5f;
			}
			if (magnitude < 4f)
			{
				num4 = 5f;
			}
			if (magnitude < 2f)
			{
				num4 = 10f;
			}
			if (magnitude < 1f)
			{
				num4 = num;
			}
			bool flag = false;
			if (__instance.isFullAuto)
			{
				if (isClutching && (__instance.timeSinceFired < 0.01f || isPanicFiring))
				{
					flag = true;
				}
			}
			else if (isClutching && (__instance.timeSinceFired < 0.1f || isPanicFiring))
			{
				flag = true;
			}
			if ((num2 > num || num3 > Mathf.Min(num, num4)) && !isPanicFiring && !flag)
			{
				return false;
			}
			if (!isPanicFiring && !flag && !__instance.GetFireClear(__instance.Muzzle.position, __instance.Muzzle.forward, __instance.RangeMinMax.y, magnitude))
			{
				return false;
			}
			__instance.FireGun(recoilMult);
			return false;
		}

		[HarmonyPatch(typeof(SosigWeapon), "UpdateRecoil")]
		[HarmonyPostfix]
		private static void SosigWeapon_UpdateRecoil_postfix(SosigWeapon __instance)
		{
			//IL_015f: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			if (!em_wpn_mod.Value)
			{
				return;
			}
			bool flag = false;
			bool flag2 = false;
			float num = 1f * ((em_acc_mult.Value + 2f) / 3f);
			if ((Object)(object)__instance.RecoilP != (Object)null)
			{
				if (__instance.m_recoilX > 0f)
				{
					__instance.m_recoilX = Mathf.MoveTowards(__instance.m_recoilX, 0f, Time.deltaTime * __instance.RecoilP.RecoilPerShot.y * 4f * __instance.RecoilP.RecoilRecoveryMults.x * num);
					flag = true;
				}
				if (fabs(__instance.m_recoilY) > 0f)
				{
					__instance.m_recoilY = Mathf.MoveTowards(__instance.m_recoilY, 0f, Time.deltaTime * __instance.RecoilP.RecoilPerShot.y * 3f * 0.5f * __instance.RecoilP.RecoilRecoveryMults.y * num);
					flag = true;
				}
				if (__instance.m_recoilLinear > 0f)
				{
					__instance.m_recoilLinear = Mathf.MoveTowards(__instance.m_recoilLinear, 0f, Time.deltaTime * __instance.RecoilP.RecoilPerShot.w * 1f * __instance.RecoilP.RecoilRecoveryMults.z * num);
					flag2 = true;
				}
			}
			if (flag2)
			{
				__instance.RecoilHolder.localPosition = new Vector3(0f, 0f, __instance.m_recoilLinear);
			}
			if (flag)
			{
				if (__instance.isFullAuto)
				{
					__instance.RecoilHolder.localEulerAngles = new Vector3(__instance.m_recoilX / (3f * em_acc_mult.Value), __instance.m_recoilY / (1.5f * em_acc_mult.Value), 0f);
				}
				else
				{
					__instance.RecoilHolder.localEulerAngles = new Vector3(__instance.m_recoilX / em_acc_mult.Value, __instance.m_recoilY / em_acc_mult.Value, 0f);
				}
			}
		}

		[HarmonyPatch(typeof(SosigWeapon), "Recoil")]
		[HarmonyPrefix]
		private static bool SosigWeapon_Recoil_prefix(SosigWeapon __instance, float recoilMult)
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			if (!em_wpn_mod.Value)
			{
				return true;
			}
			if ((Object)(object)__instance.RecoilP != (Object)null)
			{
				__instance.m_recoilX += __instance.RecoilP.RecoilPerShot.x * recoilMult;
				__instance.m_recoilY += Random.Range(__instance.RecoilP.RecoilPerShot.x * 0.5f, (0f - __instance.RecoilP.RecoilPerShot.x) * 0.5f) * recoilMult;
				__instance.m_recoilLinear += __instance.RecoilP.RecoilPerShot.z;
				__instance.m_recoilX = Mathf.Clamp(__instance.m_recoilX, 0f, __instance.RecoilP.RecoilPerShot.y);
				__instance.m_recoilY = Mathf.Clamp(__instance.m_recoilY, 0f, __instance.RecoilP.RecoilPerShot.y * 0.5f);
				__instance.m_recoilLinear = Mathf.Clamp(__instance.m_recoilLinear, 0f, __instance.RecoilP.RecoilPerShot.w);
			}
			__instance.RecoilHolder.localPosition = new Vector3(0f, 0f, __instance.m_recoilLinear);
			if (__instance.isFullAuto)
			{
				__instance.RecoilHolder.localEulerAngles = new Vector3(__instance.m_recoilX / (3f * em_acc_mult.Value), __instance.m_recoilY / (1.5f * em_acc_mult.Value), 0f);
				return false;
			}
			__instance.RecoilHolder.localEulerAngles = new Vector3(__instance.m_recoilX, __instance.m_recoilY, 0f);
			return false;
		}

		[HarmonyPatch(typeof(SosigWeapon), "FireGun")]
		[HarmonyPrefix]
		private static bool SosigWeapon_FireGun_prefix(SosigWeapon __instance, float recoilMult)
		{
			//IL_0031: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			if (!em_wpn_mod.Value)
			{
				return true;
			}
			float num = (em_acc_mult.Value + 1f) / 2f;
			if (__instance.m_shotsLeft <= 0)
			{
				return false;
			}
			if ((int)__instance.MechaState != 0)
			{
				return false;
			}
			if (__instance.IsHeldByBot)
			{
				__instance.SosigHoldingThis.GetEntity().ProcessLoudness(__instance.ShotLoudness);
			}
			if ((Object)(object)__instance.Muzzle == (Object)null)
			{
				return false;
			}
			__instance.timeSinceFired = 0f;
			if (__instance.UsesSustainedSound)
			{
				if (__instance.m_sustainEnergy <= 0f)
				{
					SM.PlayCoreSound((FVRPooledAudioType)10, __instance.AudEvent_SustainedEmit, ((Component)__instance).transform.position);
				}
				if (!__instance.AudSource_SustainedLoop.isPlaying)
				{
					__instance.AudSource_SustainedLoop.Play();
				}
				__instance.m_sustainEnergy = __instance.SustainEnergyPerShot;
			}
			for (int i = 0; i < __instance.ProjectilesPerShot; i++)
			{
				Vector3 val = __instance.Muzzle.position;
				if (__instance.HasMuzzleOffsetSet)
				{
					Vector3 val2 = __instance.MuzzleOffsetSets[__instance.m_muzzleOffsetIndex];
					val += ((Component)__instance).transform.right * val2.x + ((Component)__instance).transform.up * val2.y + ((Component)__instance).transform.forward * val2.z;
					__instance.m_muzzleOffsetIndex++;
					if (__instance.m_muzzleOffsetIndex >= __instance.MuzzleOffsetSets.Count)
					{
						__instance.m_muzzleOffsetIndex = 0;
					}
				}
				GameObject val3 = Object.Instantiate<GameObject>(__instance.Projectile, val, __instance.Muzzle.rotation);
				float num2 = __instance.ProjectileSpread;
				if (num2 < 0.2f)
				{
					num2 = (__instance.ProjectileSpread + 0.2f) / 2f;
				}
				num2 /= num;
				float num3 = 1f;
				if (__instance.isFullAuto)
				{
					num3 = 2f / num * (__instance.m_recoilLinear / Mathf.Clamp(__instance.RecoilP.RecoilPerShot.w, Mathf.Epsilon, 10f));
					num3 = Mathf.Clamp(num3, 0.8f, 2f);
				}
				else
				{
					num3 = 1f / num * (__instance.m_recoilLinear / Mathf.Clamp(__instance.RecoilP.RecoilPerShot.w, Mathf.Epsilon, 10f));
					num3 = Mathf.Clamp(num3, 1f, 2f);
				}
				if (num2 < 0.5f)
				{
					num2 = (num2 + 0.5f) / 2f;
				}
				else if (num2 > 1.5f)
				{
					num2 = (num2 + num2 + 1.5f) / 3f;
				}
				float num4 = 1f;
				if (__instance.ProjectilesPerShot == 1)
				{
					num4 = ((!__instance.isFullAuto) ? (num2 * num3 * spow(Random.Range(0.3f, 1f), 0.5f)) : (num2 * num3 * Random.Range(0.3f, 1f)));
				}
				val3.transform.Rotate(new Vector3(Random.Range(0f - num4, num4), Random.Range(0f - num4, num4), 0f));
				BallisticProjectile component = val3.GetComponent<BallisticProjectile>();
				component.FlightVelocityMultiplier *= __instance.FlightVelocityMultiplier;
				float num5 = component.MuzzleVelocityBase;
				if (__instance.IsHeldByBot && __instance.SosigHoldingThis.isDamPowerUp)
				{
					num5 *= __instance.SosigHoldingThis.BuffIntensity_DamPowerUpDown;
				}
				__instance.m_projRealSpeed = component.MuzzleVelocityBase * component.FlightVelocityMultiplier;
				if (__instance.IsHeldByBot