Decompiled source of frenchHuntsman v1.1.0

ineedmorebullet.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("angryduck")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("angryduck")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("177ce422-ce2b-4a69-838c-55bec10d7e7f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("atomiclabs.INeedMoreBulletHunter", "INeedMoreBullet Hunter", "1.0.0")]
public class INeedMoreBulletHunterMod : BaseUnityPlugin
{
	public const string modGUID = "atomiclabs.INeedMoreBulletHunter";

	public const string modName = "INeedMoreBullet Hunter";

	public const string modVersion = "1.0.0";

	public static INeedMoreBulletHunterMod instance;

	internal ManualLogSource logger;

	public AudioClip soundAimStartGlobal;

	public AudioClip soundAimStart;

	public AudioClip soundReload01;

	public AudioClip soundReload02;

	public AudioClip soundStun;

	private AssetBundle bundle;

	private void Awake()
	{
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Expected O, but got Unknown
		logger = ((BaseUnityPlugin)this).Logger;
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
			logger.LogInfo((object)"Loading INeedMoreBullet Hunter mod...");
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "ineedmorebullethunter");
			logger.LogInfo((object)("Attempting to load asset bundle from: " + text));
			bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)bundle == (Object)null)
			{
				logger.LogError((object)("Failed to load asset bundle at: " + text + "!"));
				return;
			}
			logger.LogInfo((object)("Successfully loaded asset bundle from: " + text));
			logger.LogInfo((object)"Checking available assets in the bundle...");
			string[] allAssetNames = bundle.GetAllAssetNames();
			foreach (string text2 in allAssetNames)
			{
				logger.LogInfo((object)("Asset found: " + text2));
			}
			soundAimStartGlobal = bundle.LoadAsset<AudioClip>("aimStartGlobalSound");
			if ((Object)(object)soundAimStartGlobal != (Object)null)
			{
				logger.LogInfo((object)("Loaded sound: " + ((Object)soundAimStartGlobal).name));
			}
			else
			{
				logger.LogError((object)"Failed to load aimStartGlobalSound!");
			}
			soundAimStart = bundle.LoadAsset<AudioClip>("aimStartSound");
			if ((Object)(object)soundAimStart != (Object)null)
			{
				logger.LogInfo((object)("Loaded sound: " + ((Object)soundAimStart).name));
			}
			else
			{
				logger.LogError((object)"Failed to load aimStartSound!");
			}
			soundReload01 = bundle.LoadAsset<AudioClip>("reload01Sound");
			if ((Object)(object)soundReload01 != (Object)null)
			{
				logger.LogInfo((object)("Loaded sound: " + ((Object)soundReload01).name));
			}
			else
			{
				logger.LogError((object)"Failed to load reload01Sound!");
			}
			soundReload02 = bundle.LoadAsset<AudioClip>("reload02Sound");
			if ((Object)(object)soundReload02 != (Object)null)
			{
				logger.LogInfo((object)("Loaded sound: " + ((Object)soundReload02).name));
			}
			else
			{
				logger.LogError((object)"Failed to load reload02Sound!");
			}
			soundStun = bundle.LoadAsset<AudioClip>("stunSound");
			if ((Object)(object)soundStun != (Object)null)
			{
				logger.LogInfo((object)("Loaded sound: " + ((Object)soundStun).name));
			}
			else
			{
				logger.LogError((object)"Failed to load stunSound!");
			}
			if ((Object)(object)soundAimStartGlobal != (Object)null && (Object)(object)soundAimStart != (Object)null && (Object)(object)soundReload01 != (Object)null && (Object)(object)soundReload02 != (Object)null && (Object)(object)soundStun != (Object)null)
			{
				logger.LogInfo((object)"All audio clips loaded successfully, applying Harmony patches...");
				Harmony val = new Harmony("atomiclabs.INeedMoreBulletHunter");
				val.PatchAll();
			}
			else
			{
				logger.LogError((object)"Not all audio clips were loaded. Patches will not be applied.");
			}
		}
		else
		{
			Object.Destroy((Object)(object)this);
		}
	}

	public void PlaySound(AudioClip clip, Vector3 position)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		AudioSource.PlayClipAtPoint(clip, position);
	}
}
namespace INeedMoreBulletHunter.Patches;

