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 PleaseTheMoon v1.0.0
PleaseTheMoon.dll
Decompiled 5 hours agousing 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 ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using PleaseTheMoon.Patches; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("PleaseTheMoon")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PleaseTheMoon")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d08ab981-6803-4cd8-985a-da1c0bc4b7a8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace PleaseTheMoon { [BepInPlugin("Neksuro.PleaseTheMoon", "Please The Moon", "1.0.0")] public class PleaseTheMoonPlugin : BaseUnityPlugin, IOnEventCallback { public static class TrackedExecutionContext { [ThreadStatic] private static int _callDepth; public static bool IsActive => _callDepth > 0; public static void Enter() { _callDepth++; } public static void Exit() { if (_callDepth > 0) { _callDepth--; } } } private const byte SyncSpawnEventCode = 181; public static bool canSpawn; private Harmony harmony; public static ConfigEntry<bool> EnableMod { get; private set; } public static ConfigEntry<bool> EnableRandomSpawn { get; private set; } public static ConfigEntry<int> SpawnChance { get; private set; } private void Awake() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn Settings", "Enable Extraction Pillars", true, "Enables the Halloween extraction pillars."); EnableRandomSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn Settings", "Enable Random Spawn", false, "Enables the random spawn chance of the extraction pillars on each level."); SpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn Settings", "Spawn Chance", 50, new ConfigDescription("Percent chance of the extraction pillars spawning on each level.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); Patch(); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} is loaded!"); SceneManager.sceneLoaded += OnSceneLoaded; PhotonNetwork.AddCallbackTarget((object)this); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; PhotonNetwork.RemoveCallbackTarget((object)this); } private void Patch() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); harmony.PatchAll(); PatchAllMethodsOnType(typeof(ExtractionPoint)); PatchAllMethodsOnType(typeof(ExtractionHalloweenAudio)); PatchAllMethodsOnType(typeof(ExtractionHalloweenBeams)); PatchAllMethodsOnType(typeof(ExtractionHalloweenContact)); PatchAllMethodsOnType(typeof(ExtractionHalloweenPillars)); PatchAllMethodsOnType(typeof(ExtractionHalloweenPumpkin)); PatchAllMethodsOnType(typeof(ExtractionHalloweenReward)); PatchAllMethodsOnType(typeof(ExtractionHalloweenTower)); PatchAllMethodsOnType(typeof(ValuableObject)); PatchAllMethodsOnType(typeof(PhysGrabObject)); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsLevel() && ((Scene)(ref scene)).name != "Reload") { SafeReloadConfig(); canSpawn = DetermineSpawnOnLevel(); SpawnPillarsRPC(SemiFunc.IsMultiplayer()); } } private void SafeReloadConfig() { if (Chainloader.PluginInfos.ContainsKey("nickklmao.repoconfig")) { ((BaseUnityPlugin)this).Logger.LogDebug((object)"Detected REPOConfig mod; skipping config reload."); return; } bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; try { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogDebug((object)"Config reloaded on scene load."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to reload config on scene load: {arg}"); } finally { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet; } } private bool DetermineSpawnOnLevel() { if (!EnableMod.Value) { return false; } if (EnableRandomSpawn.Value) { if (Random.Range(1, 101) <= SpawnChance.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Spawning Halloween extraction pillars on map!"); return true; } return false; } return true; } private void SpawnPillarsRPC(bool multiplayer) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (multiplayer) { PhotonNetwork.RaiseEvent((byte)181, (object)null, new RaiseEventOptions { CachingOption = (EventCaching)6 }, SendOptions.SendReliable); object[] array = new object[1] { canSpawn }; RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0, CachingOption = (EventCaching)4 }; PhotonNetwork.RaiseEvent((byte)181, (object)array, val, SendOptions.SendReliable); ((BaseUnityPlugin)this).Logger.LogDebug((object)$"[Network] Sending spawn results to lobby: {canSpawn}"); } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 181 && photonEvent.CustomData is object[] array && array.Length != 0 && array[0] is bool flag) { canSpawn = flag; ((BaseUnityPlugin)this).Logger.LogDebug((object)"[Network] Received spawn results from host."); if (canSpawn) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Network] Lobby host spawned Halloween extraction pillars on map!"); } } } private void PatchAllMethodsOnType(Type targetType) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(ExtractionPatches), "Prefix", (Type[])null); HarmonyMethod val2 = new HarmonyMethod(typeof(ExtractionPatches), "Postfix", (Type[])null); foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(targetType)) { if (!declaredMethod.IsAbstract && !declaredMethod.ContainsGenericParameters && !declaredMethod.IsGenericMethod) { try { harmony.Patch((MethodBase)declaredMethod, val, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Skipped " + targetType.Name + "." + declaredMethod.Name + ": " + ex.Message)); } } } } } } namespace PleaseTheMoon.Patches { public static class ExtractionPatches { public static void Prefix(object __instance) { if (__instance != null) { PleaseTheMoonPlugin.TrackedExecutionContext.Enter(); } } public static void Postfix(object __instance) { if (__instance != null) { PleaseTheMoonPlugin.TrackedExecutionContext.Exit(); } } } [HarmonyPatch(typeof(SemiFunc), "GameEventIsHalloween")] public static class HalloweenEventPatch { [HarmonyPostfix] public static void Postfix(ref bool __result) { if (PleaseTheMoonPlugin.TrackedExecutionContext.IsActive) { __result = PleaseTheMoonPlugin.canSpawn; } } } }