Decompiled source of Old Combat Music Fix v1.0.0

plugins/OldCombatMusicFix.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AssetShards;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using StateMachines;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OldCombat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OldCombat")]
[assembly: AssemblyTitle("OldCombat")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace OldCombat
{
	[BepInPlugin("com.easternunit.old_combat", "OldCombatMusic", "0.0.1")]
	public class Class1 : BasePlugin
	{
		[HarmonyPatch(typeof(AkBankManager), "LoadBank")]
		public class Patch_AkBankManager
		{
			public static bool Prefix(string name, bool decodeBank, bool saveDecodedBank)
			{
				int num = ((name != "music") ? 1 : 0);
				if (num != 0)
				{
					return num != 0;
				}
				DebgLogger.LogMessage((object)"Prevented from loading old music.bnk!!");
				return num != 0;
			}
		}

		public const string MODNAME = "OldCombatMusic";

		public const string GUID = "com.easternunit.old_combat";

		public const string VERSION = "1.0.0";

		public static bool Unloaded = false;

		public static ManualLogSource DebgLogger = Logger.CreateLogSource("OldCombatMusic");

		public override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.easternunit.old_combat").PatchAll();
			AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)RemoveVanillaMusicBnk);
		}

		public static void RemoveVanillaMusicBnk()
		{
			//IL_0065: 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_007b: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			if (Unloaded)
			{
				return;
			}
			Unloaded = true;
			AkBankManager.UnloadBank("music");
			MusicManager.Machine.Sound.Stop();
			int num = (int)MusicManager.Machine.Sound.Post("music_start", true);
			CellSound.SetGlobalRTPCValue(100663314u, CellSettingsManager.SettingsData.Audio.MusicVolume.Value * 100f);
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(7, (MUS_Base)new MUS_CombatRegular());
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(20, (MUS_Base)new MUS_CombatHidden());
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(19, (MUS_Base)new MUS_CombatRegular());
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(18, (MUS_Base)new MUS_CombatHidden());
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(10, (MUS_Base)new MUS_CombatRegular());
			((StateMachine<MUS_Base>)(object)MusicManager.Machine).AddState(11, (MUS_Base)new MUS_CombatHidden());
			for (int i = 0; i < ((StateMachine<MUS_Base>)(object)MusicManager.Machine).m_states.Length; i++)
			{
				if (((StateMachine<MUS_Base>)(object)MusicManager.Machine).m_states[i] != null)
				{
					((StateMachine<MUS_Base>)(object)MusicManager.Machine).m_states[i].SetMachine(MusicManager.Machine);
				}
			}
		}
	}
}