Decompiled source of UltraRealism v1.0.1

UltraRealistic.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UltraRealistic")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("RealismNeat")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltraRealistic")]
[assembly: AssemblyTitle("UltraRealistic")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UltraRealistic;

[BepInPlugin("UltraRealistic", "UltraRealistic", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static bool Ragdolled;

	public static Plugin instance;

	private float normalWalkSpeed;

	public static AudioClip EMOTIONALDAMAGE;

	public static AudioClip gunEmpty;

	private float distanceThePlayerFell;

	private static float _inertia;

	private static float FlooredMultiplier => (!MonoSingleton<NewMovement>.Instance.gc.touchingGround) ? 1 : 2;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		instance = this;
		Harmony val = new Harmony("UltraRealistic");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin UltraRealistic is loaded!");
		((MonoBehaviour)this).StartCoroutine(LoadEmbeddedAudio("UltraRealistic.TF2 critical hit sound effect.wav"));
		((MonoBehaviour)this).StartCoroutine(LoadEmbeddedAudioJam("UltraRealistic.empty-gun-shot-6209.wav"));
	}

	public static bool HandleJamming(ref bool[] jammedArray, int variation, Dictionary<int, Coroutine> coroutinesDictionary, MonoBehaviour instance, Func<bool[], int, IEnumerator> resetCoroutine, float chanceToJam)
	{
		if (variation < 0 || variation >= jammedArray.Length)
		{
			Debug.LogError((object)"Invalid variation index");
			return true;
		}
		if (jammedArray[variation])
		{
			Plugin.instance.playJamSound();
			return false;
		}
		int num = Random.Range(0, 100);
		Debug.Log((object)$"Jamming chance roll: {num}");
		jammedArray[variation] = (float)num >= chanceToJam;
		if (jammedArray[variation])
		{
			Debug.Log((object)"Weapon jammed, starting reset coroutine");
			if (coroutinesDictionary.ContainsKey(variation) && coroutinesDictionary[variation] != null)
			{
				Debug.Log((object)("Removing coroutine from " + variation));
				((MonoBehaviour)Plugin.instance).StopCoroutine(coroutinesDictionary[variation]);
			}
			coroutinesDictionary[variation] = ((MonoBehaviour)Plugin.instance).StartCoroutine(resetCoroutine(jammedArray, variation));
		}
		return !jammedArray[variation];
	}

	public static IEnumerator ResetJammedState(bool[] jammedArray, int variation)
	{
		float delay = Random.Range(2, 15);
		Debug.Log((object)$"Resetting jammed state for variation {variation} after {delay} seconds");
		yield return (object)new WaitForSeconds(delay);
		Debug.Log((object)"Delay is done. Resetting!");
		if (variation >= 0 && variation < jammedArray.Length)
		{
			jammedArray[variation] = false;
			Debug.Log((object)$"Jammed state reset for variation {variation}");
		}
		else
		{
			Debug.LogError((object)"Invalid variation index during reset");
		}
	}

	private IEnumerator LoadEmbeddedAudio(string resourcePath)
	{
		Assembly assembly = Assembly.GetExecutingAssembly();
		using (Stream stream = assembly.GetManifestResourceStream(resourcePath))
		{
			if (stream == null)
			{
				Debug.LogError((object)("Failed to load embedded resource: " + resourcePath));
				yield break;
			}
			byte[] buffer = new byte[stream.Length];
			stream.Read(buffer, 0, buffer.Length);
			AudioClip audioClip = WavUtility.ToAudioClip(buffer);
			EMOTIONALDAMAGE = audioClip;
		}
		yield return null;
	}

	private IEnumerator LoadEmbeddedAudioJam(string resourcePath)
	{
		Assembly assembly = Assembly.GetExecutingAssembly();
		using (Stream stream = assembly.GetManifestResourceStream(resourcePath))
		{
			if (stream == null)
			{
				Debug.LogError((object)("Failed to load embedded resource: " + resourcePath));
				yield break;
			}
			byte[] buffer = new byte[stream.Length];
			stream.Read(buffer, 0, buffer.Length);
			AudioClip audioClip = WavUtility.ToAudioClip(buffer);
			gunEmpty = audioClip;
		}
		yield return null;
	}

	private void Update()
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		if (MonoSingleton<InputManager>.Instance.InputSource.Dodge.WasPerformedThisFrame)
		{
			normalWalkSpeed = MonoSingleton<NewMovement>.Instance.walkSpeed;
			NewMovement obj = MonoSingleton<NewMovement>.Instance;
			obj.walkSpeed *= 2f;
		}
		else if (MonoSingleton<InputManager>.Instance.InputSource.Dodge.WasCanceledThisFrame)
		{
			MonoSingleton<NewMovement>.Instance.walkSpeed = normalWalkSpeed;
		}
		if ((double)MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true).y <= -0.125 && MonoSingleton<PlayerTracker>.Instance.levelStarted && !MonoSingleton<NewMovement>.Instance.jumping)
		{
			distanceThePlayerFell += MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true).y;
		}
		else if (distanceThePlayerFell <= 0f)
		{
			if (distanceThePlayerFell <= -585.919f)
			{
				float num = 0f - distanceThePlayerFell / 87.88785f;
				Debug.Log((object)(distanceThePlayerFell + " " + num));
				MonoSingleton<NewMovement>.Instance.GetHurt((int)num, false, 1f, false, false, 0.35f, false);
			}
			distanceThePlayerFell = 0f;
		}
		CameraController obj2 = MonoSingleton<CameraController>.Instance;
		obj2.rotationX += _inertia * Time.deltaTime * 10f;
		_inertia = Mathf.MoveTowards(_inertia, 0f, Time.deltaTime * 50f);
	}

	public static void Ragdoll()
	{
		Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
		rb.constraints = (RigidbodyConstraints)0;
		((Behaviour)MonoSingleton<CameraController>.Instance).enabled = false;
		((Behaviour)MonoSingleton<NewMovement>.Instance).enabled = false;
		rb.useGravity = true;
		Ragdolled = true;
	}

	public static void UnRagdoll()
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		((Behaviour)MonoSingleton<NewMovement>.Instance).enabled = true;
		Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
		rb.constraints = (RigidbodyConstraints)112;
		((Behaviour)MonoSingleton<CameraController>.Instance).enabled = true;
		rb.useGravity = false;
		Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform;
		transform.localRotation *= Quaternion.Euler(0f, 1f, 0f);
		Ragdolled = false;
	}

	public static void AddRecoil(float strength)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		MonoSingleton<NewMovement>.Instance.rb.AddForce(strength * -((Component)MonoSingleton<CameraController>.Instance).transform.forward * FlooredMultiplier, (ForceMode)2);
		_inertia += strength;
	}

	public void delayedUnragdoll(float delay)
	{
		((MonoBehaviour)this).StartCoroutine(RagdollDelay(delay));
	}

	public IEnumerator RagdollDelay(float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		UnRagdoll();
	}

	public void DamageWithDelay(float delay, int damage)
	{
		((MonoBehaviour)this).StartCoroutine(DamageWithDelayNumarator(delay, damage));
	}

	public IEnumerator DamageWithDelayNumarator(float delay, int damage)
	{
		yield return (object)new WaitForSeconds(delay);
		DamagePlayer(damage);
	}

	public void DamagePlayer(int damage)
	{
		MonoSingleton<NewMovement>.Instance.GetHurt(damage, false, 1f, false, false, 0.35f, false);
		PlayAudioClip(EMOTIONALDAMAGE, "emotional");
	}

	public void playJamSound()
	{
		PlayAudioClip(gunEmpty, "jam");
	}

	private void PlayAudioClip(AudioClip clip, string soundname)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)GameObject.Find("AudioSourceObject" + soundname)))
		{
			GameObject val = new GameObject("AudioSourceObject" + soundname);
			AudioSource val2 = val.AddComponent<AudioSource>();
			val.transform.position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			val.transform.parent = ((Component)MonoSingleton<NewMovement>.Instance).transform;
			val2.clip = clip;
			val2.Play();
			Object.Destroy((Object)(object)val, clip.length);
		}
	}
}
public static class WavUtility
{
	public static AudioClip ToAudioClip(byte[] wavFileBytes)
	{
		int num = 44;
		int num2 = BitConverter.ToInt32(wavFileBytes, 24);
		int num3 = BitConverter.ToInt16(wavFileBytes, 22);
		int num4 = (wavFileBytes.Length - num) / 2;
		float[] array = new float[num4];
		for (int i = 0; i < num4; i++)
		{
			array[i] = (float)BitConverter.ToInt16(wavFileBytes, num + i * 2) / 32768f;
		}
		AudioClip val = AudioClip.Create("EmbeddedAudio", num4, num3, num2, false);
		val.SetData(array, 0);
		return val;
	}
}
[HarmonyPatch(typeof(NewMovement), "StartSlide")]
public class NoMoreSlide
{
	public static bool Prefix(ref NewMovement __instance, ref Vector3 ___groundCheckPos, ref bool ___crouching)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if (!___crouching)
		{
			__instance.playerCollider.height = 1.25f;
			((Component)__instance).transform.position = new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y - 1.125f, ((Component)__instance).transform.position.z);
			((Component)__instance.gc).transform.localPosition = ___groundCheckPos + Vector3.up * 1.125f;
		}
		__instance.sliding = true;
		return false;
	}
}
[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
public class HeadshotIsInstaDeath
{
	public static bool Prefix(ref EnemyIdentifier __instance, GameObject target, Vector3 force, Vector3 hitPoint, float multiplier, bool tryForExplode, float critMultiplier = 0f, GameObject sourceWeapon = null, bool ignoreTotalDamageTakenMultiplier = false, bool fromExplosion = false)
	{
		if ((Object)(object)target == (Object)(object)__instance.weakPoint)
		{
			__instance.InstaKill();
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(DualWieldPickup), "PickedUp")]
public class nomoreDualWields
{
	public static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(CutsceneSkip), "Start")]
public class nomoreskipping
{
	public static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch]
public class Ammo
{
	private static int maxAmmoRevolver = 6;

	private static int ammoRevolver = 6;

	private static int maxAmmoRocketLauncher = 1;

	private static int AmmoRocketLauncher = 1;

	private static int maxAmmoShotgun = 5;

	private static int AmmoShotgun = 5;

	public static bool isRevolverReloading = false;

	public static bool isShotgunReloading = false;

	public static bool isRocketLauncherReloading = false;

	[HarmonyPatch(typeof(Revolver), "Shoot")]
	[HarmonyPrefix]
	private static bool AddRevolverAmmo(Revolver __instance, int shotType)
	{
		if (Jamming.revolverJammed[__instance.gunVariation])
		{
			return false;
		}
		if (ammoRevolver <= 0)
		{
			Debug.Log((object)isShotgunReloading);
			if (!isRevolverReloading)
			{
				((MonoBehaviour)__instance).StartCoroutine(ReloadRevolver(((Component)__instance).transform));
			}
			return false;
		}
		ammoRevolver--;
		Debug.Log((object)ammoRevolver);
		return true;
	}

	[HarmonyPatch(typeof(Shotgun), "Shoot")]
	[HarmonyPrefix]
	private static bool AddShotgunAmmo(Shotgun __instance)
	{
		if (Jamming.shotgunJammed[__instance.variation])
		{
			return false;
		}
		if (AmmoShotgun <= 0)
		{
			Debug.Log((object)isShotgunReloading);
			if (!isShotgunReloading)
			{
				((MonoBehaviour)__instance).StartCoroutine(ReloadShotgun(((Component)__instance).transform));
			}
			return false;
		}
		AmmoShotgun--;
		Debug.Log((object)AmmoShotgun);
		return true;
	}

	[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
	[HarmonyPrefix]
	private static bool AddRocketAmmo(RocketLauncher __instance)
	{
		if (Jamming.rocketLauncherJammed[__instance.variation])
		{
			return false;
		}
		if (AmmoRocketLauncher <= 0)
		{
			Debug.Log((object)isRocketLauncherReloading);
			if (!isRocketLauncherReloading)
			{
				((MonoBehaviour)__instance).StartCoroutine(ReloadRocketLauncher(((Component)__instance).transform));
			}
			return false;
		}
		AmmoRocketLauncher--;
		Debug.Log((object)AmmoRocketLauncher);
		return true;
	}

	public static IEnumerator ReloadRevolver(Transform weaponModel)
	{
		isRevolverReloading = true;
		float reloadTime = 3f;
		float rotateAngle = 360f;
		float elapsedTime = 0f;
		float initialZRotation = weaponModel.localEulerAngles.z;
		while (elapsedTime < reloadTime)
		{
			float zRotation = Mathf.Lerp(0f, rotateAngle, elapsedTime / reloadTime);
			weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation + zRotation);
			elapsedTime += Time.deltaTime;
			yield return null;
		}
		weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation);
		ammoRevolver = maxAmmoRevolver;
		isRevolverReloading = false;
	}

	public static IEnumerator ReloadShotgun(Transform weaponModel)
	{
		isShotgunReloading = true;
		float reloadTime = 4f;
		float rotateAngle = 360f;
		float elapsedTime = 0f;
		float initialZRotation = weaponModel.localEulerAngles.z;
		while (elapsedTime < reloadTime)
		{
			float zRotation = Mathf.Lerp(0f, rotateAngle, elapsedTime / reloadTime);
			weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation + zRotation);
			elapsedTime += Time.deltaTime;
			yield return null;
		}
		weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation);
		AmmoShotgun = maxAmmoShotgun;
		isShotgunReloading = false;
	}

	public static IEnumerator ReloadRocketLauncher(Transform weaponModel)
	{
		isRocketLauncherReloading = true;
		float reloadTime = 10f;
		float rotateAngle = 360f;
		float elapsedTime = 0f;
		float initialZRotation = weaponModel.localEulerAngles.z;
		while (elapsedTime < reloadTime)
		{
			float zRotation = Mathf.Lerp(0f, rotateAngle, elapsedTime / reloadTime);
			weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation + zRotation);
			elapsedTime += Time.deltaTime;
			yield return null;
		}
		weaponModel.localEulerAngles = new Vector3(weaponModel.localEulerAngles.x, weaponModel.localEulerAngles.y, initialZRotation);
		AmmoRocketLauncher = maxAmmoRocketLauncher;
		isRocketLauncherReloading = false;
	}

	[HarmonyPatch(typeof(GameObject), "SetActive")]
	public static void Postfix(ref GameObject __instance, bool value)
	{
		if (!value)
		{
			if (Object.op_Implicit((Object)(object)__instance.GetComponent<Revolver>()))
			{
				isRevolverReloading = false;
			}
			else if (Object.op_Implicit((Object)(object)__instance.GetComponent<Shotgun>()))
			{
				isShotgunReloading = false;
			}
			else if (Object.op_Implicit((Object)(object)__instance.GetComponent<RocketLauncher>()))
			{
				isRocketLauncherReloading = false;
			}
		}
	}
}
[HarmonyPatch]
public class Recoil
{
	[HarmonyPatch(typeof(Revolver), "Shoot")]
	[HarmonyPrefix]
	private static void AddRevolverRecoil(Revolver __instance, int shotType)
	{
		if (!Jamming.revolverJammed[__instance.gunVariation] && !Ammo.isRevolverReloading)
		{
			if (shotType == 2)
			{
				float num = __instance.pierceShotCharge / 100f;
				Plugin.AddRecoil(20f * num);
			}
			else
			{
				Plugin.AddRecoil(10f);
			}
		}
	}

