Decompiled source of RatWithAGun v0.4.2

UMM Mods/RatMod.dll

Decompiled a year ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using RatMod.Cheats.TurretOrb;
using RatMod.Properties;
using RatMod.Weapon_Scripts;
using RatMod.Weapon_Scripts.Object_Scripts;
using ULTRAKIT.Data;
using ULTRAKIT.Extensions;
using ULTRAKIT.Extensions.Classes;
using ULTRAKIT.Extensions.Interfaces;
using ULTRAKIT.Loader.Loaders;
using UMM;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RatMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("RatMod")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c1b70733-d0af-4a7e-9130-a27d06e9157b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RatMod
{
	public class Bigger : IBuff
	{
		private bool active = false;

		private EnemyIdentifier _eid;

		public EnemyIdentifier eid
		{
			get
			{
				return _eid;
			}
			set
			{
				_eid = value;
			}
		}

		public bool IsActive => active;

		public string id => "RATWITHAGUN.bigger";

		public void Enable()
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			active = true;
			Vector3 localScale = ((Component)_eid).transform.localScale;
			((Component)_eid).transform.localScale = new Vector3(localScale.x * 2f, localScale.y * 2f, localScale.z * 2f);
			_eid.DeliverDamage(((Component)_eid).gameObject, Vector3.zero, Vector3.zero, 0f - _eid.health * 2f, false, 0f, (GameObject)null, false);
		}

		public void Disable()
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			active = false;
			Vector3 localScale = ((Component)_eid).transform.localScale;
			((Component)_eid).transform.localScale = new Vector3(localScale.x / 2f, localScale.y / 2f, localScale.z / 2f);
			_eid.DeliverDamage(((Component)_eid).gameObject, Vector3.zero, Vector3.zero, _eid.health / 1.5f, false, 0f, (GameObject)null, false);
		}

		public void Update()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			_eid.DeliverDamage(((Component)_eid).gameObject, Vector3.zero, Vector3.zero, 0f - Time.deltaTime, false, 0f, (GameObject)null, false);
		}
	}
	[UKPlugin("petersone1.ratwithagun", "Rat With A Gun", "0.4.2", "Adds a collection of rats with a lust for blood", false, true)]
	public class Main : UKMod
	{
		private AssetBundle bundle = AssetBundle.LoadFromMemory(Resources.petersone1_ratwithagun);

		public Weapon[] weapons;

		public override void OnModLoaded()
		{
			Init();
			OptionsLoader.RegisterCheckbox("Rat With A Gun", "Balance Levels", "Unbalanced Mode", "rat.unbalance", false, false);
			SceneManager.sceneLoaded += OnSceneLoaded;
			weapons = WeaponLoader.LoadWeapons(bundle);
			BuffLoader.RegisterBuff((IBuff)(object)new Bigger());
		}

		public override void OnModUnload()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			WeaponLoader.UnloadWeapons("petersone1_ratwithagun");
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (Object.op_Implicit((Object)(object)MonoSingleton<CheatsManager>.Instance))
			{
				MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)OrbEnabler.cheat, (string)null);
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<RatVariableManager>.Instance))
			{
				MonoSingleton<RatVariableManager>.Instance.assetBundle = bundle;
			}
			GreechKnife.ActiveKnife = null;
		}

		private static void Init()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("RatWithAGun");
			val.PatchAll();
		}
	}
	[ConfigureSingleton(/*Could not decode attribute arguments.*/)]
	public class RatVariableManager : MonoSingleton<RatVariableManager>
	{
		public AssetBundle assetBundle;

		public GameObject Asset_ExplosionPrime;

		public GameObject Asset_ExplosionSuper;

		public GameObject Asset_PhysicalShockwaveHarmless;

		public GameObject Asset_MindflayerExplosion;

		public int GunRat_ammo = 7;

		public bool GunRat_delay = false;

		public bool BuilderRat_turretReady = true;

		public bool BuilderRat_statueReady = true;

		public int BuilderRat_numToBe = 15;

		public GameObject BuilderRat_lastStatue;

		public bool BombRat_ready = true;

		public static bool isUnbalanced
		{
			get
			{
				UKCheckbox val = default(UKCheckbox);
				OptionsLoader.GetCheckbox("rat.unbalance", ref val);
				return val.GetValue();
			}
		}

		public void OnEnable()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		public void OnDisable()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode)
		{
			Asset_ExplosionPrime = AssetLoader.AssetFind<GameObject>("Explosion Minos Prime.prefab");
			Asset_ExplosionSuper = AssetLoader.AssetFind<GameObject>("Explosion Super.prefab");
			Asset_PhysicalShockwaveHarmless = AssetLoader.AssetFind<GameObject>("PhysicalShockwaveHarmless.prefab");
			Asset_MindflayerExplosion = AssetLoader.AssetFind<GameObject>("Explosion Mindflayer.prefab");
			GunRat_ammo = 7;
			GunRat_delay = false;
			BuilderRat_turretReady = true;
			BuilderRat_statueReady = true;
		}

		public IEnumerator ReloadStatue(BuilderRat builderRat)
		{
			for (int i = Mathf.CeilToInt(builderRat.statueTimer); i > 0; i--)
			{
				BuilderRat_numToBe = i;
				if (Object.op_Implicit((Object)(object)builderRat))
				{
					MeshRenderer[] txt_num = builderRat.txt_num;
					foreach (MeshRenderer renderer in txt_num)
					{
						((Renderer)renderer).enabled = false;
					}
					((Renderer)builderRat.txt_num[i]).enabled = true;
				}
				yield return (object)new WaitForSeconds(1f);
			}
			BuilderRat_statueReady = true;
			BuilderRat_numToBe = 15;
			if (Object.op_Implicit((Object)(object)builderRat))
			{
				MeshRenderer[] txt_num2 = builderRat.txt_num;
				foreach (MeshRenderer renderer2 in txt_num2)
				{
					((Renderer)renderer2).enabled = false;
				}
				((Renderer)builderRat.txt_ready).enabled = true;
			}
			yield return null;
		}

		public IEnumerator GunDelay(float time)
		{
			GunRat_delay = true;
			yield return (object)new WaitForSeconds(time);
			GunRat_delay = false;
			yield return null;
		}
	}
}
namespace RatMod.Weapon_Scripts
{
	public class BombRat : MonoBehaviour
	{
		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private InputActionState Fire1;