[HarmonyPatch(typeof(EnemyHunterAnim), "AimStart")]
internal class AimStartPatch
{
	private static bool Prefix(EnemyHunterAnim __instance)
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)INeedMoreBulletHunterMod.instance.soundAimStart != (Object)null && (Object)(object)INeedMoreBulletHunterMod.instance.soundAimStartGlobal != (Object)null)
		{
			__instance.soundAimStart.Sounds[0] = INeedMoreBulletHunterMod.instance.soundAimStart;
			__instance.soundAimStartGlobal.Sounds[0] = INeedMoreBulletHunterMod.instance.soundAimStartGlobal;
			INeedMoreBulletHunterMod.instance.logger.LogInfo((object)("[AUDIO] Replacing AimStart sounds with custom sounds: " + ((Object)INeedMoreBulletHunterMod.instance.soundAimStart).name + ", " + ((Object)INeedMoreBulletHunterMod.instance.soundAimStartGlobal).name));
		}
		else
		{
			INeedMoreBulletHunterMod.instance.logger.LogError((object)"[AUDIO] Custom aim start sounds not loaded.");
		}
		__instance.soundAimStart.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		__instance.soundAimStartGlobal.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		return false;
	}
}
[HarmonyPatch(typeof(EnemyHunterAnim), "Reload01")]
internal class Reload01Patch
{
	private static bool Prefix(EnemyHunterAnim __instance)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)INeedMoreBulletHunterMod.instance.soundReload01 != (Object)null)
		{
			__instance.soundReload01.Sounds[0] = INeedMoreBulletHunterMod.instance.soundReload01;
			INeedMoreBulletHunterMod.instance.logger.LogInfo((object)("[AUDIO] Replacing Reload01 sound with custom sound: " + ((Object)INeedMoreBulletHunterMod.instance.soundReload01).name));
			__instance.soundReload01.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}
		else
		{
			INeedMoreBulletHunterMod.instance.logger.LogError((object)"[AUDIO] Custom Reload01 sound not loaded.");
		}
		return false;
	}
}
[HarmonyPatch(typeof(EnemyHunterAnim), "Reload02")]
internal class Reload02Patch
{
	private static bool Prefix(EnemyHunterAnim __instance)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)INeedMoreBulletHunterMod.instance.soundReload02 != (Object)null)
		{
			__instance.soundReload02.Sounds[0] = INeedMoreBulletHunterMod.instance.soundReload02;
			INeedMoreBulletHunterMod.instance.logger.LogInfo((object)("[AUDIO] Replacing Reload02 sound with custom sound: " + ((Object)INeedMoreBulletHunterMod.instance.soundReload02).name));
			__instance.soundReload02.Play(__instance.enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}
		else
		{
			INeedMoreBulletHunterMod.instance.logger.LogError((object)"[AUDIO] Custom Reload02 sound not loaded.");
		}
		return false;
	}
}
[HarmonyPatch(typeof(EnemyHunterAnim), "Update")]
internal class UpdateStunPatch
{
	private static Dictionary<EnemyHunterAnim, bool> playedStun = new Dictionary<EnemyHunterAnim, bool>();

	private static void Postfix(EnemyHunterAnim __instance)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		if (!playedStun.ContainsKey(__instance))
		{
			playedStun[__instance] = false;
		}
		if ((int)__instance.enemyHunter.currentState == 11)
		{
			if (!playedStun[__instance])
			{
				if ((Object)(object)INeedMoreBulletHunterMod.instance.soundStun != (Object)null)
				{
					INeedMoreBulletHunterMod.instance.logger.LogInfo((object)("[AUDIO] Playing custom stun sound: " + ((Object)INeedMoreBulletHunterMod.instance.soundStun).name));
					INeedMoreBulletHunterMod.instance.PlaySound(INeedMoreBulletHunterMod.instance.soundStun, __instance.enemy.CenterTransform.position);
				}
				else
				{
					INeedMoreBulletHunterMod.instance.logger.LogError((object)"[AUDIO] Custom stun sound not loaded.");
				}
				playedStun[__instance] = true;
			}
		}
		else
		{
			playedStun[__instance] = false;
		}
	}
}