	[HarmonyPatch(typeof(Shotgun), "Shoot")]
	[HarmonyPrefix]
	private static void AddShotgunRecoil(Shotgun __instance)
	{
		if (!Jamming.shotgunJammed[__instance.variation] && !Ammo.isShotgunReloading)
		{
			float num = 1 + ((__instance.variation == 1) ? ((__instance.primaryCharge + 1) / 3) : 0);
			Plugin.AddRecoil(15f * num);
		}
	}

	[HarmonyPatch(typeof(Shotgun), "ShootSinks")]
	[HarmonyPrefix]
	private static void AddShotgunCoreRecoil(Shotgun __instance, float ___grenadeForce)
	{
		Plugin.AddRecoil(10f * (___grenadeForce / 30f * 2f));
	}

	[HarmonyPatch(typeof(Nailgun), "Shoot")]
	[HarmonyPrefix]
	private static void AddNailRecoil(Nailgun __instance)
	{
		if (!Jamming.nailgunJammed[__instance.variation])
		{
			Plugin.AddRecoil(0.75f);
		}
	}

	[HarmonyPatch(typeof(Nailgun), "ShootMagnet")]
	[HarmonyPrefix]
	private static void AddNailMagnetRecoil()
	{
		Plugin.AddRecoil(10f);
	}

