using System;
using System.Diagnostics;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Panik;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 VibeGambling
{
[BepInPlugin("VibeGambling.cloverpit.VibeGambling", "Vibe Gambling", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "VibeGambling.cloverpit.VibeGambling";
public const string PluginName = "Vibe Gambling";
public const string PluginVer = "1.0.1";
internal const Identifier Card = (Identifier)19;
internal static ManualLogSource Log;
internal static readonly Harmony Harmony = new Harmony("VibeGambling.cloverpit.VibeGambling");
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<int> DebtPercent;
internal static ConfigEntry<bool> NeverRunOut;
internal static ConfigEntry<bool> UnlockIfLocked;
internal static ConfigEntry<string> CardTitle;
internal static bool Active => Enabled.Value;
private void Awake()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace the 'Delusions of Grandeur' Memory Card with the Vibe Gambling card. Set false to get the original card back.");
DebtPercent = ((BaseUnityPlugin)this).Config.Bind<int>("General", "DebtPercent", 1, new ConfigDescription("Percent of the normal deadline debt you have to pay when the card is picked for a run.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
NeverRunOut = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NeverRunOut", true, "Memory Cards normally get used up when you start a run with them. If true, this card always has at least 1 copy.");
UnlockIfLocked = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnlockIfLocked", true, "If you never unlocked 'Delusions of Grandeur', treat it as unlocked so it shows face up in the deck and can be picked.");
CardTitle = ((BaseUnityPlugin)this).Config.Bind<string>("Text", "Title", "Vibe Gambling", "Name shown for the card.");
Harmony.PatchAll(typeof(Patches));
Log.LogInfo((object)string.Format("{0} {1} loaded. Card: Delusions of Grandeur -> {2} ({3}% deadlines).", "Vibe Gambling", "1.0.1", CardTitle.Value, DebtPercent.Value));
}
internal static bool CardInPlay()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Invalid comparison between Unknown and I4
if (Active && GameplayData.Instance != null)
{
return (int)GameplayData.RunModifier_GetCurrent() == 19;
}
return false;
}
internal static string Description()
{
return "You already saw the light. Now it's just you and the machine. For the rest of the run, each deadline only asks you to deposit <color=orange>" + DebtPercent.Value + "%</color> of the usual amount. No pressure, no trapdoor anxiety, just spin. <color=red>Runs with this card don't count for the Leaderboard.</color>";
}
}
[HarmonyPatch]
internal static class Patches
{
internal const int StartingDeposit = 30;
[HarmonyPatch(typeof(GameplayData), "DebtGetExt")]
[HarmonyPostfix]
private static void DebtGetExt_Postfix(ref BigInteger __result)
{
try
{
if (!Plugin.CardInPlay() || __result <= BigInteger.Zero)
{
return;
}
int value = Plugin.DebtPercent.Value;
BigInteger bigInteger = __result / 2;
BigInteger bigInteger2 = 30;
BigInteger bigInteger4;
if (bigInteger > bigInteger2)
{
BigInteger bigInteger3 = ((bigInteger - bigInteger2) * value + 99) / 100;
if (bigInteger3 < BigInteger.One)
{
bigInteger3 = BigInteger.One;
}
bigInteger4 = bigInteger2 + bigInteger3;
}
else
{
bigInteger4 = (bigInteger * value + 99) / 100;
if (bigInteger4 < BigInteger.One)
{
bigInteger4 = BigInteger.One;
}
}
__result = bigInteger4;
}
catch (Exception ex)
{
Plugin.Log.LogError((object)("DebtGetExt patch: " + ex));
}
}
[HarmonyPatch(typeof(RunModifierScript), "TitleGet")]
[HarmonyPostfix]
private static void TitleGet_Postfix(Identifier identifier, ref string __result)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
if (Plugin.Active && (int)identifier == 19)
{
__result = Plugin.CardTitle.Value;
}
}
[HarmonyPatch(typeof(RunModifierScript), "DescriptionGet", new Type[] { typeof(Identifier) })]
[HarmonyPostfix]
private static void DescriptionGet_Postfix(Identifier identifier, ref string __result)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
if (!Plugin.Active || (int)identifier != 19)
{
return;
}
try
{
__result = Strings.Sanitize((SantizationKind)4, Plugin.Description(), (SanitizationSubKind)0);
}
catch
{
__result = Plugin.Description();
}
}
[HarmonyPatch(typeof(GameData), "RunModifier_OwnedCount_Get")]
[HarmonyPostfix]
private static void OwnedCount_Postfix(Identifier identifier, ref int __result)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (Plugin.Active && Plugin.NeverRunOut.Value && (int)identifier == 19 && __result == 0)
{
__result = 1;
}
}
[HarmonyPatch(typeof(GameData), "RunModifier_UnlockedTimes_Get")]
[HarmonyPostfix]
private static void UnlockedTimes_Postfix(Identifier identifier, ref int __result)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (Plugin.Active && Plugin.UnlockIfLocked.Value && (int)identifier == 19 && __result <= 0)
{
__result = 1;
}
}
[HarmonyPatch(typeof(PlatformAPI), "Leaderboards_PlayerHighcoreSet_Try")]
[HarmonyPrefix]
private static bool Leaderboard_Prefix(ref bool __result)
{
if (!Plugin.CardInPlay())
{
return true;
}
__result = false;
return false;
}
}
}