Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TheOneAndOnly v1.2.0
zangetsu.TheOneAndOnly.dll
Decompiled 2 years agousing System; 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 BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TheOneAndOnly.Services; using UnityEngine; using UnityEngine.Events; [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("zangetsu.TheOneAndOnly")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("TheOneAndOnly")] [assembly: AssemblyTitle("zangetsu.TheOneAndOnly")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [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.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; } } [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 TheOneAndOnly { [BepInPlugin("zangetsu.TheOneAndOnly", "TheOneAndOnly", "1.2.0")] public class TheOneAndOnly : BaseUnityPlugin { public static AudioClip TheOneAndOnlyAudioClip; private const string TheOneAndOnlyAssetBundleName = "theoneandonlymodasset"; public static TheOneAndOnly Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); if (directoryName != null) { AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "theoneandonlymodasset")); if ((Object)(object)val == (Object)null) { Logger.LogError((object)"zangetsu.TheOneAndOnly v1.2.0 not loaded - Failed to load asset."); return; } TheOneAndOnlyAudioClip = val.LoadAsset<AudioClip>("TheOneAndOnly"); Patch(); Logger.LogInfo((object)"zangetsu.TheOneAndOnly v1.2.0 has loaded!"); } } internal static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("zangetsu.TheOneAndOnly"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "zangetsu.TheOneAndOnly"; public const string PLUGIN_NAME = "TheOneAndOnly"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace TheOneAndOnly.Services { public static class TheOneAndOnlyService { [CompilerGenerated] private static class <>O { public static UnityAction <0>__OnNewRoundStartedEvent; } private static bool _soundAlreadyPlayedThisRound; private static bool _isInitialized; public static bool ShouldPlaySound(int numberOfLivingPlayers, SimpleEvent newRoundStartedEvent) { if (!_isInitialized) { Initialize(newRoundStartedEvent); } if (numberOfLivingPlayers != 1 || _soundAlreadyPlayedThisRound) { return false; } _soundAlreadyPlayedThisRound = true; return true; } private static void Initialize(SimpleEvent newRoundStartedEvent) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown object obj = <>O.<0>__OnNewRoundStartedEvent; if (obj == null) { UnityAction val = OnNewRoundStartedEvent; <>O.<0>__OnNewRoundStartedEvent = val; obj = (object)val; } ((UnityEvent)newRoundStartedEvent).AddListener((UnityAction)obj); _isInitialized = true; } private static void OnNewRoundStartedEvent() { _soundAlreadyPlayedThisRound = false; } } } namespace TheOneAndOnly.Patches { [HarmonyPatch(typeof(PlayerControllerB), "KillPlayerClientRpc")] internal sealed class PlayerControllerBPatch { private static void Postfix(StartOfRound ___playersManager) { if (TheOneAndOnlyService.ShouldPlaySound(___playersManager.livingPlayers, ___playersManager.StartNewRoundEvent)) { HUDManager.Instance.UIAudio.PlayOneShot(TheOneAndOnly.TheOneAndOnlyAudioClip); } } } [HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")] internal sealed class StartOfRoundPatch { private static void Postfix(StartOfRound __instance) { if (TheOneAndOnlyService.ShouldPlaySound(__instance.livingPlayers, __instance.StartNewRoundEvent)) { HUDManager.Instance.UIAudio.PlayOneShot(TheOneAndOnly.TheOneAndOnlyAudioClip); } } } }