	[HarmonyPatch(typeof(Railcannon), "Shoot")]
	[HarmonyPrefix]
	private static void AddRailRecoil()
	{
		Plugin.AddRecoil(50f);
	}

	[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
	[HarmonyPrefix]
	private static void AddRocketRecoil(RocketLauncher __instance)
	{
		if (!Jamming.rocketLauncherJammed[__instance.variation] && !Ammo.isRocketLauncherReloading)
		{
			Plugin.AddRecoil(15f);
		}
	}

	[HarmonyPatch(typeof(RocketLauncher), "ShootCannonball")]
	[HarmonyPrefix]
	private static void AddRocketCannonballRecoil(RocketLauncher __instance, float ___cbCharge)
	{
		Plugin.AddRecoil(30f * ___cbCharge);
	}
}
[HarmonyPatch]
public class Jamming
{
	public static bool[] revolverJammed = new bool[3];

	public static bool[] shotgunJammed = new bool[3];

	public static bool[] nailgunJammed = new bool[3];

	public static bool[] rocketLauncherJammed = new bool[3];

	public static bool[] shotgunHammerJammed = new bool[3];

	private static readonly Dictionary<int, Coroutine> revolverCoroutines = new Dictionary<int, Coroutine>();

	private static readonly Dictionary<int, Coroutine> shotgunCoroutines = new Dictionary<int, Coroutine>();

