Decompiled source of BurstLikeGlueGun v1.0.0

Hikaria.BurstLikeGlueGun.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using Gear;
using HarmonyLib;
using Hikaria.BurstLikeGlueGun;
using Il2CppInterop.Runtime.InteropTypes;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Hikaria.BurstLikeGlueGun")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Hikaria.BurstLikeGlueGun")]
[assembly: AssemblyTitle("Hikaria.BurstLikeGlueGun")]
[assembly: AssemblyVersion("1.0.0.0")]
internal static class Logs
{
	public static void LogDebug(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogDebug(data);
	}

	public static void LogError(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogError(data);
	}

	public static void LogFatal(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogFatal(data);
	}

	public static void LogInfo(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogInfo(data);
	}

	public static void LogMessage(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogMessage(data);
	}

	public static void LogWarning(object data)
	{
		((BasePlugin)EntryPoint.Instance).Log.LogWarning(data);
	}
}
namespace Hikaria.BurstLikeGlueGun;

[BepInPlugin("Hikaria.BurstLikeGlueGun", "BurstLikeGlueGun", "1.0.0")]
public class EntryPoint : BasePlugin
{
	private Harmony m_Harmony;

	public static EntryPoint Instance { get; private set; }

	public override void Load()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		Instance = this;
		m_Harmony = new Harmony("Hikaria.BurstLikeGlueGun");
		m_Harmony.PatchAll();
		Logs.LogMessage("OK");
	}
}
[HarmonyPatch(typeof(BulletWeaponArchetype))]
public class Patch__BWA_Burst
{
	[HarmonyPatch("Update")]
	private static bool Prefix(BulletWeaponArchetype __instance)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Invalid comparison between Unknown and I4
		if ((int)__instance.m_archetypeData.FireMode != 1)
		{
			return true;
		}
		Update(((Il2CppObjectBase)__instance).TryCast<BWA_Burst>());
		return false;
	}

	private static void Update(BWA_Burst __instance)
	{
		//IL_005b: 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_00d8: Invalid comparison between Unknown and I4
		if (__instance == null || (Object)(object)((BulletWeaponArchetype)__instance).m_owner == (Object)null)
		{
			return;
		}
		bool flag = !((BulletWeaponArchetype)__instance).m_owner.Locomotion.IsRunning && !((BulletWeaponArchetype)__instance).m_owner.Locomotion.IsInAir;
		((BulletWeaponArchetype)__instance).m_fireHeld = flag && (((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).FireButton || (InputMapper.HasGamepad && InputMapper.GetAxisKeyMouseGamepad((InputAction)47, ((BulletWeaponArchetype)__instance).m_owner.InputFilter) > 0f));
		if (flag && ((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).FireButtonPressed)
		{
			((BulletWeaponArchetype)__instance).m_firePressed = true;
		}
		else if (((BulletWeaponArchetype)__instance).m_fireHeld && ((BulletWeaponArchetype)__instance).m_firePressed)
		{
			((BulletWeaponArchetype)__instance).m_firePressed = false;
		}
		if (((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).IsEnabled || (((BulletWeaponArchetype)__instance).m_owner.FPItemHolder.ItemDownTrigger && (int)((BulletWeaponArchetype)__instance).m_archetypeData.FireMode == 1 && !((BulletWeaponArchetype)__instance).BurstIsDone()))
		{
			((BulletWeaponArchetype)__instance).m_clip = ((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).GetCurrentClip();
			bool flag2 = (((((BulletWeaponArchetype)__instance).HasChargeup && ((BulletWeaponArchetype)__instance).m_inChargeup) || !((BulletWeaponArchetype)__instance).m_triggerNeedsPress) ? ((BulletWeaponArchetype)__instance).m_fireHeld : ((BulletWeaponArchetype)__instance).m_firePressed);
			if (!((BulletWeaponArchetype)__instance).m_inChargeup && !((BulletWeaponArchetype)__instance).m_firing && flag2 && Clock.Time > ((BulletWeaponArchetype)__instance).m_nextBurstTimer)
			{
				if (((BulletWeaponArchetype)__instance).m_clip > 0f)
				{
					if (((BulletWeaponArchetype)__instance).HasChargeup)
					{
						((BulletWeaponArchetype)__instance).m_chargeupTimer = Clock.Time + ((BulletWeaponArchetype)__instance).ChargeupDelay();
						((BulletWeaponArchetype)__instance).m_inChargeup = true;
						((BulletWeaponArchetype)__instance).m_readyToFire = false;
						((BulletWeaponArchetype)__instance).m_weapon.TriggerAudioChargeup();
						((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).FPItemHolder.DontRelax();
						GuiManager.CrosshairLayer.SetChargeUpVisibleAndProgress(true, 0f);
					}
					else
					{
						((BulletWeaponArchetype)__instance).m_chargeupTimer = 0f;
						((BulletWeaponArchetype)__instance).m_inChargeup = false;
						GuiManager.CrosshairLayer.SetChargeUpVisibleAndProgress(false, 0f);
						((BulletWeaponArchetype)__instance).m_readyToFire = true;
					}
				}
				else if (((BulletWeaponArchetype)__instance).m_firePressed)
				{
					if (!((BulletWeaponArchetype)__instance).m_clickTriggered || !CellSettingsManager.SettingsData.Gameplay.AutoReload.Value || !((PlayerInventoryBase)((Weapon)((BulletWeaponArchetype)__instance).m_weapon).m_inventory).CanReloadCurrent())
					{
						((BulletWeaponArchetype)__instance).m_weapon.TriggerAudio(((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).AudioData.eventClick);
						((BulletWeaponArchetype)__instance).m_nextShotTimer = Clock.Time + ((BulletWeaponArchetype)__instance).ShotDelay();
						((BulletWeaponArchetype)__instance).m_clickTriggered = true;
					}
					else if (((BulletWeaponArchetype)__instance).m_clickTriggered && CellSettingsManager.SettingsData.Gameplay.AutoReload.Value && ((PlayerInventoryBase)((Weapon)((BulletWeaponArchetype)__instance).m_weapon).m_inventory).CanReloadCurrent())
					{
						((PlayerInventoryBase)((Weapon)((BulletWeaponArchetype)__instance).m_weapon).m_inventory).TriggerReload();
						((BulletWeaponArchetype)__instance).m_clickTriggered = false;
					}
					if (((BulletWeaponArchetype)__instance).m_clip <= 0f && !((PlayerInventoryBase)((Weapon)((BulletWeaponArchetype)__instance).m_weapon).m_inventory).CanReloadCurrent())
					{
						((Weapon)((BulletWeaponArchetype)__instance).m_weapon).m_wasOutOfAmmo = true;
					}
				}
				if (((BulletWeaponArchetype)__instance).m_firePressed)
				{
					((BulletWeaponArchetype)__instance).m_firePressed = false;
				}
			}
			if (((BulletWeaponArchetype)__instance).m_inChargeup)
			{
				if (!((BulletWeaponArchetype)__instance).m_fireHeld)
				{
					int num = Mathf.FloorToInt(Mathf.Clamp01(1f - (((BulletWeaponArchetype)__instance).m_chargeupTimer - Clock.Time) / ((BulletWeaponArchetype)__instance).ChargeupDelay()) * (float)__instance.m_burstMax);
					if (num == 0 || num == __instance.m_burstMax)
					{
						((BulletWeaponArchetype)__instance).OnStopChargeup();
						((BulletWeaponArchetype)__instance).m_nextShotTimer = Clock.Time + ((BulletWeaponArchetype)__instance).ShotDelay();
						return;
					}
					((BulletWeaponArchetype)__instance).m_inChargeup = false;
					((BulletWeaponArchetype)__instance).m_readyToFire = true;
					GuiManager.CrosshairLayer.SetChargeUpVisibleAndProgress(false, 0f);
					OnStartFiring(__instance, num);
					goto IL_03c6;
				}
				float num2 = 1f - (((BulletWeaponArchetype)__instance).m_chargeupTimer - Clock.Time) / ((BulletWeaponArchetype)__instance).ChargeupDelay();
				GuiManager.CrosshairLayer.SetChargeUpVisibleAndProgress(true, num2);
				if (Clock.Time >= ((BulletWeaponArchetype)__instance).m_chargeupTimer)
				{
					((BulletWeaponArchetype)__instance).m_inChargeup = false;
					((BulletWeaponArchetype)__instance).m_readyToFire = true;
					GuiManager.CrosshairLayer.SetChargeUpVisibleAndProgress(false, 0f);
				}
			}
			if (((BulletWeaponArchetype)__instance).m_readyToFire && !((BulletWeaponArchetype)__instance).m_firing)
			{
				((BulletWeaponArchetype)__instance).OnStartFiring();
			}
			goto IL_03c6;
		}
		if (((BulletWeaponArchetype)__instance).m_inChargeup)
		{
			((BulletWeaponArchetype)__instance).OnStopChargeup();
		}
		if (((BulletWeaponArchetype)__instance).m_firing)
		{
			((BulletWeaponArchetype)__instance).OnStopFiring();
		}
		return;
		IL_03c6:
		if (((BulletWeaponArchetype)__instance).PreFireCheck())
		{
			if (((BulletWeaponArchetype)__instance).m_readyToFire && ((BulletWeaponArchetype)__instance).m_firing && Clock.Time > ((BulletWeaponArchetype)__instance).m_nextShotTimer)
			{
				if (((BulletWeaponArchetype)__instance).m_clip > 0f)
				{
					((BulletWeaponArchetype)__instance).OnFireShot();
					((BulletWeaponArchetype)__instance).m_nextShotTimer = Clock.Time + ((BulletWeaponArchetype)__instance).ShotDelay();
				}
				else
				{
					((BulletWeaponArchetype)__instance).OnStopFiring();
					((BulletWeaponArchetype)__instance).OnFireShotEmptyClip();
					((BulletWeaponArchetype)__instance).m_nextShotTimer = Clock.Time + ((BulletWeaponArchetype)__instance).ShotDelay();
				}
				((BulletWeaponArchetype)__instance).PostFireCheck();
			}
		}
		else if (((BulletWeaponArchetype)__instance).m_firing)
		{
			((BulletWeaponArchetype)__instance).OnStopFiring();
		}
	}

	private static void OnStartFiring(BWA_Burst __instance, int count)
	{
		((BulletWeaponArchetype)__instance).OnStartFiring();
		int currentClip = ((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).GetCurrentClip();
		__instance.m_burstCurrentCount = Mathf.Min(__instance.m_burstMax, Mathf.Min(count, currentClip));
		if (currentClip >= __instance.m_burstMax && !((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).AudioData.TriggerBurstAudioForEachShot)
		{
			((BulletWeaponArchetype)__instance).m_weapon.TriggerBurstFireAudio();
			((ItemEquippable)((BulletWeaponArchetype)__instance).m_weapon).FPItemHolder.DontRelax();
		}
	}
}
public static class PluginInfo
{
	public const string GUID = "Hikaria.BurstLikeGlueGun";

	public const string NAME = "BurstLikeGlueGun";

	public const string VERSION = "1.0.0";
}