Decompiled source of MyLegSoundMod v1.0.5

plugins/MyLegSoundMod.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MyLegSoundMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyLegSoundMod")]
[assembly: AssemblyTitle("MyLegSoundMod")]
[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 MyLegSoundMod
{
	[BepInPlugin("com.jarias.mylegsoundmod", "MyLeg Sound Mod", "1.0.5")]
	public class MyLegSoundMod : BaseUnityPlugin
	{
		internal static AssetBundle bundle;

		internal static List<AudioClip> sounds;

		internal static AudioClip myLegSound;

		private void Awake()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MyLegSoundMod: Loading bundle...");
			bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "myleg"));
			if ((Object)(object)bundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"MyLegSoundMod: Failed to load bundle.");
				return;
			}
			sounds = bundle.LoadAllAssets<AudioClip>().ToList();
			myLegSound = sounds.FirstOrDefault();
			if ((Object)(object)myLegSound != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("MyLegSoundMod: Loaded clip: " + ((Object)myLegSound).name));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"MyLegSoundMod: No AudioClip found in bundle.");
			}
			new Harmony("com.jarias.mylegsoundmod").PatchAll();
		}
	}
}
namespace MyLegSoundMod.Patches
{
	[HarmonyPatch(typeof(PlayerDeathEffects))]
	[HarmonyPatch("Start")]
	public class PlayerDeathEffectsPatch
	{
		[HarmonyPostfix]
		public static void Postfix(PlayerDeathEffects __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)MyLegSoundMod.myLegSound != (Object)null)
			{
				__instance.deathSound.Sounds = (AudioClip[])(object)new AudioClip[1] { MyLegSoundMod.myLegSound };
				Debug.Log((object)"MyLegSoundMod: Replaced death sound.");
			}
			else
			{
				Debug.LogWarning((object)"MyLegSoundMod: Could not replace death sound — something is null.");
			}
		}
	}
}