using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CloverAPI.Content.Data;
using CloverAPI.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Panik;
using QOLverPit.Patches;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("QOLverPit")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QOLverPit")]
[assembly: AssemblyTitle("QOLverPit")]
[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 QOLverPit
{
public static class Logging
{
public static ManualLogSource Logger => Plugin.Log;
public static void Log(LogLevel level, object message)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Logger.Log(level, message);
}
public static void LogInfo(object message)
{
Logger.LogInfo(message);
}
public static void LogDebug(object message)
{
Logger.LogDebug(message);
}
public static void LogWarning(object message)
{
Logger.LogWarning(message);
}
public static void LogError(object message)
{
Logger.LogError(message);
}
public static void LogFatal(object message)
{
Logger.LogFatal(message);
}
}
[BepInPlugin("IngoH.cloverpit.QOLverPit", "QOLverPit", "1.0.0")]
[HarmonyPatch]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "IngoH.cloverpit.QOLverPit";
public const string PluginName = "QOLverPit";
public const string PluginVer = "1.0.0";
internal static ManualLogSource Log;
internal static readonly Harmony Harmony = new Harmony("IngoH.cloverpit.QOLverPit");
internal static string PluginPath;
internal const string MainContentFolder = "QOLverPit_Content";
internal static ConfigEntry<KeyboardElement> ChangeDepositModeKeyboardKey;
internal static ConfigEntry<MouseElement> ChangeDepositModeMouseButton;
internal static ConfigEntry<JoystickElement> ChangeDepositModeControllerButton;
internal static ConfigEntry<KeyboardElement> ChangeDepositModeReverseKeyboardKey;
internal static ConfigEntry<MouseElement> ChangeDepositModeReverseMouseButton;
internal static ConfigEntry<JoystickElement> ChangeDepositModeReverseControllerButton;
internal static ConfigEntry<bool> AllowMaxPlus;
internal static ConfigEntry<float> TransitionSpeedMultiplier;
internal static ConfigEntry<float> GameSpeedMultiplier;
internal static ConfigEntry<bool> SkipSplashScreens;
private float mouseAxisDelay = 0f;
private float controllerAxisDelay = 0f;
public static string DataPath { get; private set; }
public static string ImagePath { get; private set; }
internal static bool Ready => GameUtils.GameReady;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
DataPath = Path.Combine(PluginPath, "QOLverPit_Content", "Data");
ImagePath = Path.Combine(PluginPath, "QOLverPit_Content", "Images");
MakeConfig();
Time.timeScale = GameSpeedMultiplier.Value;
}
private void MakeConfig()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Expected O, but got Unknown
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Expected O, but got Unknown
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Expected O, but got Unknown
ChangeDepositModeKeyboardKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardElement>("Controls", "Keyboard: Change Deposit Mode", (KeyboardElement)17, new ConfigDescription("Key to change the deposit amount mode. Set to None to disable.", (AcceptableValueBase)null, Array.Empty<object>()));
ChangeDepositModeMouseButton = ((BaseUnityPlugin)this).Config.Bind<MouseElement>("Controls", "Mouse: Change Deposit Mode", (MouseElement)3, new ConfigDescription("Mouse button to change the deposit amount mode. Set to Undefined to disable. Setting it to scroll wheel makes it work in both directions.", (AcceptableValueBase)null, Array.Empty<object>()));
ChangeDepositModeControllerButton = ((BaseUnityPlugin)this).Config.Bind<JoystickElement>("Controls", "Controller: Change Deposit Mode", (JoystickElement)9, new ConfigDescription("Button to change the deposit amount mode. Set to Undefined to disable. Setting it to a stick makes it work in both directions.", (AcceptableValueBase)null, Array.Empty<object>()));
ChangeDepositModeReverseKeyboardKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardElement>("Controls", "Keyboard: Change Deposit Mode (Reverse)", (KeyboardElement)0, new ConfigDescription("Key to change the deposit amount mode in reverse order. Set to None to disable.", (AcceptableValueBase)null, Array.Empty<object>()));
ChangeDepositModeReverseMouseButton = ((BaseUnityPlugin)this).Config.Bind<MouseElement>("Controls", "Mouse: Change Deposit Mode (Reverse)", (MouseElement)8, new ConfigDescription("Mouse button to change the deposit amount mode in reverse order. Set to Undefined to disable. Setting it to scroll wheel makes it work in both directions.", (AcceptableValueBase)null, Array.Empty<object>()));
ChangeDepositModeReverseControllerButton = ((BaseUnityPlugin)this).Config.Bind<JoystickElement>("Controls", "Controller: Change Deposit Mode (Reverse)", (JoystickElement)10, new ConfigDescription("Button to change the deposit amount mode in reverse order. Set to Undefined to disable. Setting it to a stick makes it work in both directions.", (AcceptableValueBase)null, Array.Empty<object>()));
AllowMaxPlus = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Allow Max Plus Deposit Mode", false, new ConfigDescription("If true, the Max Plus deposit mode will be available when changing deposit modes. This mode deposits the maximum amount of coins up to one coin less than the remaining debt. This isn't normally possible due to deposits being in steps of 5%, so this may be considered cheating.", (AcceptableValueBase)null, Array.Empty<object>()));
TransitionSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "Transition Speed Multiplier", 1f, new ConfigDescription("How much faster transitions should be. Overrides the in-game setting if not 1. Must be greater than 0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1000f), Array.Empty<object>()));
GameSpeedMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "Game Speed Multiplier", 1f, new ConfigDescription("How much faster the game should be. Beware! This can cause physics issues if set too high. Must be greater than 0.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 100f), Array.Empty<object>()));
SkipSplashScreens = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Skip Splash Screens", false, new ConfigDescription("If true, the splash screens will be skipped on game start. Won't apply on first launch before language selection.", (AcceptableValueBase)null, Array.Empty<object>()));
GameSpeedMultiplier.SettingChanged += delegate
{
Time.timeScale = GameSpeedMultiplier.Value;
};
ModSettingsManager.RegisterPageFromConfig((BaseUnityPlugin)(object)this, "QOLverPit", (string[])null, (string[])null, (Action<PageBuilder>)null);
}
private void OnEnable()
{
Harmony.PatchAll();
Logging.LogInfo("Loaded QOLverPit!");
}
private void OnDisable()
{
Harmony.UnpatchSelf();
Logging.LogInfo("Unloaded QOLverPit!");
}
private void Update()
{
if (Ready)
{
mouseAxisDelay -= Time.unscaledDeltaTime;
controllerAxisDelay -= Time.unscaledDeltaTime;
if (KeyboardFwd() || MouseFwd() || ControllerFwd())
{
DepositPatch.CycleDepositMode();
}
else if (KeyboardRev() || MouseRev() || ControllerRev())
{
DepositPatch.CycleDepositMode(reverse: true);
}
}
}
private bool KeyboardFwd()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return Controls.KeyboardButton_PressedGet(0, ChangeDepositModeKeyboardKey.Value);
}
private bool KeyboardRev()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return Controls.KeyboardButton_PressedGet(0, ChangeDepositModeReverseKeyboardKey.Value);
}
private bool MouseFwd()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if (((Controls.MouseElement_IsAxis(ChangeDepositModeMouseButton.Value) && Controls.MouseAxis_ValueGet(0, ChangeDepositModeMouseButton.Value) > 0f) || (Controls.MouseElement_IsAxis(ChangeDepositModeReverseMouseButton.Value) && Controls.MouseAxis_ValueGet(0, ChangeDepositModeReverseMouseButton.Value) < 0f)) && mouseAxisDelay <= 0f)
{
mouseAxisDelay = 0.05f;
return true;
}
return Controls.MouseElement_IsButton(ChangeDepositModeMouseButton.Value) && Controls.MouseButton_PressedGet(0, ChangeDepositModeMouseButton.Value);
}
private bool MouseRev()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if (((Controls.MouseElement_IsAxis(ChangeDepositModeMouseButton.Value) && Controls.MouseAxis_ValueGet(0, ChangeDepositModeMouseButton.Value) < 0f) || (Controls.MouseElement_IsAxis(ChangeDepositModeReverseMouseButton.Value) && Controls.MouseAxis_ValueGet(0, ChangeDepositModeReverseMouseButton.Value) > 0f)) && mouseAxisDelay <= 0f)
{
mouseAxisDelay = 0.05f;
return true;
}
return Controls.MouseElement_IsButton(ChangeDepositModeReverseMouseButton.Value) && Controls.MouseButton_PressedGet(0, ChangeDepositModeReverseMouseButton.Value);
}
private bool ControllerFwd()
{
//IL_0006: 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)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
if (((Controls.JoystickElement_IsAxis(ChangeDepositModeControllerButton.Value) && Math.Abs(Controls.JoystickAxis_ValueGet(0, ChangeDepositModeControllerButton.Value)) > 0.5f) || (Controls.JoystickElement_IsAxis(ChangeDepositModeReverseControllerButton.Value) && Math.Abs(Controls.JoystickAxis_ValueGet(0, ChangeDepositModeReverseControllerButton.Value)) > 0.5f)) && controllerAxisDelay <= 0f)
{
controllerAxisDelay = 0.2f;
return true;
}
return Controls.JoystickButton_PressedGet(0, ChangeDepositModeControllerButton.Value);
}
private bool ControllerRev()
{
//IL_0006: 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)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
if (((Controls.JoystickElement_IsAxis(ChangeDepositModeControllerButton.Value) && Math.Abs(Controls.JoystickAxis_ValueGet(0, ChangeDepositModeControllerButton.Value)) > 0.5f) || (Controls.JoystickElement_IsAxis(ChangeDepositModeReverseControllerButton.Value) && Math.Abs(Controls.JoystickAxis_ValueGet(0, ChangeDepositModeReverseControllerButton.Value)) > 0.5f)) && controllerAxisDelay <= 0f)
{
controllerAxisDelay = 0.2f;
return true;
}
return Controls.JoystickButton_PressedGet(0, ChangeDepositModeReverseControllerButton.Value);
}
}
}
namespace QOLverPit.Patches
{
[HarmonyPatch]
internal class DepositPatch
{
internal enum DepositMode
{
Normal,
Max,
MaxPlus,
All,
Count
}
internal static DepositMode _currentDepositMode;
private static bool _skipDelay;
[HarmonyPatch(typeof(GameplayData), "NextDepositAmmountGet")]
[HarmonyPrefix]
internal static bool NextDepositAmmountGet_Prefix(ref BigInteger __result)
{
BigInteger bigInteger = GameplayData.DebtGet();
BigInteger bigInteger2 = ((bigInteger <= 1073741823L) ? ((BigInteger)Mathf.FloorToInt((float)ClassExtensions.CastToInt(bigInteger) / 20f)) : (bigInteger / 20));
BigInteger bigInteger3 = GameplayData.CoinsGet();
BigInteger bigInteger4 = GameplayData.DebtMissingGet();
BigInteger bigInteger5 = GameplayData.SpinCostMax_Get();
switch (_currentDepositMode)
{
case DepositMode.Max:
if (bigInteger3 <= bigInteger5)
{
return true;
}
if (bigInteger3 >= bigInteger4 + bigInteger5)
{
__result = BigInteger.Min(BigInteger.Max(1, (bigInteger4 - 1) / bigInteger2) * bigInteger2, bigInteger4);
}
else
{
__result = bigInteger3 - bigInteger5;
}
return false;
case DepositMode.MaxPlus:
if (bigInteger3 <= bigInteger5)
{
return true;
}
if (bigInteger3 >= bigInteger4 + bigInteger5)
{
__result = BigInteger.Max(1, bigInteger4 - 1);
}
else
{
__result = bigInteger3 - bigInteger5;
}
return false;
case DepositMode.All:
__result = BigInteger.Min(bigInteger3, bigInteger4);
return false;
default:
return true;
}
}
[HarmonyPatch(typeof(PromptGuideScript), "SetGuideType")]
[HarmonyPostfix]
internal static void SetGuideType_Postfix(GuideType type)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
if ((int)type == 4 && _currentDepositMode != 0 && !ATMScript.Button_DealIsRunning() && !(GameplayData.CoinsGet() < GameplayData.NextDepositAmmountGet(false)))
{
TextMeshProUGUI text = PromptGuideScript.instance.text;
((TMP_Text)text).text = ((TMP_Text)text).text + " " + GetModeText();
}
}
internal static void CycleDepositMode(bool reverse = false)
{
int num = ((!reverse) ? 1 : (-1));
_currentDepositMode = (DepositMode)nmod((int)(_currentDepositMode + num), 4);
if (!Plugin.AllowMaxPlus.Value && _currentDepositMode == DepositMode.MaxPlus)
{
_currentDepositMode = (DepositMode)nmod((int)(_currentDepositMode + num), 4);
}
DiegeticMenuController activeMenu = DiegeticMenuController.ActiveMenu;
DiegeticMenuElement val = ((activeMenu != null) ? activeMenu.HoveredElement : null);
if ((Object)(object)val != (Object)null)
{
_skipDelay = true;
val.RefreshHovering(true);
}
}
[HarmonyPatch(typeof(DiegeticMenuController), "Update")]
[HarmonyPostfix]
internal static void DiegeticMenuController_Update_Postfix(DiegeticMenuController __instance)
{
if (_skipDelay && (Object)(object)__instance == (Object)(object)DiegeticMenuController.ActiveMenu && __instance.runningDelay > 0f)
{
_skipDelay = false;
__instance.runningDelay = 0f;
}
}
private static int nmod(int x, int m)
{
return (x % m + m) % m;
}
internal static string GetModeText()
{
DepositMode currentDepositMode = _currentDepositMode;
if (1 == 0)
{
}
string result = currentDepositMode switch
{
DepositMode.Normal => "(Normal)",
DepositMode.Max => "(Max)",
DepositMode.MaxPlus => "(Max+)",
DepositMode.All => "(All)",
_ => "",
};
if (1 == 0)
{
}
return result;
}
}
[HarmonyPatch]
public class IntroPatch
{
[HarmonyPatch(typeof(IntroScript), "Start")]
[HarmonyPrefix]
internal static bool IntroScript_Start_Postfix(IntroScript __instance)
{
if (Plugin.SkipSplashScreens.Value && Data.settings.initialLanguageSelectionPerfromed)
{
((Component)__instance.languageSelectionHolder).gameObject.SetActive(false);
__instance.popUpHolder.SetActive(false);
__instance.autosaveWarningHolder.SetActive(false);
__instance.publisherIntroHolder.SetActive(false);
__instance.developerIntroHolder.SetActive(false);
__instance.musicianIntroHolder.SetActive(false);
Level.GoTo((SceneIndex)2, false);
return false;
}
return true;
}
}
[HarmonyPatch]
internal class TitleScreenPatch
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static OptionEvent <>9__0_0;
internal void <ScreenMenuScript_Open_Prefix>b__0_0()
{
Sound.Play("SoundMenuSelect", 1f, 1f);
GameplayMaster.SetGamePhase((GamePhase)8, false, (string)null);
}
}
[HarmonyPatch(typeof(ScreenMenuScript), "Open")]
[HarmonyPrefix]
internal static void ScreenMenuScript_Open_Prefix(ref string[] options, ref OptionEvent[] optionEvents)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
string match = Strings.Sanitize((SantizationKind)2, Translation.Get("SCREEN_MENU_OPTION_NEW_RUN"), (SanitizationSubKind)0);
if (options == null || options.Length == 0 || !options.Any((string x) => x == match))
{
return;
}
options = options.Append(Translation.Get("MENU_OPTION_QUIT")).ToArray();
OptionEvent[] source = optionEvents;
object obj = <>c.<>9__0_0;
if (obj == null)
{
OptionEvent val = delegate
{
Sound.Play("SoundMenuSelect", 1f, 1f);
GameplayMaster.SetGamePhase((GamePhase)8, false, (string)null);
};
<>c.<>9__0_0 = val;
obj = (object)val;
}
optionEvents = source.Append((OptionEvent)obj).ToArray();
}
}
[HarmonyPatch]
public class TransitionSpeedPatch
{
[HarmonyPatch(typeof(SettingsData), "TransitionSpeedMapped_Get")]
[HarmonyPrefix]
internal static void TransitionSpeedMapped_Get_Prefix(ref float from)
{
if (!Mathf.Approximately(Plugin.TransitionSpeedMultiplier.Value, 1f))
{
from = Plugin.TransitionSpeedMultiplier.Value;
}
}
}
}