	private static readonly Dictionary<int, Coroutine> nailgunCoroutines = new Dictionary<int, Coroutine>();

	private static readonly Dictionary<int, Coroutine> rocketLauncherCoroutines = new Dictionary<int, Coroutine>();

	private static readonly Dictionary<int, Coroutine> shotgunHammerCoroutines = new Dictionary<int, Coroutine>();

	[HarmonyPatch(typeof(Revolver), "Shoot")]
	[HarmonyPrefix]
	public static bool RevolverJam(Revolver __instance)
	{
		return Plugin.HandleJamming(ref revolverJammed, __instance.gunVariation, revolverCoroutines, (MonoBehaviour)(object)__instance, Plugin.ResetJammedState, 85f);
	}

	[HarmonyPatch(typeof(Nailgun), "Shoot")]
	[HarmonyPrefix]
	public static bool NailgunJam(Nailgun __instance)
	{
		return Plugin.HandleJamming(ref nailgunJammed, __instance.variation, nailgunCoroutines, (MonoBehaviour)(object)__instance, Plugin.ResetJammedState, 99f);
	}

	[HarmonyPatch(typeof(RocketLauncher), "Shoot")]
	[HarmonyPrefix]
	public static bool RocketLauncherJam(RocketLauncher __instance)
	{
		return Plugin.HandleJamming(ref rocketLauncherJammed, __instance.variation, rocketLauncherCoroutines, (MonoBehaviour)(object)__instance, Plugin.ResetJammedState, 85f);
	}

