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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("PlayerLegoBrickDeathSound")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlayerLegoBrickDeathSound")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("14da8466-ea98-41d4-9ac2-1d49b68c0559")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PlayerLegoBrickDeathSound
{
[BepInPlugin("rKzenta.LegoBrickDeath", "LegoBrickDeath", "1.0.0")]
public class PlayerLegoBrickDeathBase : BaseUnityPlugin
{
internal static PlayerLegoBrickDeathBase Instance;
internal List<AudioClip> Sounds = new List<AudioClip>();
private readonly Harmony _harmony = new Harmony("rKzenta.LegoBrickDeath");
public void Awake()
{
if (Instance == null)
{
Instance = this;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"rKzenta.LegoBrickDeath loading...");
_harmony.PatchAll(typeof(PlayerLegoBrickDeathBase));
_harmony.PatchAll(typeof(PlayerAvatarPatch));
_harmony.PatchAll(typeof(PlayerDeathEffectsPatch));
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(new FileInfo(((BaseUnityPlugin)this).Info.Location).Directory?.FullName ?? "", "soundfx"));
if (val == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load audio asset!");
return;
}
Sounds = val.LoadAllAssets<AudioClip>().ToList();
((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded " + Sounds.Count + " sounds from asset bundle! First sounds: " + ((Object)Sounds[0]).name));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded LegoBrickDeath mod");
}
}
[HarmonyPatch(typeof(PlayerAvatar))]
public class PlayerAvatarPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Postfix(PlayerAvatar __instance)
{
__instance.deathSound.Sounds = PlayerLegoBrickDeathBase.Instance.Sounds.ToArray();
}
}
[HarmonyPatch(typeof(PlayerDeathEffects))]
public class PlayerDeathEffectsPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Postfix(PlayerDeathEffects __instance)
{
__instance.deathSound.Sounds = PlayerLegoBrickDeathBase.Instance.Sounds.ToArray();
}
}
}