using System;
using System.Collections;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cards;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Essentials;
using TemporaryInjuries;
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.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1+4003db9795db4a57d3756d11016bdaf56a6440f9")]
[assembly: AssemblyProduct("TemporaryInjuries")]
[assembly: AssemblyTitle("com.binbin.TemporaryInjuries")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.0")]
[module: UnverifiableCode]
[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;
}
}
}
public static class EssentialsCompatibility
{
private static bool? _enabled;
public static bool Enabled
{
get
{
bool valueOrDefault = _enabled == true;
if (!_enabled.HasValue)
{
valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.stiffmeds.obeliskialessentials");
_enabled = valueOrDefault;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void EssentialsRegister()
{
Essentials.RegisterMod(Plugin.PluginName, "binbin", "Exp Normalization", Plugin.PluginVersion, Plugin.ModDate, "https://github.com/binbinmods/ExpNormalization", (string[])null, "", 100, (string[])null, "", true);
Plugin.LogInfo(Plugin.PluginGUID + " " + Plugin.PluginVersion + " has loaded with Essentials!");
}
}
namespace TemporaryInjuries
{
[BepInPlugin("com.binbin.TemporaryInjuries", "TemporaryInjuries", "1.3.1")]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
public static string PluginName;
public static string PluginVersion;
public static string PluginGUID;
internal static 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> EnableDebugging { 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00a9: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00de: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"com.binbin.TemporaryInjuries 1.3.1 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>()));
EnableDebugging = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("TemporaryInjuries", "EnableDebugging"), false, new ConfigDescription("If true, enables debugging messages. 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>()));
PluginName = "TemporaryInjuries";
PluginVersion = "1.3.1";
PluginGUID = "com.binbin.TemporaryInjuries";
if (EnableTemporaryInjuries.Value)
{
if (EssentialsCompatibility.Enabled)
{
EssentialsCompatibility.EssentialsRegister();
}
else
{
LogInfo(PluginGUID + " " + PluginVersion + " has loaded!");
}
harmony.PatchAll();
}
}
internal static void LogDebug(string msg, [CallerMemberName] string caller = "")
{
if (EnableDebugging.Value)
{
Log.LogDebug((object)(debugBase + "- " + caller + " - " + msg));
}
}
internal static void LogInfo(string msg)
{
Log.LogInfo((object)(debugBase + msg));
}
internal static void LogError(string msg, [CallerMemberName] string caller = "")
{
Log.LogError((object)(debugBase + "- " + caller + " - " + msg));
}
public static IEnumerator RunAfter(IEnumerator original, Action action)
{
while (original.MoveNext())
{
yield return original.Current;
}
action();
}
}
[HarmonyPatch]
public class TemporaryInjuries
{
[MethodImpl(MethodImplOptions.NoInlining)]
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(CardCraftManager), "ButtonText")]
public static string ButtonText(CardCraftManager __instance, int cost)
{
throw new NotImplementedException();
}
[MethodImpl(MethodImplOptions.NoInlining)]
[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
[HarmonyPatch(typeof(CardCraftManager), "ShowElements")]
public static void ShowElements(CardCraftManager __instance, string direction, string cardId = "")
{
throw new NotImplementedException();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CardCraftManager), "ShowElements")]
public static void ShowElementsPostfix(ref CardCraftManager __instance, string direction, string cardId = "")
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Invalid comparison between Unknown and I4
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Invalid comparison between Unknown and I4
Plugin.LogDebug("ShowElementsPostfix", "ShowElementsPostfix");
if (__instance.craftType != 1 || direction == "")
{
return;
}
if ((Object)(object)Globals.Instance == (Object)null || (Object)(object)AtOManager.Instance == (Object)null)
{
Plugin.LogDebug("Null Instance", "ShowElementsPostfix");
return;
}
CardRealtimeData 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", "ShowElementsPostfix");
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", "ShowElementsPostfix");
return;
}
if (!flag2 && (flag || SandboxManager.Instance.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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Invalid comparison between Unknown and I4
Plugin.LogInfo("SelectCardPostfix");
if ((Object)(object)__instance == (Object)null)
{
Plugin.LogDebug("Null instance of CardCraftManager", "SelectCardPostfix");
return;
}
string[] array = cardName.Split('_');
string cardId = array[0];
float value = Plugin.HighCostInjuryMultiplier.Value;
if (!Plugin.EnableHighCostInjuries.Value)
{
Plugin.LogDebug("High Cost Injuries Disabled", "SelectCardPostfix");
return;
}
CardRealtimeData value2 = Traverse.Create((object)__instance).Field("cardData").GetValue<CardRealtimeData>();
if ((int)value2.CardClass != 6 || AtOManager.Instance.GetNgPlus(false) < 9 || value2 == (CardRealtimeData)null || __instance.craftType != 1)
{
return;
}
BotonGeneric value3 = Traverse.Create((object)__instance).Field("BG_Remove").GetValue<BotonGeneric>();
if ((Object)(object)value3 == (Object)null)
{
Plugin.LogDebug("No BG_Remove", "SelectCardPostfix");
return;
}
int value4 = Traverse.Create((object)__instance).Field("costRemove").GetValue<int>();
Plugin.LogDebug($"Starting costRemove = {value4}", "SelectCardPostfix");
__instance.oldcostRemoveText.text = "";
value4 = Mathf.RoundToInt((float)SetPrice(__instance, "Remove", "") * value);
Plugin.LogDebug($"SetPrice costRemove = {value4}", "SelectCardPostfix");
value3.SetText(ButtonText(__instance, value4));
Traverse.Create((object)__instance).Field("costRemove").SetValue((object)value4);
Traverse.Create((object)__instance).Field("BG_Remove").SetValue((object)value3);
Plugin.LogDebug("PostTraverses", "SelectCardPostfix");
int num = SetPrice(__instance, "Remove", "", "", 0, useShopDiscount: false);
if (num != value4)
{
__instance.oldcostRemoveText.text = string.Format(Texts.Instance.GetText("oldCost", ""), num.ToString());
}
ShowElements(__instance, "Remove", cardId);
}
public static int SetPrice(CardCraftManager __instance, string function, string rarity, string cardName = "", int zoneTier = 0, bool useShopDiscount = true)
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Invalid comparison between Unknown and I4
Plugin.LogDebug("SetPriceLocal", "SetPrice");
int num = 0;
bool value = Traverse.Create((object)__instance).Field("isPetShop").GetValue<bool>();
CardRealtimeData value2 = Traverse.Create((object)__instance).Field("cardData").GetValue<CardRealtimeData>();
int value3 = Traverse.Create((object)__instance).Field("discount").GetValue<int>();
if (value2 == (CardRealtimeData)null)
{
Plugin.LogError("Invalid SetPrice Traverse", "SetPrice");
return 0;
}
if (value)
{
Plugin.LogDebug("isPetShop", "SetPrice");
if (cardName != "")
{
rarity = Enum.GetName(typeof(CardRarity), value2.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", "SetPrice");
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.team.GetHero(i) != null)
{
num4 += ((Character)AtOManager.Instance.team.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" && SandboxManager.Instance.CardUpgradePrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)SandboxManager.Instance.CardUpgradePrice * 0.01f);
}
else if (function == "Transform" && SandboxManager.Instance.CardTransformPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)SandboxManager.Instance.CardTransformPrice * 0.01f);
}
else if (function == "Remove" && SandboxManager.Instance.CardRemovePrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)SandboxManager.Instance.CardRemovePrice * 0.01f);
}
else if (function == "Item" && SandboxManager.Instance.ItemsPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)SandboxManager.Instance.ItemsPrice * 0.01f);
}
else if (value && SandboxManager.Instance.PetsPrice != 0)
{
num += Functions.FuncRoundToInt((float)num * (float)SandboxManager.Instance.PetsPrice * 0.01f);
}
return num;
}
public static bool IsCorruptionEnabled(CardCraftManager __instance, int _index)
{
Plugin.LogDebug("IsCorruptionEnabledLocal", "IsCorruptionEnabled");
bool? obj;
if (__instance == null)
{
obj = null;
}
else
{
Transform obj2 = __instance.corruptionArrows[_index];
if (obj2 == null)
{
obj = null;
}
else
{
GameObject gameObject = ((Component)obj2).gameObject;
obj = ((gameObject != null) ? new bool?(gameObject.activeSelf) : ((bool?)null));
}
}
bool? flag = obj;
return flag == true;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.TemporaryInjuries";
public const string PLUGIN_NAME = "TemporaryInjuries";
public const string PLUGIN_VERSION = "1.3.1";
}
}