using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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 HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExtraPerkChoices")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExtraPerkChoices")]
[assembly: AssemblyTitle("ExtraPerkChoices")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ExtraPerkChoices;
[BepInPlugin("x753.Extra_Perk_Choices", "Extra_Perk_Choices", "1.0.0")]
public class ExtraPerkChoicesMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(ShopManager), "ChooseShopSize")]
private class ShopManager_ChooseShopSize_Patch
{
[HarmonyPostfix]
public static void ShopManager_ChooseShopSize_Postfix(ref int __result)
{
int extraPerkChoices = ExtraPerkChoices;
__result += extraPerkChoices;
ModLogger.LogInfo((object)$"Increased the number of perk choices by {extraPerkChoices}!");
}
}
[HarmonyPatch(typeof(ShopManager), "Awake")]
private class ShopManager_Awake_Patch
{
[HarmonyPostfix]
public static void ShopManager_Awake_Postfix(ShopManager __instance)
{
GameObject gameObject = ((Component)__instance.upgradeCards[0]).gameObject;
for (int i = 0; i < ExtraPerkChoices; i++)
{
BonusCardScript component = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent).GetComponent<BonusCardScript>();
component.cardId = 4 + i;
__instance.upgradeCards.Add(component);
__instance.cardButtons.Add(((Component)((Component)component).transform.Find("Card Graphic")).GetComponent<Button>());
__instance.slidingImages = __instance.slidingImages.Concat((IEnumerable<RectTransform>)(object)new RectTransform[1] { ((Component)component).GetComponent<RectTransform>() }).ToArray();
}
__instance.numberOfShopItems = 3 + ExtraPerkChoices;
}
}
[HarmonyPatch(typeof(ShopManager), "ShowShop")]
private class ShopManager_ShowShop_Patch
{
[HarmonyPostfix]
public static void ShopManager_ShowShop_Postfix(ShopManager __instance)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
GridLayoutGroup gridLayoutGroup = __instance.gridLayoutGroup;
gridLayoutGroup.constraint = (Constraint)2;
gridLayoutGroup.constraintCount = 1;
float num = 1f;
if (__instance.numberOfShopItems > 10)
{
GridLayoutGroup gridLayoutGroup2 = __instance.gridLayoutGroup;
int numberOfShopItems = __instance.numberOfShopItems;
float x = gridLayoutGroup2.cellSize.x;
float x2 = gridLayoutGroup2.spacing.x;
float num2 = (float)numberOfShopItems * x + (float)(numberOfShopItems - 1) * x2;
Rect rect = ((RectTransform)((Transform)__instance.cardGridRT).parent).rect;
float width = ((Rect)(ref rect)).width;
num = Mathf.Min(1f, width / num2);
}
else if (__instance.numberOfShopItems > 3)
{
num = 1f - 0.05f * (float)__instance.numberOfShopItems;
}
((Transform)__instance.cardGridRT).localScale = new Vector3(num, num, 0f);
((Behaviour)__instance.gridLayoutGroup).enabled = true;
}
}
private const string modGUID = "x753.Extra_Perk_Choices";
private const string modName = "Extra_Perk_Choices";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("x753.Extra_Perk_Choices");
internal static ManualLogSource ModLogger;
public static ExtraPerkChoicesMod Instance;
public static int ExtraPerkChoices;
private void Awake()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
harmony.PatchAll();
ModLogger = Logger.CreateLogSource("Extra_Perk_Choices");
ModLogger.LogInfo((object)"Plugin Extra_Perk_Choices is loaded!");
ExtraPerkChoices = ((BaseUnityPlugin)this).Config.Bind<int>("Perks", "Extra Perk Choices", 2, new ConfigDescription("The number of extra perks you can choose from when beating a round (0-16)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 16), Array.Empty<object>())).Value;
}
}