Decompiled source of WhatCurfew v1.0.0

WhatCurfew_Il2cpp.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne.Law;
using Il2CppScheduleOne.ObjectScripts;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
using WhatCurfew;
using WhatCurfew.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "WhatCurfew", "1.0.0", "HazDS", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WhatCurfew_Il2cpp")]
[assembly: AssemblyConfiguration("Il2cpp")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WhatCurfew_Il2cpp")]
[assembly: AssemblyTitle("WhatCurfew_Il2cpp")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WhatCurfew
{
	public class Core : MelonMod
	{
		private static Harmony _harmony;

		public override void OnInitializeMelon()
		{
			Config.Initialize();
			MelonLogger.Msg("WhatCurfew v1.0.0 loaded!");
			ApplyPatches();
		}

		private void ApplyPatches()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			try
			{
				_harmony = new Harmony("com.whatcurfew.patches");
				Type typeFromHandle = typeof(CurfewManager);
				PatchMethod(typeFromHandle, "MinPass", "MinPass_Prefix");
				PatchEnableRPC(typeFromHandle);
				PatchVMSBoard();
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Failed to apply patches: " + ex.Message);
			}
		}

		private void PatchMethod(Type targetType, string methodName, string prefixMethodName)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			MethodInfo method = targetType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(method == null))
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod(prefixMethodName, BindingFlags.Static | BindingFlags.Public);
				if (!(method2 == null))
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private void PatchEnableRPC(Type curfewManagerType)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			MethodInfo method = curfewManagerType.GetMethod("RpcLogic___Enable_328543758", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(method == null))
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod("Enable_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (!(method2 == null))
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private void PatchVMSBoard()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			Type typeFromHandle = typeof(VMSBoard);
			MethodInfo method = typeFromHandle.GetMethod("SetText", new Type[2]
			{
				typeof(string),
				typeof(Color)
			});
			if (method != null)
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod("VMSBoard_SetText_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (method2 != null)
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			MethodInfo method3 = typeFromHandle.GetMethod("SetText", new Type[1] { typeof(string) });
			if (method3 != null)
			{
				MethodInfo method4 = typeof(CurfewPatches).GetMethod("VMSBoard_SetText_StringOnly_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (method4 != null)
				{
					_harmony.Patch((MethodBase)method3, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}
	}
	public static class Config
	{
		private static MelonPreferences_Category _category;

		private static MelonPreferences_Entry<bool> _enabled;

		private static MelonPreferences_Entry<string> _vmsBoardMessage;

		private static MelonPreferences_Entry<string> _vmsBoardColor;

		public static readonly Dictionary<string, Color32> ColorOptions = new Dictionary<string, Color32>
		{
			{
				"Green",
				new Color32((byte)100, byte.MaxValue, (byte)100, byte.MaxValue)
			},
			{
				"Yellow",
				new Color32(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue)
			},
			{
				"Red",
				new Color32(byte.MaxValue, (byte)85, (byte)60, byte.MaxValue)
			},
			{
				"Blue",
				new Color32((byte)100, (byte)150, byte.MaxValue, byte.MaxValue)
			},
			{
				"Cyan",
				new Color32((byte)100, byte.MaxValue, byte.MaxValue, byte.MaxValue)
			},
			{
				"Purple",
				new Color32((byte)200, (byte)100, byte.MaxValue, byte.MaxValue)
			},
			{
				"Orange",
				new Color32(byte.MaxValue, (byte)165, (byte)50, byte.MaxValue)
			},
			{
				"White",
				new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)
			}
		};

		public static bool Enabled => _enabled?.Value ?? true;

		public static string VMSBoardMessage => _vmsBoardMessage?.Value ?? "NO CURFEW\nENJOY THE NIGHT";

		public static string VMSBoardColorName => _vmsBoardColor?.Value ?? "Green";

		public static Color32 VMSBoardColor
		{
			get
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: 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_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				if (ColorOptions.TryGetValue(VMSBoardColorName, out var value))
				{
					return value;
				}
				return ColorOptions["Green"];
			}
		}

		public static void Initialize()
		{
			_category = MelonPreferences.CreateCategory("WhatCurfew", "WhatCurfew Settings");
			_enabled = _category.CreateEntry<bool>("Enabled", true, "Enable Mod", "When enabled, the curfew system is completely disabled. You can roam freely at any time without police harassment.", false, false, (ValueValidator)null, (string)null);
			_vmsBoardMessage = _category.CreateEntry<string>("VMSBoardMessage", "NO CURFEW\nENJOY THE NIGHT", "VMS Board Message", "Custom message to display on roadside VMS boards. Use \\n for new lines.", false, false, (ValueValidator)null, (string)null);
			_vmsBoardColor = _category.CreateEntry<string>("VMSBoardColor", "Green", "VMS Board Color", "Color of the VMS board text. Options: Green, Yellow, Red, Blue, Cyan, Purple, Orange, White", false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<bool, bool>>)(object)_enabled.OnEntryValueChanged).Subscribe((LemonAction<bool, bool>)delegate(bool oldVal, bool newVal)
			{
				MelonLogger.Msg("Mod " + (newVal ? "enabled" : "disabled"));
				CurfewPatches.OnEnabledChanged(newVal);
			}, 0, false);
			((MelonEventBase<LemonAction<string, string>>)(object)_vmsBoardMessage.OnEntryValueChanged).Subscribe((LemonAction<string, string>)delegate(string oldVal, string newVal)
			{
				MelonLogger.Msg("VMS message changed to: " + newVal);
				if (Enabled)
				{
					CurfewPatches.RefreshAllBoards();
				}
			}, 0, false);
			((MelonEventBase<LemonAction<string, string>>)(object)_vmsBoardColor.OnEntryValueChanged).Subscribe((LemonAction<string, string>)delegate(string oldVal, string newVal)
			{
				MelonLogger.Msg("VMS color changed to: " + newVal);
				if (Enabled)
				{
					CurfewPatches.RefreshAllBoards();
				}
			}, 0, false);
			MelonLogger.Msg($"Configuration loaded. Curfew disabled: {Enabled}");
		}
	}
}
namespace WhatCurfew.Patches
{
	public static class CurfewPatches
	{
		private static readonly Dictionary<int, (VMSBoard board, string text, Color color)> _trackedBoards = new Dictionary<int, (VMSBoard, string, Color)>();

		private static readonly string[] CurfewMessages = new string[3] { "CURFEW TONIGHT", "CURFEW ACTIVE", "CURFEW SOON" };

		public static void RefreshAllBoards()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard in _trackedBoards)
			{
				if ((Object)(object)trackedBoard.Value.Item1 == (Object)null)
				{
					list.Add(trackedBoard.Key);
				}
			}
			foreach (int item2 in list)
			{
				_trackedBoards.Remove(item2);
			}
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard2 in _trackedBoards)
			{
				VMSBoard item = trackedBoard2.Value.Item1;
				if ((Object)(object)item != (Object)null && (Object)(object)item.Label != (Object)null)
				{
					item.SetText(Config.VMSBoardMessage, Color32.op_Implicit(Config.VMSBoardColor));
				}
			}
		}

		public static void RestoreAllBoards()
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard in _trackedBoards)
			{
				if ((Object)(object)trackedBoard.Value.Item1 == (Object)null)
				{
					list.Add(trackedBoard.Key);
				}
			}
			foreach (int item in list)
			{
				_trackedBoards.Remove(item);
			}
			List<(VMSBoard, string, Color)> list2 = new List<(VMSBoard, string, Color)>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard2 in _trackedBoards)
			{
				list2.Add(trackedBoard2.Value);
			}
			foreach (var (val, text, color) in list2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.Label != (Object)null)
				{
					((TMP_Text)val.Label).text = text;
					((Graphic)val.Label).color = color;
				}
			}
		}

		public static void OnEnabledChanged(bool enabled)
		{
			if (enabled)
			{
				RefreshAllBoards();
				return;
			}
			RestoreAllBoards();
			RestoreCurfewState();
		}

		private static void RestoreCurfewState()
		{
			try
			{
				Type typeFromHandle = typeof(CurfewManager);
				PropertyInfo propertyInfo = typeFromHandle.BaseType?.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
				if (propertyInfo == null)
				{
					propertyInfo = typeFromHandle.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
				}
				if (!(propertyInfo != null))
				{
					return;
				}
				object? value = propertyInfo.GetValue(null);
				CurfewManager val = (CurfewManager)((value is CurfewManager) ? value : null);
				if ((Object)(object)val != (Object)null)
				{
					PropertyInfo property = typeFromHandle.GetProperty("IsEnabled");
					if (property != null)
					{
						property.SetValue(val, true);
					}
				}
			}
			catch
			{
			}
		}

		private static bool IsCurfewMessage(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			string[] curfewMessages = CurfewMessages;
			foreach (string value in curfewMessages)
			{
				if (text.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		public static bool MinPass_Prefix(CurfewManager __instance)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			try
			{
				Type type = ((object)__instance).GetType();
				PropertyInfo property = type.GetProperty("IsEnabled");
				PropertyInfo property2 = type.GetProperty("IsCurrentlyActive");
				PropertyInfo property3 = type.GetProperty("IsHardCurfewActive");
				if (property != null && (bool)property.GetValue(__instance))
				{
					property.SetValue(__instance, false);
				}
				if (property2 != null && (bool)property2.GetValue(__instance))
				{
					property2.SetValue(__instance, false);
				}
				if (property3 != null && (bool)property3.GetValue(__instance))
				{
					property3.SetValue(__instance, false);
				}
			}
			catch
			{
			}
			return false;
		}

		public static bool Enable_Prefix(CurfewManager __instance)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if (!Config.Enabled)
			{
				return true;
			}
			try
			{
				if (__instance.VMSBoards != null)
				{
					Color32 val = default(Color32);
					foreach (VMSBoard item in (Il2CppArrayBase<VMSBoard>)(object)__instance.VMSBoards)
					{
						if ((Object)(object)item != (Object)null)
						{
							((Component)item).gameObject.SetActive(true);
							if ((Object)(object)item.Label != (Object)null)
							{
								((TMP_Text)item.Label).text = Config.VMSBoardMessage;
								((Graphic)item.Label).color = Color32.op_Implicit(Config.VMSBoardColor);
							}
							int instanceID = ((Object)item).GetInstanceID();
							((Color32)(ref val))..ctor(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue);
							_trackedBoards[instanceID] = (item, "CURFEW TONIGHT\n9PM - 5AM", Color32.op_Implicit(val));
						}
					}
				}
			}
			catch
			{
			}
			return false;
		}

		public static bool IsCurrentlyActive_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static bool IsHardCurfewActive_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static bool IsEnabled_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static void VMSBoard_SetText_Prefix(VMSBoard __instance, ref string text, ref Color col)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (IsCurfewMessage(text))
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				_trackedBoards[instanceID] = (__instance, text, col);
				if (Config.Enabled)
				{
					text = Config.VMSBoardMessage;
					col = Color32.op_Implicit(Config.VMSBoardColor);
				}
			}
		}

		public static bool VMSBoard_SetText_StringOnly_Prefix(VMSBoard __instance, ref string text)
		{
			//IL_0038: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (IsCurfewMessage(text))
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				Color32 val = default(Color32);
				((Color32)(ref val))..ctor(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue);
				_trackedBoards[instanceID] = (__instance, text, Color32.op_Implicit(val));
				if (!Config.Enabled)
				{
					return true;
				}
				if ((Object)(object)__instance.Label != (Object)null)
				{
					((TMP_Text)__instance.Label).text = Config.VMSBoardMessage;
					((Graphic)__instance.Label).color = Color32.op_Implicit(Config.VMSBoardColor);
				}
				return false;
			}
			return true;
		}
	}
}
namespace WhatCurfew.Utils
{
	public static class Constants
	{
		public static class Game
		{
			public const string GAME_STUDIO = "TVGS";