	[HarmonyPatch(typeof(ShotgunHammer), "Impact")]
	[HarmonyPrefix]
	public static bool ShotgunHammerJam(ShotgunHammer __instance)
	{
		return Plugin.HandleJamming(ref shotgunHammerJammed, __instance.variation, shotgunHammerCoroutines, (MonoBehaviour)(object)__instance, Plugin.ResetJammedState, 85f);
	}

	[HarmonyPatch(typeof(Shotgun), "Shoot")]
	[HarmonyPrefix]
	public static bool ShotgunJam(Shotgun __instance)
	{
		return Plugin.HandleJamming(ref shotgunJammed, __instance.variation, shotgunCoroutines, (MonoBehaviour)(object)__instance, Plugin.ResetJammedState, 85f);
	}
}
[HarmonyPatch]
public class SlipEnemies
{
	[HarmonyPatch(typeof(Zombie), "Update")]
	[HarmonyPostfix]
	public static void ZombieSlip(ref Zombie __instance, ref EnemyIdentifier ___eid)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		float @float = __instance.anim.GetFloat("RunSpeed");
		if (@float > 0f)
		{
			float num = 99900f;
			float num2 = 99998f;
			float num3 = 100f;
			float num4 = (onGasoline(((Component)__instance).transform.position) ? Mathf.Clamp(num - @float * num3, 0f, 100000f) : Mathf.Clamp(num2 - @float * num3, 0f, 100000f));
			int num5 = Random.Range(0, 100000);
			if ((float)num5 >= num4)
			{
				___eid.InstaKill();
			}
		}
	}

