Decompiled source of Loader Slam Audio Fix v1.0.0

LoaderSlamFix.dll

Decompiled 5 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HG.GeneralSerializer;
using HG.Reflection;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace LoaderSlamFix;

[BepInPlugin("dolso.loaderslamfix", "LoaderSlamFix", "1.0.0")]
internal class Main : BaseUnityPlugin
{
	private void Start()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_006c: 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)
		AkSoundEngine.AddBasePath(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location));
		uint num = default(uint);
		AkSoundEngine.LoadBank("LoaderSlamSoundbank.bnk", ref num);
		SetStateConfigIndex(Addressables.LoadAssetAsync<EntityStateConfiguration>((object)"RoR2/Base/Loader/EntityStates.Loader.PreGroundSlam.asset").WaitForCompletion(), "enterSoundString", "loaderfix_loader_R_variant_activate");
		SetStateConfigIndex(Addressables.LoadAssetAsync<EntityStateConfiguration>((object)"RoR2/Base/Loader/EntityStates.Loader.GroundSlam.asset").WaitForCompletion(), "enterSoundString", "loaderfix_loader_R_variant_whooshDown");
		Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderGroundSlam.prefab").WaitForCompletion().GetComponent<EffectComponent>()
			.soundName = "loaderfix_loader_R_variant_slam";
	}

	private void SetStateConfigIndex(EntityStateConfiguration stateConfig, string fieldName, string newStringValue)
	{
		ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
		for (int i = 0; i < serializedFields.Length; i++)
		{
			if (serializedFields[i].fieldName == fieldName)
			{
				serializedFields[i].fieldValue.stringValue = newStringValue;
				return;
			}
		}
		((BaseUnityPlugin)this).Logger.LogError((object)("failed to find " + fieldName));
	}
}