			public const string GAME_NAME = "Schedule I";
		}

		public const string MOD_NAME = "WhatCurfew";

		public const string MOD_VERSION = "1.0.0";

		public const string MOD_AUTHOR = "HazDS";

		public const string MOD_DESCRIPTION = "Removes the curfew system from Schedule I.";

		public const string PREFERENCES_CATEGORY = "WhatCurfew";
	}
}

WhatCurfew_Mono.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using ScheduleOne.Law;
using ScheduleOne.ObjectScripts;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using WhatCurfew;
using WhatCurfew.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "WhatCurfew", "1.0.0", "HazDS", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WhatCurfew_Mono")]
[assembly: AssemblyConfiguration("Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WhatCurfew_Mono")]
[assembly: AssemblyTitle("WhatCurfew_Mono")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WhatCurfew
{
	public class Core : MelonMod
	{
		private static Harmony _harmony;

		public override void OnInitializeMelon()
		{
			Config.Initialize();
			MelonLogger.Msg("WhatCurfew v1.0.0 loaded!");
			ApplyPatches();
		}

		private void ApplyPatches()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			try
			{
				_harmony = new Harmony("com.whatcurfew.patches");
				Type typeFromHandle = typeof(CurfewManager);
				PatchMethod(typeFromHandle, "MinPass", "MinPass_Prefix");
				PatchEnableRPC(typeFromHandle);
				PatchVMSBoard();
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Failed to apply patches: " + ex.Message);
			}
		}

		private void PatchMethod(Type targetType, string methodName, string prefixMethodName)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			MethodInfo method = targetType.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(method == null))
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod(prefixMethodName, BindingFlags.Static | BindingFlags.Public);
				if (!(method2 == null))
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private void PatchEnableRPC(Type curfewManagerType)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			MethodInfo method = curfewManagerType.GetMethod("RpcLogic___Enable_328543758", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (!(method == null))
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod("Enable_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (!(method2 == null))
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private void PatchVMSBoard()
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			Type typeFromHandle = typeof(VMSBoard);
			MethodInfo method = typeFromHandle.GetMethod("SetText", new Type[2]
			{
				typeof(string),
				typeof(Color)
			});
			if (method != null)
			{
				MethodInfo method2 = typeof(CurfewPatches).GetMethod("VMSBoard_SetText_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (method2 != null)
				{
					_harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			MethodInfo method3 = typeFromHandle.GetMethod("SetText", new Type[1] { typeof(string) });
			if (method3 != null)
			{
				MethodInfo method4 = typeof(CurfewPatches).GetMethod("VMSBoard_SetText_StringOnly_Prefix", BindingFlags.Static | BindingFlags.Public);
				if (method4 != null)
				{
					_harmony.Patch((MethodBase)method3, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}
	}
	public static class Config
	{
		private static MelonPreferences_Category _category;

		private static MelonPreferences_Entry<bool> _enabled;

		private static MelonPreferences_Entry<string> _vmsBoardMessage;

		private static MelonPreferences_Entry<string> _vmsBoardColor;

		public static readonly Dictionary<string, Color32> ColorOptions = new Dictionary<string, Color32>
		{
			{
				"Green",
				new Color32((byte)100, byte.MaxValue, (byte)100, byte.MaxValue)
			},
			{
				"Yellow",
				new Color32(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue)
			},
			{
				"Red",
				new Color32(byte.MaxValue, (byte)85, (byte)60, byte.MaxValue)
			},
			{
				"Blue",
				new Color32((byte)100, (byte)150, byte.MaxValue, byte.MaxValue)
			},
			{
				"Cyan",
				new Color32((byte)100, byte.MaxValue, byte.MaxValue, byte.MaxValue)
			},
			{
				"Purple",
				new Color32((byte)200, (byte)100, byte.MaxValue, byte.MaxValue)
			},
			{
				"Orange",
				new Color32(byte.MaxValue, (byte)165, (byte)50, byte.MaxValue)
			},
			{
				"White",
				new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)
			}
		};

		public static bool Enabled => _enabled?.Value ?? true;

		public static string VMSBoardMessage => _vmsBoardMessage?.Value ?? "NO CURFEW\nENJOY THE NIGHT";

		public static string VMSBoardColorName => _vmsBoardColor?.Value ?? "Green";

		public static Color32 VMSBoardColor
		{
			get
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: 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_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				if (ColorOptions.TryGetValue(VMSBoardColorName, out var value))
				{
					return value;
				}
				return ColorOptions["Green"];
			}
		}

		public static void Initialize()
		{
			_category = MelonPreferences.CreateCategory("WhatCurfew", "WhatCurfew Settings");
			_enabled = _category.CreateEntry<bool>("Enabled", true, "Enable Mod", "When enabled, the curfew system is completely disabled. You can roam freely at any time without police harassment.", false, false, (ValueValidator)null, (string)null);
			_vmsBoardMessage = _category.CreateEntry<string>("VMSBoardMessage", "NO CURFEW\nENJOY THE NIGHT", "VMS Board Message", "Custom message to display on roadside VMS boards. Use \\n for new lines.", false, false, (ValueValidator)null, (string)null);
			_vmsBoardColor = _category.CreateEntry<string>("VMSBoardColor", "Green", "VMS Board Color", "Color of the VMS board text. Options: Green, Yellow, Red, Blue, Cyan, Purple, Orange, White", false, false, (ValueValidator)null, (string)null);
			((MelonEventBase<LemonAction<bool, bool>>)(object)_enabled.OnEntryValueChanged).Subscribe((LemonAction<bool, bool>)delegate(bool oldVal, bool newVal)
			{
				MelonLogger.Msg("Mod " + (newVal ? "enabled" : "disabled"));
				CurfewPatches.OnEnabledChanged(newVal);
			}, 0, false);
			((MelonEventBase<LemonAction<string, string>>)(object)_vmsBoardMessage.OnEntryValueChanged).Subscribe((LemonAction<string, string>)delegate(string oldVal, string newVal)
			{
				MelonLogger.Msg("VMS message changed to: " + newVal);
				if (Enabled)
				{
					CurfewPatches.RefreshAllBoards();
				}
			}, 0, false);
			((MelonEventBase<LemonAction<string, string>>)(object)_vmsBoardColor.OnEntryValueChanged).Subscribe((LemonAction<string, string>)delegate(string oldVal, string newVal)
			{
				MelonLogger.Msg("VMS color changed to: " + newVal);
				if (Enabled)
				{
					CurfewPatches.RefreshAllBoards();
				}
			}, 0, false);
			MelonLogger.Msg($"Configuration loaded. Curfew disabled: {Enabled}");
		}
	}
}
namespace WhatCurfew.Patches
{
	public static class CurfewPatches
	{
		private static readonly Dictionary<int, (VMSBoard board, string text, Color color)> _trackedBoards = new Dictionary<int, (VMSBoard, string, Color)>();

		private static readonly string[] CurfewMessages = new string[3] { "CURFEW TONIGHT", "CURFEW ACTIVE", "CURFEW SOON" };

		public static void RefreshAllBoards()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard in _trackedBoards)
			{
				if ((Object)(object)trackedBoard.Value.Item1 == (Object)null)
				{
					list.Add(trackedBoard.Key);
				}
			}
			foreach (int item2 in list)
			{
				_trackedBoards.Remove(item2);
			}
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard2 in _trackedBoards)
			{
				VMSBoard item = trackedBoard2.Value.Item1;
				if ((Object)(object)item != (Object)null && (Object)(object)item.Label != (Object)null)
				{
					item.SetText(Config.VMSBoardMessage, Color32.op_Implicit(Config.VMSBoardColor));
				}
			}
		}

		public static void RestoreAllBoards()
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard in _trackedBoards)
			{
				if ((Object)(object)trackedBoard.Value.Item1 == (Object)null)
				{
					list.Add(trackedBoard.Key);
				}
			}
			foreach (int item in list)
			{
				_trackedBoards.Remove(item);
			}
			List<(VMSBoard, string, Color)> list2 = new List<(VMSBoard, string, Color)>();
			foreach (KeyValuePair<int, (VMSBoard, string, Color)> trackedBoard2 in _trackedBoards)
			{
				list2.Add(trackedBoard2.Value);
			}
			foreach (var (val, text, color) in list2)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.Label != (Object)null)
				{
					((TMP_Text)val.Label).text = text;
					((Graphic)val.Label).color = color;
				}
			}
		}

		public static void OnEnabledChanged(bool enabled)
		{
			if (enabled)
			{
				RefreshAllBoards();
				return;
			}
			RestoreAllBoards();
			RestoreCurfewState();
		}

		private static void RestoreCurfewState()
		{
			try
			{
				Type typeFromHandle = typeof(CurfewManager);
				PropertyInfo propertyInfo = typeFromHandle.BaseType?.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
				if (propertyInfo == null)
				{
					propertyInfo = typeFromHandle.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public);
				}
				if (!(propertyInfo != null))
				{
					return;
				}
				object? value = propertyInfo.GetValue(null);
				CurfewManager val = (CurfewManager)((value is CurfewManager) ? value : null);
				if ((Object)(object)val != (Object)null)
				{
					PropertyInfo property = typeFromHandle.GetProperty("IsEnabled");
					if (property != null)
					{
						property.SetValue(val, true);
					}
				}
			}
			catch
			{
			}
		}

		private static bool IsCurfewMessage(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			string[] curfewMessages = CurfewMessages;
			foreach (string value in curfewMessages)
			{
				if (text.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		public static bool MinPass_Prefix(CurfewManager __instance)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			try
			{
				Type type = ((object)__instance).GetType();
				PropertyInfo property = type.GetProperty("IsEnabled");
				PropertyInfo property2 = type.GetProperty("IsCurrentlyActive");
				PropertyInfo property3 = type.GetProperty("IsHardCurfewActive");
				if (property != null && (bool)property.GetValue(__instance))
				{
					property.SetValue(__instance, false);
				}
				if (property2 != null && (bool)property2.GetValue(__instance))
				{
					property2.SetValue(__instance, false);
				}
				if (property3 != null && (bool)property3.GetValue(__instance))
				{
					property3.SetValue(__instance, false);
				}
			}
			catch
			{
			}
			return false;
		}

		public static bool Enable_Prefix(CurfewManager __instance)
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (!Config.Enabled)
			{
				return true;
			}
			try
			{
				if (__instance.VMSBoards != null)
				{
					VMSBoard[] vMSBoards = __instance.VMSBoards;
					Color32 val2 = default(Color32);
					foreach (VMSBoard val in vMSBoards)
					{
						if ((Object)(object)val != (Object)null)
						{
							((Component)val).gameObject.SetActive(true);
							if ((Object)(object)val.Label != (Object)null)
							{
								((TMP_Text)val.Label).text = Config.VMSBoardMessage;
								((Graphic)val.Label).color = Color32.op_Implicit(Config.VMSBoardColor);
							}
							int instanceID = ((Object)val).GetInstanceID();
							((Color32)(ref val2))..ctor(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue);
							_trackedBoards[instanceID] = (val, "CURFEW TONIGHT\n9PM - 5AM", Color32.op_Implicit(val2));
						}
					}
				}
			}
			catch
			{
			}
			return false;
		}

		public static bool IsCurrentlyActive_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static bool IsHardCurfewActive_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static bool IsEnabled_Prefix(ref bool __result)
		{
			if (!Config.Enabled)
			{
				return true;
			}
			__result = false;
			return false;
		}

		public static void VMSBoard_SetText_Prefix(VMSBoard __instance, ref string text, ref Color col)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (IsCurfewMessage(text))
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				_trackedBoards[instanceID] = (__instance, text, col);
				if (Config.Enabled)
				{
					text = Config.VMSBoardMessage;
					col = Color32.op_Implicit(Config.VMSBoardColor);
				}
			}
		}

		public static bool VMSBoard_SetText_StringOnly_Prefix(VMSBoard __instance, ref string text)
		{
			//IL_0038: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (IsCurfewMessage(text))
			{
				int instanceID = ((Object)__instance).GetInstanceID();
				Color32 val = default(Color32);
				((Color32)(ref val))..ctor(byte.MaxValue, (byte)215, (byte)50, byte.MaxValue);
				_trackedBoards[instanceID] = (__instance, text, Color32.op_Implicit(val));
				if (!Config.Enabled)
				{
					return true;
				}
				if ((Object)(object)__instance.Label != (Object)null)
				{
					((TMP_Text)__instance.Label).text = Config.VMSBoardMessage;
					((Graphic)__instance.Label).color = Color32.op_Implicit(Config.VMSBoardColor);
				}
				return false;
			}
			return true;
		}
	}
}
namespace WhatCurfew.Utils
{
	public static class Constants
	{
		public static class Game
		{
			public const string GAME_STUDIO = "TVGS";

			public const string GAME_NAME = "Schedule I";
		}

		public const string MOD_NAME = "WhatCurfew";

		public const string MOD_VERSION = "1.0.0";

		public const string MOD_AUTHOR = "HazDS";

		public const string MOD_DESCRIPTION = "Removes the curfew system from Schedule I.";

		public const string PREFERENCES_CATEGORY = "WhatCurfew";
	}
}