using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExplodingHorns.Patches; using GameNetcodeStuff; using HarmonyLib; using LethalSettings.UI; using LethalSettings.UI.Components; using Microsoft.CodeAnalysis; using Unity.Netcode; 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("ExplodingHorns")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ExplodingHorns")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6b3d5f35-02d0-4b46-964d-46ebee750fa0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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 ExplodingHorns { internal static class LethalSettingsIntegration { internal static void TryRegister() { if (!Chainloader.PluginInfos.ContainsKey("com.willis.lc.lethalsettings")) { Plugin.Log.LogInfo((object)"LethalSettings non détecté — configuration via le .cfg uniquement."); return; } try { Register(); Plugin.Log.LogInfo((object)"Menu LethalSettings enregistré pour ExplodingHorns."); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Impossible d'enregistrer le menu LethalSettings : {arg}"); } } private static void Register() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Expected O, but got Unknown ModSettingsConfig val = new ModSettingsConfig(); val.Name = "ExplodingHorns"; val.Id = "ota.explodinghorns"; val.Version = "1.0.0"; val.Description = "Chance que l'airhorn / clown horn explose (+ foudre) à l'usage."; val.MenuComponents = (MenuComponent[])(object)new MenuComponent[7] { (MenuComponent)new SliderComponent { Text = "Chance d'explosion (%)", Value = Plugin.ExplosionChance.Value * 100f, MinValue = 0f, MaxValue = 100f, OnValueChanged = delegate(SliderComponent self, float value) { Plugin.ExplosionChance.Value = value / 100f; } }, (MenuComponent)new SliderComponent { Text = "Rayon de dégâts min (m)", Value = Plugin.MinDamageRadius.Value, MinValue = 0f, MaxValue = 20f, OnValueChanged = delegate(SliderComponent self, float value) { Plugin.MinDamageRadius.Value = value; } }, (MenuComponent)new SliderComponent { Text = "Rayon de dégâts max (m)", Value = Plugin.MaxDamageRadius.Value, MinValue = 0f, MaxValue = 30f, OnValueChanged = delegate(SliderComponent self, float value) { Plugin.MaxDamageRadius.Value = value; } }, (MenuComponent)new SliderComponent { Text = "Dégâts", Value = Plugin.DamageAmount.Value, MinValue = 0f, MaxValue = 150f, OnValueChanged = delegate(SliderComponent self, float value) { Plugin.DamageAmount.Value = (int)value; } }, (MenuComponent)new ToggleComponent { Text = "Détruire le horn après explosion", Value = Plugin.DestroyHornOnExplosion.Value, OnValueChanged = delegate(ToggleComponent self, bool value) { Plugin.DestroyHornOnExplosion.Value = value; } }, (MenuComponent)new ToggleComponent { Text = "Activer la foudre autour de l'explosion", Value = Plugin.LightningEnabled.Value, OnValueChanged = delegate(ToggleComponent self, bool value) { Plugin.LightningEnabled.Value = value; } }, (MenuComponent)new SliderComponent { Text = "Rayon de la foudre (m)", Value = Plugin.LightningRadius.Value, MinValue = 0f, MaxValue = 40f, OnValueChanged = delegate(SliderComponent self, float value) { Plugin.LightningRadius.Value = value; } } }; ModMenu.RegisterMod(val); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("ota.explodinghorns", "ExplodingHorns", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "ota.explodinghorns"; public const string PluginName = "ExplodingHorns"; public const string PluginVersion = "1.0.0"; public const string LethalSettingsGuid = "com.willis.lc.lethalsettings"; public static ConfigEntry ExplosionChance; public static ConfigEntry MinDamageRadius; public static ConfigEntry MaxDamageRadius; public static ConfigEntry DamageAmount; public static ConfigEntry DestroyHornOnExplosion; public static ConfigEntry LightningEnabled; public static ConfigEntry LightningRadius; internal static ManualLogSource Log; private readonly Harmony harmony = new Harmony("ota.explodinghorns"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ExplosionChance = ((BaseUnityPlugin)this).Config.Bind("General", "ExplosionChance", 0.1f, "Probabilité (entre 0 et 1) que l'airhorn / clown horn explose à chaque utilisation. 0.10 = 10%."); MinDamageRadius = ((BaseUnityPlugin)this).Config.Bind("General", "MinDamageRadius", 2f, "Rayon (en mètres) dans lequel les dégâts de l'explosion sont maximaux."); MaxDamageRadius = ((BaseUnityPlugin)this).Config.Bind("General", "MaxDamageRadius", 6f, "Rayon (en mètres) au-delà duquel l'explosion ne fait plus de dégâts."); DamageAmount = ((BaseUnityPlugin)this).Config.Bind("General", "DamageAmount", 60, "Dégâts infligés par l'explosion (le porteur du horn les reçoit toujours, même hors du rayon)."); DestroyHornOnExplosion = ((BaseUnityPlugin)this).Config.Bind("General", "DestroyHornOnExplosion", true, "Si vrai, le horn est détruit quand il explose."); LightningEnabled = ((BaseUnityPlugin)this).Config.Bind("Lightning", "LightningEnabled", true, "Si vrai, la foudre s'abat aussi sur les joueurs à proximité de l'explosion. Ne fonctionne que si la météo du jour est orageuse (StormyWeather)."); LightningRadius = ((BaseUnityPlugin)this).Config.Bind("Lightning", "LightningRadius", 15f, "Rayon (en mètres) autour de l'explosion dans lequel les joueurs sont frappés par la foudre."); harmony.PatchAll(typeof(HornExplosionPatch)); LethalSettingsIntegration.TryRegister(); Log.LogInfo((object)string.Format("{0} {1} chargé — chance d'explosion : {2}%", "ExplodingHorns", "1.0.0", ExplosionChance.Value * 100f)); } } } namespace ExplodingHorns.Patches { [HarmonyPatch(typeof(NoisemakerProp), "ItemActivate")] internal static class HornExplosionPatch { [HarmonyPostfix] private static void Postfix(NoisemakerProp __instance, bool used, bool buttonDown) { if (buttonDown && ((NetworkBehaviour)__instance).IsOwner && Random.value <= Plugin.ExplosionChance.Value) { Explode((GrabbableObject)(object)__instance); } } private static void Explode(GrabbableObject horn) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)horn).transform.position; PlayerControllerB playerHeldBy = horn.playerHeldBy; Plugin.Log.LogInfo((object)string.Format("BOOM — {0} explose en {1}", horn.itemProperties?.itemName ?? "horn", position)); Landmine.SpawnExplosion(position, true, Plugin.MinDamageRadius.Value, Plugin.MaxDamageRadius.Value, Plugin.DamageAmount.Value, 0f, (GameObject)null, false); if ((Object)(object)playerHeldBy != (Object)null) { playerHeldBy.DamagePlayer(Plugin.DamageAmount.Value, true, true, (CauseOfDeath)3, 0, false, default(Vector3)); } if (Plugin.DestroyHornOnExplosion.Value) { horn.DestroyObjectInHand(playerHeldBy); } if (Plugin.LightningEnabled.Value) { StrikeLightningNearby(position, Plugin.LightningRadius.Value); } } private static void StrikeLightningNearby(Vector3 origin, float radius) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (!((Object)(object)val == (Object)null) && !val.isPlayerDead) { float num = Vector3.Distance(((Component)val).transform.position, origin); if (num <= radius) { Plugin.Log.LogInfo((object)("⚡ La foudre s'abat sur " + val.playerUsername + " !")); RoundManager.Instance.LightningStrikeServerRpc(((Component)val).transform.position); } } } } } }