Decompiled source of GlobalLightSwitch v1.0.2

Alternate-GlobalLightSwitch.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Global_Light_Switch;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using ScheduleOne.Misc;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Global Light Switch", "1.0.0", "GuysWeForgotDre", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("Global Light Switch")]
[assembly: AssemblyDescription("Toggles all lights in the game off and on with a single key")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Global Light Switch")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Global_Light_Switch;

public class Core : MelonMod
{
	public const string ModName = "Global Light Switch";

	public const string Version = "1.0.0";

	public const string ModDesc = "Toggles all lights in the game off and on with a single key";

	public static bool LightsOn = false;

	public static bool Initialized = false;

	public static readonly HashSet<ToggleableLight> AllLights = new HashSet<ToggleableLight>();

	public static MelonPreferences_Category PrefsCategory;

	public static MelonPreferences_Entry<KeyCode> PrefsKeyCode;

	public override void OnInitializeMelon()
	{
	}

	public override void OnUpdate()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		if (!Initialized)
		{
			PrefsCategory = MelonPreferences.CreateCategory("GlobalLightSwitch_prefs", "Global Light Switch");
			PrefsKeyCode = PrefsCategory.CreateEntry<KeyCode>("KeyCode", (KeyCode)286, "Toggle all lights", (string)null, false, false, (ValueValidator)null, (string)null);
			Initialized = true;
		}
		if (!Input.GetKeyDown(PrefsKeyCode.Value))
		{
			return;
		}
		foreach (ToggleableLight allLight in AllLights)
		{
			if (LightsOn)
			{
				allLight.TurnOn();
			}
			else
			{
				allLight.TurnOff();
			}
		}
		LightsOn = !LightsOn;
	}
}
[HarmonyPatch(typeof(ToggleableLight), "Awake")]
internal static class ToggleableLightAwakePatch
{
	private static void Postfix(ToggleableLight __instance)
	{
		if (__instance != null)
		{
			Core.AllLights.Add(__instance);
		}
	}
}

Main-GlobalLightSwitch.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Global_Light_Switch;
using HarmonyLib;
using Il2CppScheduleOne.Misc;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Global Light Switch", "1.0.0", "GuysWeForgotDre", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("Global Light Switch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Global Light Switch")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Global_Light_Switch;

public class Core : MelonMod
{
	public const string ModName = "Global Light Switch";

	public const string Version = "1.0.0";

	public const string ModDesc = "";

	public static bool LightsOn = false;

	public static bool Initialized = false;

	public static readonly HashSet<ToggleableLight> AllLights = new HashSet<ToggleableLight>();

	public static MelonPreferences_Category PrefsCategory;

	public static MelonPreferences_Entry<KeyCode> PrefsKeyCode;

	public override void OnInitializeMelon()
	{
	}

	public override void OnUpdate()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		if (!Initialized)
		{
			PrefsCategory = MelonPreferences.CreateCategory("GlobalLightSwitch_prefs", "Global Light Switch");
			PrefsKeyCode = PrefsCategory.CreateEntry<KeyCode>("KeyCode", (KeyCode)286, "Toggle all lights", (string)null, false, false, (ValueValidator)null, (string)null);
			Initialized = true;
		}
		if (!Input.GetKeyDown(PrefsKeyCode.Value))
		{
			return;
		}
		foreach (ToggleableLight allLight in AllLights)
		{
			if (LightsOn)
			{
				allLight.TurnOn();
			}
			else
			{
				allLight.TurnOff();
			}
		}
		LightsOn = !LightsOn;
	}
}
[HarmonyPatch(typeof(ToggleableLight), "Awake")]
internal static class ToggleableLightAwakePatch
{
	private static void Postfix(ToggleableLight __instance)
	{
		if (__instance != null)
		{
			Core.AllLights.Add(__instance);
		}
	}
}