using System;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.binbin.TemporaryInjuries")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2feef7a93fa68d71e2424393046751303522f64d")]
[assembly: AssemblyProduct("TemporaryInjuries")]
[assembly: AssemblyTitle("com.binbin.TemporaryInjuries")]
[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 TemporaryInjuries
{
[BepInPlugin("com.binbin.TemporaryInjuries", "TemporaryInjuries", "1.0.0")]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
internal int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));
private readonly Harmony harmony = new Harmony("com.binbin.TemporaryInjuries");
internal static ManualLogSource Log;
public static string debugBase = "com.binbin.TemporaryInjuries ";
public static ConfigEntry<bool> EnableTemporaryInjuries { get; set; }
public static ConfigEntry<bool> EnableHighCostInjuries { get; set; }
public static ConfigEntry<float> HighCostInjuryMultiplier { get; set; }
private void Awake()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0047: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
//IL_0078: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Expected O, but got Unknown
//IL_00ad: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"com.binbin.TemporaryInjuries 1.0.0 has loaded!");
EnableTemporaryInjuries = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("TemporaryInjuries", "EnableTemporaryInjuries"), true, new ConfigDescription("If false, disables the mod. Restart the game upon changing this setting.", (AcceptableValueBase)null, Array.Empty<object>()));
EnableHighCostInjuries = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("TemporaryInjuries", "EnableHighCostInjuries"), true, new ConfigDescription("If true, increases the cost of injuries on Base Madness 9 to compensate for making them removeable.", (AcceptableValueBase)null, Array.Empty<object>()));
HighCostInjuryMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("TemporaryInjuries", "HighCostInjuryMultiplier"), 5f, new ConfigDescription("Multiplier for the cost of injuries.", (AcceptableValueBase)null, Array.Empty<object>()));
if (EnableTemporaryInjuries.Value)
{
LogDebug("Excuting Patches");
harmony.PatchAll();
}
}
internal static void LogDebug(string msg)
{
Log.LogDebug((object)(debugBase + msg));
}
internal static void LogInfo(string msg)
{
Log.LogInfo((object)(debugBase + msg));
}
internal static void LogError(string msg)
{
Log.LogError((object)(debugBase + msg));
}
}
[HarmonyPatch]
public class TemporaryInjuries
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CardCraftManager), "ShowElements")]
public static void ShowElementsPostfix(ref CardCraftManager __instance, string direction, string cardId = "")
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Invalid comparison between Unknown and I4
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Invalid comparison between Unknown and I4
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Invalid comparison between Unknown and I4
Plugin.LogInfo("ShowElementsPostfix");
if (__instance.craftType != 1 || direction == "")
{
return;
}
if ((Object)(object)Globals.Instance == (Object)null || (Object)(object)AtOManager.Instance == (Object)null)
{
Plugin.LogDebug("Null Instance");
return;
}
CardData cardData = Globals.Instance.GetCardData(cardId, false);
bool flag = true;
bool flag2 = false;
Hero value = Traverse.Create((object)__instance).Field("currentHero").GetValue<Hero>();
if (value == null)
{
Plugin.LogError("Null currentHero");
return;
}
if ((int)cardData.CardClass == 6 && AtOManager.Instance.GetNgPlus(false) >= 9)
{
flag2 = false;
}
else if ((int)cardData.CardClass == 6 || (int)cardData.CardClass == 7)
{
if (value.GetTotalCardsInDeck(false) <= 15)
{
flag = false;
}
}
else if (value.GetTotalCardsInDeck(true) <= 15)
{
flag = false;
}
BotonGeneric value2 = Traverse.Create((object)__instance).Field("BG_Remove").GetValue<BotonGeneric>();
if ((Object)(object)value2 == (Object)null)
{
Plugin.LogError("Null BG_Remove");
return;
}
if (!flag2 && (flag || AtOManager.Instance.Sandbox_noMinimumDecksize))
{
if (__instance.CanBuy("Remove", ""))
{
value2.Enable();
}
else
{
value2.Disable();
}
}
else
{
value2.Disable();
}
Traverse.Create((object)__instance).Field("BG_Remove").SetValue((object)value2);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CardCraftManager), "SelectCard")]
public static void SelectCardPostfix(ref CardCraftManager __instance, string cardName)
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
Plugin.LogInfo("SelectCardPostfix");
string[] array = cardName.Split('_');
string text = array[0];
float num = 5f;
Plugin.EnableHighCostInjuries.Value = true;
if (!Plugin.EnableHighCostInjuries.Value)
{
Plugin.LogDebug("High Cost Injuries Disabled");
return;
}
CardData value = Traverse.Create((object)__instance).Field("cardData").GetValue<CardData>();
if ((int)value.CardClass != 6 || AtOManager.Instance.GetNgPlus(false) < 9)
{
return;
}
BotonGeneric value2 = Traverse.Create((object)__instance).Field("BG_Remove").GetValue<BotonGeneric>();
int value3 = Traverse.Create((object)__instance).Field("costRemove").GetValue<int>();
Plugin.LogDebug($"Starting costRemove = {value3}");
if (__instance.craftType == 1)
{
__instance.oldcostRemoveText.text = "";
value3 = Mathf.RoundToInt((float)SetPrice(__instance, "Remove", "") * num);
Plugin.LogDebug($"SetPrice costRemove = {value3}");
value2.SetText(__instance.ButtonText(value3));
Traverse.Create((object)__instance).Field("costRemove").SetValue((object)value3);
Traverse.Create((object)__instance).Field("BG_Remove").SetValue((object)value2);
Plugin.LogDebug("PostTraverses");
int num2 = SetPrice(__instance, "Remove", "", "", 0, useShopDiscount: false);
if (num2 != value3)
{
__instance.oldcostRemoveText.text = string.Format(Texts.Instance.GetText("oldCost", ""), num2.ToString());
}
__instance.ShowElements("Remove", text);
}
}
public static int SetPrice(CardCraftManager __instance, string function, string rarity, string cardName = "", int zoneTier = 0, bool useShopDiscount = true)
{
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Invalid comparison between Unknown and I4
Plugin.LogDebug("SetPriceLocal");
int num = 0;
bool value = Traverse.Create((object)__instance).Field("isPetShop").GetValue<bool>();
CardData value2 = Traverse.Create((object)__instance).Field("cardData").GetValue<CardData>();
int value3 = Traverse.Create((object)__instance).Field("discount").GetValue<int>();
if ((Object)(object)value2 == (Object)null)
{
Plugin.LogError("Invalid SetPrice Traverse");
return 0;
}
if (value)
{
Plugin.LogDebug("isPetShop");
if (cardName != "")
{
rarity = Enum.GetName(typeof(CardRarity), Globals.Instance.GetCardData(cardName, false).CardRarity);
}
if (rarity.ToLower() == "common")
{
num = 72;
}
else if (rarity.ToLower() == "uncommon")
{
num = 156;
}
else if (rarity.ToLower() == "rare")
{
num = 348;
}
else if (rarity.ToLower() == "epic")
{
num = 744;
}
else if (rarity.ToLower() == "mythic")
{
num = 1200;
}
}
else
{
switch (function)
{
case "Remove":
Plugin.LogDebug("IsRemove");
if (zoneTier == 0 && GameManager.Instance.IsSingularity())
{
num = 0;
break;
}
num = Globals.Instance.GetRemoveCost(value2.CardType, value2.CardRarity);
if ((int)value2.CardType == 18)
{
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_4"))
{
num -= Functions.FuncRoundToInt((float)num * 0.3f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_2"))
{
num -= Functions.FuncRoundToInt((float)num * 0.15f);
}
break;
}
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_5"))
{
num -= Functions.FuncRoundToInt((float)num * 0.5f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_3"))
{
num -= Functions.FuncRoundToInt((float)num * 0.25f);
}
if (!AtOManager.Instance.CharInTown())
{
break;
}
if (AtOManager.Instance.GetTownTier() == 1)
{
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_6"))
{
num = 0;
}
}
else if (AtOManager.Instance.GetTownTier() == 0 && PlayerManager.Instance.PlayerHaveSupply("townUpgrade_3_1"))
{
num = 0;
}
break;
case "Upgrade":
case "Transform":
num = Globals.Instance.GetUpgradeCost(function, rarity);
if (function == "Upgrade")
{
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_6"))
{
num -= Functions.FuncRoundToInt((float)num * 0.5f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_4"))
{
num -= Functions.FuncRoundToInt((float)num * 0.3f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_2"))
{
num -= Functions.FuncRoundToInt((float)num * 0.15f);
}
}
if (function == "Transform")
{
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_5"))
{
num = 0;
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_3"))
{
num -= Functions.FuncRoundToInt((float)num * 0.5f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_1"))
{
num -= Functions.FuncRoundToInt((float)num * 0.25f);
}
}
break;
case "Craft":
{
float num2 = 0f;
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_1_5"))
{
num2 = 0.3f;
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_1_2"))
{
num2 = 0.15f;
}
float num3 = 0f;
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_6"))
{
num3 = 0.5f;
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_4"))
{
num3 = 0.3f;
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_2_2"))
{
num3 = 0.15f;
}
num = Globals.Instance.GetCraftCost(cardName, num2, num3, zoneTier);
break;
}
case "Item":
num = Globals.Instance.GetItemCost(cardName);
if (AtOManager.Instance.CharInTown())
{
if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_5_5"))
{
num -= Functions.FuncRoundToInt((float)num * 0.3f);
}
else if (PlayerManager.Instance.PlayerHaveSupply("townUpgrade_5_2"))
{
num -= Functions.FuncRoundToInt((float)num * 0.15f);
}
}
break;
case "Corruption":
num = 300;
break;
}
}
if (num > 0)
{
int num4 = 0;
for (int i = 0; i < 4; i++)
{
if (AtOManager.Instance.GetHero(i) != null)
{
num4 += ((Character)AtOManager.Instance.GetHero(i)).GetItemDiscountModification();
}
}
int num5 = num4;
if (useShopDiscount)
{
num5 += value3;
}
if (num5 != 0)
{
num -= Functions.FuncRoundToInt((float)(num * num5 / 100));
if (num < 0)
{
num = 0;
}
}
}
if (function == "Corruption" && IsCorruptionEnabled(__instance, 0))
{
num += 400;
}
if (function == "Upgrade" && AtOManager.Instance.Sandbox_cardUpgradePrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)AtOManager.Instance.Sandbox_cardUpgradePrice * 0.01f);
}
else if (function == "Transform" && AtOManager.Instance.Sandbox_cardTransformPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)AtOManager.Instance.Sandbox_cardTransformPrice * 0.01f);
}
else if (function == "Remove" && AtOManager.Instance.Sandbox_cardRemovePrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)AtOManager.Instance.Sandbox_cardRemovePrice * 0.01f);
}
else if (function == "Item" && AtOManager.Instance.Sandbox_itemsPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)AtOManager.Instance.Sandbox_itemsPrice * 0.01f);
}
else if (value && AtOManager.Instance.Sandbox_petsPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)AtOManager.Instance.Sandbox_petsPrice * 0.01f);
}
return num;
}
public static bool IsCorruptionEnabled(CardCraftManager __instance, int _index)
{
Plugin.LogDebug("IsCorruptionEnabledLocal");
if (((Component)__instance.corruptionArrows[_index]).gameObject.activeSelf)
{
return true;
}
return false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.TemporaryInjuries";
public const string PLUGIN_NAME = "TemporaryInjuries";
public const string PLUGIN_VERSION = "1.0.0";
}
}