using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LLGUI; using LLScreen; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("com.github.daioutzu.moretime")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MoreTime")] [assembly: AssemblyTitle("com.github.daioutzu.moretime")] [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 MoreTime { internal class Patches { private const int MAX_TIME_SECONDS = 359999; private const int TIME_SIZE_Y = 15; [HarmonyPatch(typeof(ScreenPlayersSettings), "BtTimeChange")] [HarmonyTranspiler] private static IEnumerable AddMoreTimeOptions(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.SearchForward((Func)((CodeInstruction i) => i.opcode == OpCodes.Stloc_2)).ThrowIfNotMatch("Didn't find local variable 2", (CodeMatch[])(object)new CodeMatch[0]).Advance(-3); int value = Plugin.maxTimeInSeconds.Value; val.SetOperandAndAdvance((object)value); val.SearchForward((Func)((CodeInstruction i) => i.opcode == OpCodes.Mul)).ThrowIfNotMatch("Didn't find multiplication", (CodeMatch[])(object)new CodeMatch[0]).Advance(1); val.Insert((CodeInstruction[])(object)new CodeInstruction[2] { Transpilers.EmitDelegate>((Func)delegate { if ((double)UIInput.mainCursor.accelKeysMove > 8.1) { return 300; } if ((double)UIInput.mainCursor.accelKeysMove > 5.7) { return 60; } if ((double)UIInput.mainCursor.accelKeysMove > 3.5) { return 30; } return (!(UIInput.mainCursor.accelKeysMove > 2f)) ? 1 : 10; }), new CodeInstruction(OpCodes.Mul, (object)null) }); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(Math), "SecondsToString")] [HarmonyPrefix] private static bool ChangeTimeFormat(Math __instance, int seconds, ref string __result) { if (seconds >= 359999) { __result = "99:59:59"; return false; } __result = Mathf.FloorToInt((float)(seconds / 3600)).ToString("00") + ":" + (seconds / 60 % 60).ToString("00") + ":" + (seconds % 60).ToString("00"); return false; } [HarmonyPatch(typeof(LLImageText), "InitNeeded")] [HarmonyPrefix] private static void AddMoreImages(LLImageText __instance) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if (__instance == null || ((Object)__instance).name != "Time") { return; } Image[] array = (Image[])(object)new Image[8]; float num = 14 * (-array.Length + 2); for (int i = 0; i < array.Length; i++) { if (i < __instance.images.Length) { array[i] = __instance.images[i]; } else { array[i] = Object.Instantiate(__instance.images[0], ((Component)__instance).transform); ((Object)array[i]).name = $"im{i}"; } RectTransform rectTransform = ((Graphic)array[i]).rectTransform; rectTransform.anchoredPosition = Vector2.op_Implicit(new Vector3(num, 0f, 0f)); rectTransform.sizeDelta = new Vector2(8.25f, 15f); num += 14f; } __instance.images = array; __instance.alignment = (TextAlignment)2; } [HarmonyPatch(typeof(LLImageText), "InitNeeded")] [HarmonyPostfix] private static void DoAfter(LLImageText __instance) { if (__instance != null && !(((Object)__instance).name != "Time")) { __instance.charWidth = 7f; __instance.xMax = 20f; } } } [BepInPlugin("com.github.daioutzu.moretime", "MoreTime", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; internal static ConfigEntry maxTimeInSeconds; internal static Harmony Harmony { get; private set; } = new Harmony("com.github.daioutzu.moretime"); private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; ConfigSetup(); Harmony.PatchAll(typeof(Patches)); Logger.LogInfo((object)"Plugin com.github.daioutzu.moretime is loaded!"); } private void ConfigSetup() { maxTimeInSeconds = ((BaseUnityPlugin)this).Config.Bind("General", "MaxTime", 86400, "The maximum time (in seconds) for match duration. Absolute max is 359999"); if (maxTimeInSeconds.Value < 600) { Logger.LogFatal((object)"MaxTime MUST be greater than 10 minutes aka 600 seconds"); maxTimeInSeconds.Value = (int)((ConfigEntryBase)maxTimeInSeconds).DefaultValue; } if (maxTimeInSeconds.Value > 359999) { Logger.LogFatal((object)"MaxTime MUST be below 359,999 seconds"); maxTimeInSeconds.Value = 359999; } int value = maxTimeInSeconds.Value; int num = value % 60; if (num != 0) { maxTimeInSeconds.Value = value - num; } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.daioutzu.moretime"; public const string PLUGIN_NAME = "MoreTime"; public const string PLUGIN_VERSION = "1.0.0"; } }