Decompiled source of Halloween Event v1.0.4

Halloween.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("fishing")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("fishing")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2bbf55db-61a4-4d2d-8b26-593a61e2e520")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.Recks.halloweeneventforcer", "Halloween Event Forcer", "1.0.4")]
public class HalloweenEventForcer : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <ActivateHalloweenEvent>d__7 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public HalloweenEventForcer <>4__this;

		private GameObject[] <allGameObjects>5__1;

		private bool <found>5__2;

		private GameObject[] <>s__3;

		private int <>s__4;

		private GameObject <go>5__5;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ActivateHalloweenEvent>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<allGameObjects>5__1 = null;
			<>s__3 = null;
			<go>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			if (<>1__state != 0)
			{
				return false;
			}
			<>1__state = -1;
			if (<>4__this.activated)
			{
				return false;
			}
			<allGameObjects>5__1 = Resources.FindObjectsOfTypeAll<GameObject>();
			<found>5__2 = false;
			<>s__3 = <allGameObjects>5__1;
			for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
			{
				<go>5__5 = <>s__3[<>s__4];
				if (((Object)<go>5__5).name == "HALLOWEEN EVENT")
				{
					<found>5__2 = true;
					if (!<go>5__5.activeSelf)
					{
						<go>5__5.SetActive(true);
						((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"HALLOWEEN EVENT set active! The event should now begin.");
					}
					else
					{
						((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"HALLOWEEN EVENT was already active.");
					}
					<>4__this.activated = true;
					break;
				}
				<go>5__5 = null;
			}
			<>s__3 = null;
			if (!<found>5__2)
			{
				((BaseUnityPlugin)<>4__this).Logger.LogWarning((object)"No GameObject named 'HALLOWEEN EVENT' was found in the current scene or resources.");
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private ConfigEntry<bool> enabledConfig;

	private bool activated = false;

	private void Awake()
	{
		enabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable forcing the Halloween Event in Stowaway.");
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void Start()
	{
		TryActivateIfEligible();
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		TryActivateIfEligible();
	}

	private void TryActivateIfEligible()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		activated = false;
		if (!enabledConfig.Value)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Halloween Event Forcer is disabled in config.");
			return;
		}
		Scene activeScene = SceneManager.GetActiveScene();
		if (((Scene)(ref activeScene)).name != "Stowaway")
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Halloween Event Forcer only runs in scene 'Stowaway', current scene is '" + ((Scene)(ref activeScene)).name + "'."));
		}
		else
		{
			((MonoBehaviour)this).StartCoroutine(ActivateHalloweenEvent());
		}
	}

	[IteratorStateMachine(typeof(<ActivateHalloweenEvent>d__7))]
	private IEnumerator ActivateHalloweenEvent()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ActivateHalloweenEvent>d__7(0)
		{
			<>4__this = this
		};
	}
}