Decompiled source of NoBlacksmithSounds v1.1.0

plugins/NoBlacksmithSounds.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using UnityEngine;
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("NoBlacksmithSounds")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoBlacksmithSounds")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace NoBlacksmithSounds;

[BepInPlugin("zenethian.noblacksmithsounds", "No Blacksmith Hammer Sounds", "1.0.0")]
public class NoBlacksmithSounds : BaseUnityPlugin
{
	public const string GUID = "zenethian.noblacksmithsounds";

	public const string NAME = "No Blacksmith Hammer Sounds";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	public static NoBlacksmithSounds Instance { get; private set; }

	internal void Awake()
	{
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		SceneManager.sceneLoaded += SceneManager_sceneLoaded;
	}

	internal void SceneManager_sceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (!(((Scene)(ref scene)).name == "LowMemory_TransitionScene") && !(((Scene)(ref scene)).name == "MainMenu_Empty") && !(((Scene)(ref scene)).name == ""))
		{
			((MonoBehaviour)Instance).StartCoroutine(DelayMethod(scene));
		}
	}

	private IEnumerator DelayMethod(Scene scene)
	{
		//IL_000e: 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)
		yield return (object)new WaitForSeconds(5f);
		if (!FixHammerSounds(scene))
		{
			yield return (object)new WaitForSeconds(10f);
			if (!FixHammerSounds(scene))
			{
				yield return (object)new WaitForSeconds(15f);
				FixHammerSounds(scene);
			}
		}
	}

	private bool FixHammerSounds(Scene scene)
	{
		GameObject val = GameObject.Find("HumanSNPC_Blacksmith");
		if ((Object)(object)val != (Object)null)
		{
			Log.LogMessage((object)("De-hammering " + val.GetComponent<SNPC>().LocKey + " in scene " + ((Scene)(ref scene)).name));
			AnimEventPlaySound component = val.GetComponent<AnimEventPlaySound>();
			component.Sounds = Array.Empty<Sounds>();
			return true;
		}
		Log.LogMessage((object)("Nobody to de-hammer in scene " + ((Scene)(ref scene)).name));
		return false;
	}
}