		private InputActionState Fire2;

		private Transform origin;

		private GameObject projectile;

		private bool cooldownOff;

		private bool readyToFire;

		private void OnEnable()
		{
			InitializeFields();
			try
			{
				CheatsManager instance = MonoSingleton<CheatsManager>.Instance;
				cooldownOff = instance != null && instance.GetCheatState("ultrakill.no-weapon-cooldown");
			}
			catch
			{
				cooldownOff = false;
			}
			((UnityEvent<string>)(object)Events.CheatStateChanged).AddListener((UnityAction<string>)OnCheatChange);
		}

		private void OnDisable()
		{
			((UnityEvent<string>)(object)Events.CheatStateChanged).RemoveListener((UnityAction<string>)OnCheatChange);
		}

		private void Update()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			if (MonoSingleton<OptionsManager>.Instance.paused)
			{
				return;
			}
			readyToFire = _man.BombRat_ready;
			if (Fire1.WasPerformedThisFrame && readyToFire)
			{
				if (!cooldownOff)
				{
					readyToFire = false;
					((MonoBehaviour)this).Invoke("Ready", 1.5f);
				}
				GameObject val = Object.Instantiate<GameObject>(projectile, origin.position, ((Component)MonoSingleton<CameraController>.Instance).transform.rotation, (Transform)null);
				val.GetComponent<ProjectileScript>().sourceWeapon = ((Component)this).gameObject;
				val.AddComponent<FloatingPointErrorPreventer>();
				val.AddComponent<DestroyOnCheckpointRestart>();
				val.AddComponent<RemoveOnTime>().time = 30f;
			}
			_man.BombRat_ready = readyToFire;
		}

		private void Ready()
		{
			_man.BombRat_ready = true;
		}

		private void InitializeFields()
		{
			if ((Object)(object)origin == (Object)null)
			{
				origin = ((Component)this).transform.Find("RAT/gun/MuzzleOrigin");
			}
			if ((Object)(object)projectile == (Object)null)
			{
				projectile = _man.assetBundle.LoadAsset<GameObject>("explosiveprojectile.prefab");
			}
		}

		private void OnCheatChange(string cheat)
		{
			cooldownOff = MonoSingleton<CheatsManager>.Instance.GetCheatState("ultrakill.no-weapon-cooldown");
		}