	[HarmonyPatch(typeof(Machine), "Update")]
	[HarmonyPostfix]
	public static void MachineSlip(ref Machine __instance, ref NavMeshAgent ___nma, ref EnemyIdentifier ___eid)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)___nma != (Object)null))
		{
			return;
		}
		Vector3 velocity = ___nma.velocity;
		float magnitude = ((Vector3)(ref velocity)).magnitude;
		if (magnitude > 0f)
		{
			float num = 99900f;
			float num2 = 99998f;
			float num3 = 100f;
			float num4 = (onGasoline(((Component)__instance).transform.position) ? Mathf.Clamp(num - magnitude * num3, 0f, 100000f) : Mathf.Clamp(num2 - magnitude * num3, 0f, 100000f));
			int num5 = Random.Range(0, 100000);
			if ((float)num5 >= num4)
			{
				___eid.InstaKill();
			}
		}
	}

	[HarmonyPatch(typeof(Statue), "Update")]
	[HarmonyPostfix]
	public static void StatueSlip(ref Statue __instance, ref NavMeshAgent ___nma, ref EnemyIdentifier ___eid)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)___nma != (Object)null))
		{
			return;
		}
		Vector3 velocity = ___nma.velocity;
		float magnitude = ((Vector3)(ref velocity)).magnitude;
		if (magnitude > 0f)
		{
			float num = 99900f;
			float num2 = 99998f;
			float num3 = 100f;
			float num4 = (onGasoline(((Component)__instance).transform.position) ? Mathf.Clamp(num - magnitude * num3, 0f, 100000f) : Mathf.Clamp(num2 - magnitude * num3, 0f, 100000f));
			int num5 = Random.Range(0, 100000);
			if ((float)num5 >= num4)
			{
				___eid.InstaKill();
			}
		}
	}

	[HarmonyPatch(typeof(Wicked), "Update")]
	[HarmonyPostfix]
	public static void WickedSlip(ref Wicked __instance, ref NavMeshAgent ___nma, ref EnemyIdentifier ___eid)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)___nma != (Object)null))
		{
			return;
		}
		Vector3 velocity = ___nma.velocity;
		float magnitude = ((Vector3)(ref velocity)).magnitude;
		if (magnitude > 0f)
		{
			float num = 99900f;
			float num2 = 99998f;
			float num3 = 100f;
			float num4 = (onGasoline(((Component)__instance).transform.position) ? Mathf.Clamp(num - magnitude * num3, 0f, 100000f) : Mathf.Clamp(num2 - magnitude * num3, 0f, 100000f));
			int num5 = Random.Range(0, 100000);
			if ((float)num5 >= num4)
			{
				__instance.GetHit();
			}
		}
	}

	private static bool onGasoline(Vector3 pos)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Vector3Int val = StainVoxelManager.WorldToVoxelPosition(pos + Vector3.down * 1.8333334f);
		float num = ((!MonoSingleton<StainVoxelManager>.Instance.HasProxiesAt(val, 3, (VoxelCheckingShape)1, (ProxySearchMode)31, true)) ? 1 : 0);
		return num == 0f;
	}
}
[HarmonyPatch(typeof(NewMovement), "WallJump")]
public class NoMoreWallJump
{
	public static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(NewMovement), "Update")]
public class noDodge
{
	public static bool Prefix(ref NewMovement __instance)
	{
		__instance.boostCharge = 0f;
		return true;
	}
}
[HarmonyPatch(typeof(Punch), "ParryProjectile")]
public class noParry
{
	public static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(StatsManager), "Restart")]
public class PermaDeath
{
	public static bool Prefix()
	{
		Application.Quit();
		return false;
	}
}
[HarmonyPatch(typeof(NewMovement), "Move")]
public class Slip
{
	public static void Postfix(ref NewMovement __instance, ref GroundCheck ___gc)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		if (!___gc.onGround)
		{
			return;
		}
		Vector3 playerVelocity = MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true);
		if ((double)((Vector3)(ref playerVelocity)).magnitude >= 0.1 && !Plugin.Ragdolled)
		{
			float num = (onGasoline(((Component)__instance).transform.position, __instance) ? 99900 : 99998);
			int num2 = Random.Range(0, 100000);
			if ((float)num2 >= num)
			{
				Plugin.Ragdoll();
				MonoSingleton<NewMovement>.Instance.GetHurt(15, false, 1f, false, false, 0.35f, false);
				__instance.rb.AddForce((MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true) + new Vector3(0f, 5f, 0f)) * 2f, (ForceMode)2);
				Plugin.instance.delayedUnragdoll(2.5f);
			}
		}
	}

	private static bool onGasoline(Vector3 pos, NewMovement instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		Vector3Int val = StainVoxelManager.WorldToVoxelPosition(pos + Vector3.down * 1.8333334f);
		return instance.modForcedFrictionMultip == 0f;
	}
}
[HarmonyPatch(typeof(GabrielVoice), "TauntNow")]
public class EMOTIONALDAMAGE
{
	public static void Postfix(ref AudioSource ___aud)
	{
		Plugin.instance.DamageWithDelay(___aud.clip.length, 10);
	}
}
public static class MyPluginInfo
{
	public const string PLUGIN_GUID = "UltraRealistic";

	public const string PLUGIN_NAME = "UltraRealistic";

	public const string PLUGIN_VERSION = "1.0.0";
}