		public BombRat()
		{
			InputManager instance = MonoSingleton<InputManager>.Instance;
			Fire1 = ((instance != null) ? instance.InputSource.Fire1 : null);
			InputManager instance2 = MonoSingleton<InputManager>.Instance;
			Fire2 = ((instance2 != null) ? instance2.InputSource.Fire2 : null);
			((MonoBehaviour)this)..ctor();
		}
	}
	public class BuilderRat : MonoBehaviour
	{
		public readonly float turretTimer = 10f;

		public readonly float statueTimer = 15f;

		private GameObject _turret;

		private GameObject _statue;

		private Transform origin;

		private MeshRenderer sight;

		private MeshRenderer altSight;

		public MeshRenderer txt_ready;

		public MeshRenderer[] txt_num;

		private bool cooldownOff;

		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private InputActionState Fire1;

		private InputActionState Fire2;

		private Transform head;

		private LayerMask mask;

		private void OnEnable()
		{
			InitializeFields();
			if (_man.BuilderRat_turretReady)
			{
				((Renderer)sight).enabled = true;
				((Renderer)altSight).enabled = false;
			}
			else
			{
				((Renderer)altSight).enabled = true;
				((Renderer)sight).enabled = false;
			}
			((Renderer)txt_ready).enabled = false;
			MeshRenderer[] array = txt_num;
			foreach (MeshRenderer val in array)
			{
				((Renderer)val).enabled = false;
			}
			if (_man.BuilderRat_statueReady)
			{
				((Renderer)txt_ready).enabled = true;
			}
			else
			{
				((Renderer)txt_num[_man.BuilderRat_numToBe]).enabled = true;
			}
			try
			{
				CheatsManager instance = MonoSingleton<CheatsManager>.Instance;
				cooldownOff = instance != null && instance.GetCheatState("ultrakill.no-weapon-cooldown");
			}
			catch
			{
				cooldownOff = false;
			}
			((UnityEvent<string>)(object)Events.CheatStateChanged).AddListener((UnityAction<string>)OnCheatChange);
		}

		private void OnDisable()
		{
			((UnityEvent<string>)(object)Events.CheatStateChanged).RemoveListener((UnityAction<string>)OnCheatChange);
		}

		private void Update()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			if (MonoSingleton<OptionsManager>.Instance.paused)
			{
				return;
			}
			bool flag = _man.BuilderRat_turretReady;
			bool flag2 = _man.BuilderRat_statueReady;
			RaycastHit val = default(RaycastHit);
			if (Fire1.WasPerformedThisFrame && flag && Physics.Raycast(head.position + head.forward, head.forward, ref val, float.PositiveInfinity, LayerMask.op_Implicit(mask)))
			{
				if (!cooldownOff)
				{
					flag = false;
					((Renderer)sight).enabled = false;
					((Renderer)altSight).enabled = true;
					((MonoBehaviour)this).Invoke("ReloadTurret", turretTimer);
				}
				GameObject val2 = Object.Instantiate<GameObject>(_turret, ((RaycastHit)(ref val)).point, Quaternion.identity, (Transform)null);
				val2.GetComponent<TurretScript>().sourceWeapon = ((Component)this).gameObject;
				val2.transform.LookAt(head);
				val2.transform.rotation = Quaternion.FromToRotation(val2.transform.up, ((RaycastHit)(ref val)).normal) * ((Component)this).transform.rotation;
				val2.AddComponent<DestroyOnCheckpointRestart>();
				GraphicsUtilities.RenderObject<Transform>(val2.transform, LayerMask.op_Implicit(LayerMask.NameToLayer("Outdoors")));
				val2.SetActive(true);
			}
			RaycastHit val3 = default(RaycastHit);
			if (Fire2.WasPerformedThisFrame && flag2 && Physics.Raycast(head.position + head.forward, head.forward, ref val3, float.PositiveInfinity, LayerMask.op_Implicit(mask)))
			{
				if (!cooldownOff)
				{
					flag2 = false;
					ReloadStatue();
				}
				if (Object.op_Implicit((Object)(object)_man.BuilderRat_lastStatue))
				{
					Object.Destroy((Object)(object)_man.BuilderRat_lastStatue);
				}
				GameObject val4 = Object.Instantiate<GameObject>(_statue, ((RaycastHit)(ref val3)).point, Quaternion.identity, (Transform)null);
				val4.GetComponent<StatueScript>().sourceWeapon = ((Component)this).gameObject;
				val4.transform.LookAt(head);
				val4.transform.rotation = Quaternion.FromToRotation(val4.transform.up, ((RaycastHit)(ref val3)).normal) * ((Component)this).transform.rotation;
				val4.AddComponent<DestroyOnCheckpointRestart>();
				GraphicsUtilities.RenderObject<Transform>(val4.transform, LayerMask.op_Implicit(LayerMask.NameToLayer("Outdoors")));
				_man.BuilderRat_lastStatue = val4;
				val4.SetActive(true);
			}
			_man.BuilderRat_turretReady = flag;
			_man.BuilderRat_statueReady = flag2;
		}

		private void ReloadTurret()
		{
			_man.BuilderRat_turretReady = true;
			((Renderer)sight).enabled = true;
			((Renderer)altSight).enabled = false;
		}

		private void ReloadStatue()
		{
			((Renderer)txt_ready).enabled = false;
			IEnumerator enumerator = _man.ReloadStatue(this);
			((MonoBehaviour)_man).StartCoroutine(enumerator);
		}

		private void InitializeFields()
		{
			if ((Object)(object)origin == (Object)null)
			{
				origin = ((Component)this).transform.Find("RAT/gun/MuzzleOrigin");
			}
			if ((Object)(object)sight == (Object)null)
			{
				sight = ((Component)((Component)this).transform.Find("RAT/gun/Slide/FrontSight")).gameObject.GetComponent<MeshRenderer>();
			}
			if ((Object)(object)altSight == (Object)null)
			{
				altSight = ((Component)((Component)this).transform.Find("RAT/gun/Slide/RedSight")).gameObject.GetComponent<MeshRenderer>();
			}
			if (txt_num == null || txt_num.Length == 0)
			{
				txt_num = ((Component)((Component)this).transform.Find("RAT/gun/Screen/TEXT/NUM")).gameObject.GetComponentsInChildren<MeshRenderer>();
			}
			if ((Object)(object)txt_ready == (Object)null)
			{
				txt_ready = ((Component)((Component)this).transform.Find("RAT/gun/Screen/TEXT/Ready")).gameObject.GetComponent<MeshRenderer>();
			}
			if ((Object)(object)_turret == (Object)null)
			{
				_turret = _man.assetBundle.LoadAsset<GameObject>("turret.prefab");
			}
			if ((Object)(object)_statue == (Object)null)
			{
				_statue = _man.assetBundle.LoadAsset<GameObject>("statue.prefab");
			}
		}

		private void OnCheatChange(string cheat)
		{
			cooldownOff = MonoSingleton<CheatsManager>.Instance.GetCheatState("ultrakill.no-weapon-cooldown");
		}

		public BuilderRat()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			InputManager instance = MonoSingleton<InputManager>.Instance;
			Fire1 = ((instance != null) ? instance.InputSource.Fire1 : null);
			InputManager instance2 = MonoSingleton<InputManager>.Instance;
			Fire2 = ((instance2 != null) ? instance2.InputSource.Fire2 : null);
			CameraController instance3 = MonoSingleton<CameraController>.Instance;
			head = ((instance3 != null) ? ((Component)instance3).transform : null);
			mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Environment", "Outdoors" }));
			((MonoBehaviour)this)..ctor();
		}
	}
	public class GreechKnife : MonoBehaviour
	{
		private const float _launchSpeed = 75f;

		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private InputActionState Fire1;

		private InputActionState Fire2;

		private GameObject _knifePrefab;

		public static GameObject ActiveKnife;

		private double timeToRun;

		public void OnEnable()
		{
			InitializeFields();
		}

		public void Update()
		{
			//IL_0034: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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)
			if (Fire1.WasPerformedThisFrame && (Object)(object)ActiveKnife == (Object)null)
			{
				ActiveKnife = Object.Instantiate<GameObject>(_knifePrefab, ((Component)MonoSingleton<CameraController>.Instance).transform.position + ((Component)MonoSingleton<CameraController>.Instance).transform.forward, Quaternion.identity, (Transform)null);
				GraphicsUtilities.RenderObject<Transform>(ActiveKnife.transform, LayerMask.op_Implicit(LayerMask.NameToLayer("Projectile")));
				ActiveKnife.GetComponent<KnifeObject>().timeLeft = timeToRun;
				Vector3 val = ((Component)MonoSingleton<CameraController>.Instance).transform.forward * 75f;
				ActiveKnife.GetComponent<Rigidbody>().AddForce(val, (ForceMode)2);
			}
			if (Fire2.WasPerformedThisFrame && (Object)(object)ActiveKnife != (Object)null)
			{
				ActiveKnife.GetComponent<KnifeObject>().Recall();
				ActiveKnife = null;
			}
		}

		private void InitializeFields()
		{
			if ((Object)(object)_knifePrefab == (Object)null)
			{
				_knifePrefab = _man.assetBundle.LoadAsset<GameObject>("knifeobject.prefab");
			}
		}

		public GreechKnife()
		{
			InputManager instance = MonoSingleton<InputManager>.Instance;
			Fire1 = ((instance != null) ? instance.InputSource.Fire1 : null);
			InputManager instance2 = MonoSingleton<InputManager>.Instance;
			Fire2 = ((instance2 != null) ? instance2.InputSource.Fire2 : null);
			timeToRun = 10.0;
			((MonoBehaviour)this)..ctor();
		}
	}
	public class GunScript : MonoBehaviour
	{
		public static Action Refresh;

		public static bool isActive;

		private bool cooldownOff;

		private Transform origin;

		private MeshRenderer[] txt_num;

		private GameObject beam;

		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private InputActionState Fire1;

		private InputActionState Fire2;

		private bool delay => _man.GunRat_delay;

		private int ammo
		{
			get
			{
				return _man.GunRat_ammo;
			}
			set
			{
				_man.GunRat_ammo = value;
			}
		}

		private void RefreshCounter()
		{
			if (isActive)
			{
				MeshRenderer[] array = txt_num;
				for (int i = 0; i < array.Length; i++)
				{
					Renderer val = (Renderer)(object)array[i];
					val.enabled = false;
				}
				((Renderer)txt_num[_man.GunRat_ammo]).enabled = true;
			}
		}

		private void OnEnable()
		{
			isActive = true;
			InitializeFields();
			RefreshCounter();
			((Renderer)txt_num[_man.GunRat_ammo]).enabled = true;
			try
			{
				CheatsManager instance = MonoSingleton<CheatsManager>.Instance;
				cooldownOff = instance != null && instance.GetCheatState("ultrakill.no-weapon-cooldown");
			}
			catch
			{
				cooldownOff = false;
			}
			((UnityEvent<string>)(object)Events.CheatStateChanged).AddListener((UnityAction<string>)OnCheatChange);
		}

		private void OnDisable()
		{
			isActive = false;
			((UnityEvent<string>)(object)Events.CheatStateChanged).RemoveListener((UnityAction<string>)OnCheatChange);
		}

		private void Update()
		{
			//IL_00c8: 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)
			if (!MonoSingleton<OptionsManager>.Instance.paused && Fire1.WasPerformedThisFrame && ammo > 0 && (cooldownOff || !delay))
			{
				((Renderer)txt_num[ammo]).enabled = false;
				if (!cooldownOff)
				{
					ammo--;
					Delay();
				}
				((Renderer)txt_num[ammo]).enabled = true;
				GameObject val = Object.Instantiate<GameObject>(beam);
				val.GetComponent<RevolverBeam>().sourceWeapon = ((Component)this).gameObject;
				val.transform.position = ((Component)origin).transform.position;
				val.transform.rotation = ((Component)MonoSingleton<CameraController>.Instance).transform.rotation;
			}
		}

		private void Delay()
		{
			((MonoBehaviour)_man).StartCoroutine(_man.GunDelay(0.28f));
		}

		private void InitializeFields()
		{
			Refresh = RefreshCounter;
			if ((Object)(object)origin == (Object)null)
			{
				origin = ((Component)this).transform.Find("RAT/gun/MuzzleOrigin");
			}
			if (txt_num == null)
			{
				txt_num = ((Component)((Component)this).transform.Find("RAT/gun/Screen/TEXT/NUM")).gameObject.GetComponentsInChildren<MeshRenderer>();
			}
			if ((Object)(object)beam == (Object)null)
			{
				beam = AssetLoader.AssetFind<GameObject>("Revolver Beam Alternative.prefab");
			}
		}

		private void OnCheatChange(string cheat)
		{
			cooldownOff = MonoSingleton<CheatsManager>.Instance.GetCheatState("ultrakill.no-weapon-cooldown");
		}

		public GunScript()
		{
			InputManager instance = MonoSingleton<InputManager>.Instance;
			Fire1 = ((instance != null) ? instance.InputSource.Fire1 : null);
			InputManager instance2 = MonoSingleton<InputManager>.Instance;
			Fire2 = ((instance2 != null) ? instance2.InputSource.Fire2 : null);
			((MonoBehaviour)this)..ctor();
		}
	}
}
namespace RatMod.Weapon_Scripts.Object_Scripts
{
	public class ExplosionFixer : MonoBehaviour
	{
		public GameObject sourceWeapon = null;

		private void Start()
		{
			Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren<Explosion>();
			foreach (Explosion val in componentsInChildren)
			{
				val.enemy = false;
				val.sourceWeapon = sourceWeapon;
			}
		}
	}
	public class KnifeObject : MonoBehaviour
	{
		public double timeLeft;

		private readonly float DAMAGE = 0.2f;

		private LayerMask mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[2] { "Environment", "Outdoors" }));

		private bool _enabled = false;

		private bool _traveling = false;

		private bool _attached = false;

		private bool _findingTarget = false;

		private bool _hurting = false;

		private EnemyIdentifier Target;

		private NavMeshAgent agent;

		private Rigidbody rb;

		private EnemyIdentifier CachedEnemy;

		public void Awake()
		{
			rb = ((Component)this).GetComponent<Rigidbody>();
			agent = ((Component)this).GetComponent<NavMeshAgent>();
			agent.areaMask = 13;
			((Component)this).gameObject.AddComponent<DestroyOnCheckpointRestart>();
		}

		public void OnDisable()
		{
			GreechKnife.ActiveKnife = null;
		}

		public void Start()
		{
			((Behaviour)agent).enabled = true;
		}

		public void OnTriggerEnter(Collider collider)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (LayerMask.op_Implicit(mask) == (LayerMask.op_Implicit(mask) | (1 << ((Component)collider).gameObject.layer)) && !_attached)
			{
				_enabled = true;
				_traveling = true;
			}
			if (((Component)collider).gameObject.layer == 12 && !_attached)
			{
				_enabled = true;
				rb.isKinematic = true;
				_traveling = false;
				((Component)this).transform.parent = ((Component)collider).transform;
				_attached = true;
				Target = ((Component)collider).GetComponentInChildren<EnemyIdentifier>() ?? ((Component)collider).GetComponentInChildren<EnemyIdentifierIdentifier>().eid;
				if (!_hurting)
				{
					_hurting = true;
					CachedEnemy = Target;
					((MonoBehaviour)this).Invoke("Damage", 0.25f);
				}
			}
			((Behaviour)agent).enabled = _traveling;
		}

		public void Update()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (timeLeft <= 0.0)
			{
				_enabled = false;
				GreechKnife.ActiveKnife = null;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			if (_enabled)
			{
				timeLeft -= Time.deltaTime;
				if ((Object)(object)Target != (Object)null && Target.dead)
				{
					Target = null;
					_traveling = true;
					((Component)this).transform.parent = null;
					_attached = false;
					((Behaviour)agent).enabled = _traveling;
					agent.SetDestination(((Component)this).transform.position);
				}
				if ((Object)(object)Target == (Object)null)
				{
					FindTarget();
				}
				if (_traveling)
				{
					Travel();
				}
			}
		}

		private void FindTarget()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (_findingTarget)
			{
				return;
			}
			_findingTarget = true;
			if ((Object)(object)((Component)this).transform.parent != (Object)null)
			{
				Target = ((Component)((Component)this).transform.parent).GetComponentInChildren<EnemyIdentifier>() ?? ((Component)((Component)this).transform.parent).GetComponentInChildren<EnemyIdentifierIdentifier>().eid;
				if (Object.op_Implicit((Object)(object)Target))
				{
					return;
				}
			}
			EnemyIdentifier[] array = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().ToArray();
			if (array.Length == 0)
			{
				return;
			}
			Dictionary<float, int> dictionary = new Dictionary<float, int>();
			for (int i = 0; i < array.Length; i++)
			{
				agent.SetDestination(((Component)array[i]).transform.position);
				if (agent.hasPath)
				{
					float key = Vector3.Distance(((Component)this).transform.position, ((Component)array[i]).transform.position);
					if (!dictionary.ContainsKey(key))
					{
						dictionary.Add(key, i);
					}
				}
			}
			if (dictionary.Count > 0)
			{
				Target = array[dictionary[dictionary.Min((KeyValuePair<float, int> k) => k.Key)]];
				agent.SetDestination(((Component)Target).transform.position);
			}
			_findingTarget = false;
		}

		private void Travel()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Target) && !Target.dead)
			{
				agent.SetDestination(((Component)Target).transform.position);
				if (agent.remainingDistance < 8f)
				{
					((Behaviour)agent).enabled = false;
					_traveling = false;
					((MonoBehaviour)this).StartCoroutine(Jump());
				}
			}
		}

		private IEnumerator Jump()
		{
			float jumpTime = 0f;
			Vector3 startPos = ((Component)this).transform.position;
			Vector3 target = default(Vector3);
			bool isWeakpoint = Object.op_Implicit((Object)(object)Target.weakPoint);
			while (Object.op_Implicit((Object)(object)Target) && !Target.dead && Vector3.Distance(((Component)this).transform.position, target) > 0.2f)
			{
				target = ((!isWeakpoint) ? ((Component)Target).transform.position : Target.weakPoint.transform.position);
				jumpTime += Time.fixedDeltaTime;
				float mix = 10f * Mathf.Log10(jumpTime + 1f);
				((Component)this).transform.position = Vector3.Lerp(startPos, target, mix);
				yield return (object)new WaitForFixedUpdate();
			}
			if (_attached && !_hurting)
			{
				_hurting = true;
				CachedEnemy = Target;
				((MonoBehaviour)this).Invoke("Damage", 0.25f);
			}
			yield return null;
		}

		private void Damage()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			_hurting = true;
			if ((Object)(object)CachedEnemy != (Object)(object)Target)
			{
				_hurting = false;
				return;
			}
			if ((Object)(object)Target != (Object)null && !Target.dead)
			{
				Target.DeliverDamage(((Component)Target).gameObject, default(Vector3), ((Component)this).transform.position, DAMAGE, false, 0f, (GameObject)null, false);
				if (Target.dead)
				{
					_hurting = false;
					return;
				}
				((MonoBehaviour)this).Invoke("Damage", 0.25f);
			}
			_hurting = false;
		}

		public void Recall()
		{
			_enabled = false;
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class ProjectileScript : MonoBehaviour
	{
		public GameObject sourceWeapon = null;

		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private LayerMask mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Environment", "Outdoors", "EnemyTrigger", "BigCorpse" }));

		private Rigidbody rb;

		private Projectile proj;

		private Transform part1;

		private Transform part2;

		private Transform part3;

		private void Start()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			rb = ((Component)this).GetComponent<Rigidbody>();
			proj = ((Component)this).gameObject.AddComponent<Projectile>();
			part1 = ((Component)this).transform.Find("Component-1");
			part2 = ((Component)this).transform.Find("Component-2");
			part3 = ((Component)this).transform.Find("Component-3");
			GraphicsUtilities.RenderObject<Projectile>(proj, LayerMask.op_Implicit(LayerMask.NameToLayer("Projectile")));
			proj.target = FindTarget();
			SetProjectile();
		}

		private void Update()
		{
			//IL_0007: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			part1.rotation = Random.rotation;
			part2.rotation = Random.rotation;
			part3.rotation = Random.rotation;
			((Component)part1).transform.position = ((Component)this).transform.position;
			((Component)part2).transform.position = ((Component)this).transform.position;
			((Component)part3).transform.position = ((Component)this).transform.position;
		}

		private void SetProjectile()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			proj.damage = 15f;
			proj.speed = 20f;
			proj.turningSpeedMultiplier = 1f;
			proj.decorative = false;
			proj.undeflectable = false;
			proj.friendly = true;
			proj.playerBullet = true;
			proj.bulletType = "HomingGun";
			proj.weaponType = "Rat";
			proj.explosive = true;
			proj.bigExplosion = true;
			proj.explosionEffect = _man.Asset_MindflayerExplosion;
			if ((Object)(object)proj.target != (Object)null)
			{
				proj.homingType = (HomingType)2;
			}
			proj.explosionEffect.AddComponent<ExplosionFixer>().sourceWeapon = sourceWeapon;
			Grenade val = ((Component)this).gameObject.AddComponent<Grenade>();
			val.explosion = proj.explosionEffect;
			val.superExplosion = proj.explosionEffect;
			val.enemy = false;
			val.rideable = false;
			val.rocket = false;
			val.hitterWeapon = "Rat";
			val.sourceWeapon = ((Component)this).gameObject;
		}

		private Transform FindTarget()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00fb: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			if (MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().Count == 0)
			{
				return null;
			}
			Vector3 val = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)MonoSingleton<CameraController>.Instance).transform.position + ((Component)MonoSingleton<CameraController>.Instance).transform.forward, ((Component)MonoSingleton<CameraController>.Instance).transform.forward, ref val2, float.PositiveInfinity, LayerMask.op_Implicit(mask)))
			{
				val = ((RaycastHit)(ref val2)).point;
			}
			SortedDictionary<float, int> sortedDictionary = new SortedDictionary<float, int>();
			EnemyIdentifier[] array = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				sortedDictionary.Add(Vector3.Distance(((Component)array[i]).transform.position, val), i);
			}
			EnemyIdentifier val3 = new EnemyIdentifier();
			RaycastHit val6 = default(RaycastHit);
			foreach (KeyValuePair<float, int> item in sortedDictionary)
			{
				Vector3 val4 = val;
				Vector3 val5 = ((Component)array[item.Value]).transform.position - val;
				Physics.Raycast(val4, ((Vector3)(ref val5)).normalized, ref val6, float.PositiveInfinity, LayerMask.op_Implicit(mask));
				if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val6)).collider).GetComponent<EnemyIdentifier>()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val6)).collider).GetComponent<EnemyIdentifierIdentifier>()))
				{
					val3 = array[item.Value];
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				EnemyIdentifier val7 = array.Where((EnemyIdentifier n) => (int)n.enemyType == 17).ToArray()?.First();
				if ((Object)(object)val7 != (Object)null)
				{
					return ((Component)val7).transform;
				}
				return null;
			}
			return ((Component)val3).transform;
		}
	}
	public class StatueScript : MonoBehaviour
	{
		public GameObject sourceWeapon;

		private RatVariableManager _man = MonoSingleton<RatVariableManager>.Instance;

		private List<EnemyIdentifier> harmedEnemies;

		private bool active = true;

		private int counter = 0;

		private void Start()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			harmedEnemies = new List<EnemyIdentifier>();
			Object.Instantiate<GameObject>(_man.Asset_PhysicalShockwaveHarmless, ((Component)this).transform.position, Quaternion.identity);
			Explosion componentInChildren = Object.Instantiate<GameObject>(_man.Asset_ExplosionPrime, ((Component)this).transform.position, Quaternion.identity).GetComponentInChildren<Explosion>();
			Explosion componentInChildren2 = Object.Instantiate<GameObject>(_man.Asset_ExplosionSuper, ((Component)this).transform.position, Quaternion.identity).GetComponentInChildren<Explosion>();
			((Component)componentInChildren2).transform.localScale = new Vector3(100f, 100f, 100f);
			componentInChildren.enemyDamageMultiplier = 0f;
			componentInChildren2.enemyDamageMultiplier = 0f;
			float num = Time.deltaTime * 3f;
			((MonoBehaviour)this).Invoke("Deactivate", num);
			foreach (EnemyIdentifier item in MonoSingleton<EnemyTracker>.Instance.GetEnemiesOfType((EnemyType)2))
			{
				Collider component = ((Component)this).GetComponent<Collider>();
				Vector3 val = ((Component)item).transform.position + new Vector3(0f, 8f, 0f);
				Vector3 val2 = component.ClosestPoint(val);
				float num2 = Mathf.Abs(val2.x - val.x);
				float num3 = Mathf.Abs(val2.y - val.y);
				float num4 = Mathf.Abs(val2.z - val.z);
				if (num2 < 3f && num3 < 8f && num4 < 5f)
				{
					item.Explode();
				}
			}
		}

		private void OnTriggerEnter(Collider collider)
		{
			if (!active || !Object.op_Implicit((Object)(object)((Component)collider).gameObject.GetComponentInParent<EnemyIdentifier>()) || harmedEnemies.Contains(((Component)collider).gameObject.GetComponentInParent<EnemyIdentifier>()))
			{
				return;
			}
			EnemyIdentifier componentInParent = ((Component)collider).gameObject.GetComponentInParent<EnemyIdentifier>();
			if (componentInParent.dead)
			{
				return;
			}
			harmedEnemies.Add(componentInParent);
			bool bigEnemy = componentInParent.bigEnemy;
			if (Damage(componentInParent, RatVariableManager.isUnbalanced))
			{
				counter++;
				MonoSingleton<StyleHUD>.Instance.DecayFreshness(sourceWeapon, "ultrakill.exploded", bigEnemy);
			}
			MonoSingleton<StyleHUD>.Instance.DecayFreshness(sourceWeapon, "ultrakill.explosionhit", bigEnemy);
			if (counter != 0)
			{
				if (counter == 1)
				{
					MonoSingleton<StyleHUD>.Instance.AddPoints(350, "<color=green>FRESHLY MURDERED</color>", (GameObject)null, (EnemyIdentifier)null, -1, "", "");
				}
				else
				{
					MonoSingleton<StyleHUD>.Instance.AddPoints(350, $"<color=green>FRESHLY MURDERED x{counter}</color>", (GameObject)null, (EnemyIdentifier)null, -1, "", "");
				}
			}
		}

		private bool Damage(EnemyIdentifier enemy, bool isUnbalanced)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			if (isUnbalanced)
			{
				enemy.Explode();
				if ((int)enemy.enemyType == 21)
				{
					((Component)enemy).GetComponent<Idol>().Death();
				}
				enemy.hitter = "greechStatue";
				return true;
			}
			enemy.DeliverDamage(((Component)enemy).gameObject, Vector3.up, ((Component)enemy).transform.position, 5f, true, 0f, sourceWeapon, false);
			enemy.hitter = "greechStatue";
			if (!enemy.hitterWeapons.Contains("greechStatue"))
			{
				enemy.hitterWeapons.Add("greechStatue");
			}
			if (enemy.dead)
			{
				return true;
			}
			return false;
		}

		private void Deactivate()
		{
			active = false;
		}
	}
	public class TurretScript : MonoBehaviour
	{
		public GameObject sourceWeapon = null;

		private LayerMask mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Environment", "Outdoors", "EnemyTrigger", "BigCorpse" }));

		private Transform gun;

		private Transform origin;

		private GameObject beam;

		private bool cooldownOff;

		private readonly float timer = 10f;

		private readonly float fireDelay = 0.5f;

		private float lastFired = Time.time;

		private void Start()
		{
			cooldownOff = MonoSingleton<CheatsManager>.Instance.GetCheatState("ultrakill.no-weapon-cooldown");
			InitializeFields();
			((MonoBehaviour)this).Invoke("DestroySelf", timer);
		}

		private void Update()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			if (!cooldownOff && !(Time.time - fireDelay >= lastFired))
			{
				return;
			}
			bool flag = false;
			EnemyIdentifier val = new EnemyIdentifier();
			Vector3 val2 = default(Vector3);
			EnemyIdentifier[] array = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().ToArray();
			if (array.Length == 0)
			{
				return;
			}
			Dictionary<float, int> dictionary = new Dictionary<float, int>();
			Vector3 val4;
			RaycastHit val5 = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				EnemyIdentifier val3 = array[i];
				if ((int)val3.enemyType == 21 || val3.blessed)
				{
					continue;
				}
				val4 = ((Component)val3).transform.position - gun.position;
				Vector3 normalized = ((Vector3)(ref val4)).normalized;
				if (Object.op_Implicit((Object)(object)val3.weakPoint))
				{
					val4 = val3.weakPoint.transform.position - gun.position;
					normalized = ((Vector3)(ref val4)).normalized;
				}
				Physics.Raycast(gun.position, normalized, ref val5, float.PositiveInfinity, LayerMask.op_Implicit(mask));
				if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).transform).GetComponentInChildren<EnemyIdentifier>()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val5)).transform).GetComponentInChildren<EnemyIdentifierIdentifier>()))
				{
					float key = Vector3.Distance(((Component)this).transform.position, ((Component)val3).transform.position);
					if (!dictionary.ContainsKey(key))
					{
						dictionary.Add(key, i);
					}
				}
			}
			if (dictionary.Count > 0)
			{
				val = array[dictionary[dictionary.Min((KeyValuePair<float, int> v) => v.Key)]];
				Vector3 normalized2;
				if (!Object.op_Implicit((Object)(object)val.weakPoint))
				{
					val4 = ((Component)val).transform.position - gun.position;
					normalized2 = ((Vector3)(ref val4)).normalized;
				}
				else
				{
					val4 = val.weakPoint.transform.position - gun.position;
					normalized2 = ((Vector3)(ref val4)).normalized;
				}
				val2 = normalized2;
				flag = true;
			}
			if (flag)
			{
				gun.rotation = Quaternion.LookRotation(val2);
				GameObject val6 = Object.Instantiate<GameObject>(beam, origin.position, gun.rotation);
				val6.GetComponent<RevolverBeam>().sourceWeapon = sourceWeapon;
				lastFired = Time.time;
			}
		}

		private void InitializeFields()
		{
			if ((Object)(object)gun == (Object)null)
			{
				gun = ((Component)this).transform.Find("RAT/GUN");
			}
			if ((Object)(object)origin == (Object)null)
			{
				origin = ((Component)this).transform.Find("RAT/GUN/BARREL/MuzzleOrigin");
			}
			if ((Object)(object)beam == (Object)null)
			{
				beam = AssetLoader.AssetFind<GameObject>("Revolver Beam Alternative.prefab");
			}
		}

		private void DestroySelf()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
namespace RatMod.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("RatMod.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] petersone1_ratwithagun
		{
			get
			{
				object @object = ResourceManager.GetObject("petersone1_ratwithagun", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace RatMod.Patches
{
	[HarmonyPatch(typeof(NewMovement))]
	public static class NewMovementPatch
	{
		private static readonly float HealthPerAmmo = 10f;

		private static float storedHealth = 0f;

		[HarmonyPatch("GetHealth")]
		[HarmonyPostfix]
		private static void GetHealthPostfix(NewMovement __instance, int health)
		{
			int num = 0;
			storedHealth += health;
			while (storedHealth >= HealthPerAmmo)
			{
				storedHealth -= HealthPerAmmo;
				num++;
			}
			if (Object.op_Implicit((Object)(object)MonoSingleton<RatVariableManager>.Instance))
			{
				MonoSingleton<RatVariableManager>.Instance.GunRat_ammo = Mathf.Clamp(MonoSingleton<RatVariableManager>.Instance.GunRat_ammo + num, 0, 7);
				if (GunScript.isActive)
				{
					GunScript.Refresh();
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier))]
	public static class EnemyIdentifierPatch
	{
		private static readonly float HEAL_DISTANCE = 3f;

		private static readonly float HEAL_AMOUNT = 1.5f;

		[HarmonyPatch("Death")]
		[HarmonyPrefix]
		private static void DeathPrefix(EnemyIdentifier __instance)
		{
			//IL_0049: 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)
			KnifeObject knife = GetKnife(((Component)__instance).transform);
			if (Object.op_Implicit((Object)(object)knife))
			{
				((Component)knife).transform.parent = null;
			}
			GameObject activeKnife = GreechKnife.ActiveKnife;
			knife = ((activeKnife != null) ? activeKnife.GetComponent<KnifeObject>() : null) ?? null;
			if (Object.op_Implicit((Object)(object)knife) && Vector3.Distance(((Component)__instance).transform.position, ((Component)knife).transform.position) < HEAL_DISTANCE)
			{
				knife.timeLeft += HEAL_AMOUNT;
			}
		}

		private static KnifeObject GetKnife(Transform instance)
		{
			KnifeObject result = default(KnifeObject);
			foreach (Transform item in ComponentExt.ListChildren((Component)(object)instance))
			{
				if (((Component)item).TryGetComponent<KnifeObject>(ref result))
				{
					return result;
				}
			}
			return null;
		}
	}
}
namespace RatMod.Cheats.TurretOrb
{
	public class CheatOrb : MonoBehaviour
	{
		private Transform[] arms;

		private LayerMask mask = LayerMask.op_Implicit(LayerMask.GetMask(new string[4] { "Environment", "Outdoors", "EnemyTrigger", "BigCorpse" }));

		private Transform origin;

		private GameObject beam;

		public void Start()
		{
			arms = ((Component)((Component)this).transform.Find("Arms")).GetComponentsInChildren<Transform>();
			InitializeFields();
		}

		public void Update()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_00a5: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			RandomizeArms();
			bool flag = false;
			EnemyIdentifier val = new EnemyIdentifier();
			Vector3 val2 = default(Vector3);
			EnemyIdentifier[] array = MonoSingleton<EnemyTracker>.Instance.GetCurrentEnemies().ToArray();
			if (array.Length == 0)
			{
				return;
			}
			Dictionary<float, int> dictionary = new Dictionary<float, int>();
			Vector3 val4;
			RaycastHit val6 = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				EnemyIdentifier val3 = array[i];
				if ((int)val3.enemyType != 21)
				{
					Vector3 normalized;
					if (!Object.op_Implicit((Object)(object)val3.weakPoint))
					{
						val4 = ((Component)val3).transform.position - origin.position;
						normalized = ((Vector3)(ref val4)).normalized;
					}
					else
					{
						val4 = val3.weakPoint.transform.position - origin.position;
						normalized = ((Vector3)(ref val4)).normalized;
					}
					Vector3 val5 = normalized;
					Physics.Raycast(origin.position, val5, ref val6, float.PositiveInfinity, LayerMask.op_Implicit(mask));
					if (Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val6)).transform).GetComponentInChildren<EnemyIdentifier>()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val6)).transform).GetComponentInChildren<EnemyIdentifierIdentifier>()))
					{
						dictionary.Add(Vector3.Distance(origin.position, ((Component)array[i]).transform.position), i);
					}
				}
			}
			if (dictionary.Count > 0)
			{
				val = array[dictionary[dictionary.Min((KeyValuePair<float, int> v) => v.Key)]];
				Vector3 normalized2;
				if (!Object.op_Implicit((Object)(object)val.weakPoint))
				{
					val4 = ((Component)val).transform.position - origin.position;
					normalized2 = ((Vector3)(ref val4)).normalized;
				}
				else
				{
					val4 = val.weakPoint.transform.position - origin.position;
					normalized2 = ((Vector3)(ref val4)).normalized;
				}
				val2 = normalized2;
				flag = true;
			}
			if (flag)
			{
				Object.Instantiate<GameObject>(beam, origin.position, Quaternion.LookRotation(val2));
			}
		}

		private void RandomizeArms()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = arms;
			foreach (Transform val in array)
			{
				val.rotation *= Random.rotation;
			}
		}

		private void InitializeFields()
		{
			if ((Object)(object)origin == (Object)null)
			{
				origin = ((Component)this).transform.Find("Origin");
			}
			if ((Object)(object)beam == (Object)null)
			{
				beam = AssetLoader.AssetFind<GameObject>("Revolver Beam Alternative.prefab");
			}
		}
	}
	public static class OrbEnabler
	{
		public static GameObject activeOrb;

		public static Cheat cheat;

		private static void Enable()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			activeOrb = Object.Instantiate<GameObject>(MonoSingleton<RatVariableManager>.Instance.assetBundle.LoadAsset<GameObject>("turretorb.prefab"), ((Component)MonoSingleton<NewMovement>.Instance).transform.position + new Vector3(0f, 5f, 0f), Quaternion.identity, ((Component)MonoSingleton<NewMovement>.Instance).transform);
			GraphicsUtilities.RenderObject<Transform>(activeOrb.transform, LayerMask.op_Implicit(LayerMask.NameToLayer("Outdoors")));
		}

		private static void Disable()
		{
			Object.Destroy((Object)(object)activeOrb);
		}

		private static void OnUpdate()
		{
		}

		static OrbEnabler()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			Cheat val = new Cheat();
			val.LongName = "Gun Orb";
			val.Identifier = "RATWITHAGUN.gun_orb";
			val.ButtonEnabledOverride = "Orb Active";
			val.ButtonDisabledOverride = "Orb Inactive";
			val.DefaultState = false;
			val.PersistenceMode = (StatePersistenceMode)1;
			val.EnableScript = Enable;
			val.DisableScript = Disable;
			val.UpdateScript = OnUpdate;
			cheat = val;
		}
	}
}