Decompiled source of Obeliskial Content v1.7.10
BepInEx/plugins/com.stiffmeds.obeliskialcontent.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using Cards; using Cards.Data; using Cards.Data.Effects; using Cards.Utility; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; using Obeliskial_Essentials; using UnityEngine; using UnityEngine.SceneManagement; [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("com.stiffmeds.obeliskialcontent")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Content loading library for Across the Obelisk mods.")] [assembly: AssemblyFileVersion("1.7.10.0")] [assembly: AssemblyInformationalVersion("1.7.10")] [assembly: AssemblyProduct("Obeliskial Content")] [assembly: AssemblyTitle("com.stiffmeds.obeliskialcontent")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.7.10.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; } } } namespace ObeliskialContentCompat { internal static class CardImporter { internal static ManualLogSource Log; internal static Func<string, Type, object> FindReference; internal static Func<string, AuraCurseData> GetAuraCurse; internal static Func<string, Sprite> GetSprite; internal static Func<string, AudioClip> GetAudio; private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static int mapped; private static int failed; internal static readonly Dictionary<string, string> PendingRareLinks = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); internal static readonly Dictionary<string, string[]> PendingAddCardLists = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase); private static int soundsTotal; private static int soundsMissing; internal static readonly ConditionalWeakTable<SoundData, string[]> SoundNames = new ConditionalWeakTable<SoundData, string[]>(); internal static CardDataNew Import(JObject json, CardDataNew existing = null) { CardDataNew card = existing ?? ScriptableObject.CreateInstance<CardDataNew>(); string text = Str(json, "ID"); bool flag = (Object)(object)existing != (Object)null; if (!flag) { ((Object)card).name = Str(json, "CardName"); SetS(card, "id", text); SetS(card, "internalId", text); SetS(card, "cardName", Str(json, "CardName")); } SetS(card, "baseCard", Str(json, "BaseCard")); SetS(card, "sku", Str(json, "Sku")); SetI(card, "maxInDeck", Int(json, "MaxInDeck")); SetI(card, "energyCost", Int(json, "EnergyCost")); SetI(card, "grantStanza", Int(json, "GrantStanza")); SetI(card, "damageEnergyBonus", Int(json, "DamageEnergyBonus")); SetI(card, "pushTarget", Int(json, "PushTarget")); SetI(card, "pullTarget", Int(json, "PullTarget")); SetI(card, "acEnergyBonusQuantity", Int(json, "AcEnergyBonusQuantity")); SetI(card, "acEnergyBonus2Quantity", Int(json, "AcEnergyBonus2Quantity")); SetF(card, "selfKillHiddenSeconds", Flt(json, "SelfKillHiddenSeconds")); SetB(card, "playable", Bool(json, "Playable", def: true)); SetB(card, "autoplayDraw", Bool(json, "AutoplayDraw")); SetB(card, "autoplayEndTurn", Bool(json, "AutoplayEndTurn")); SetB(card, "ignoreStealth", Bool(json, "IgnoreStealth")); SetS(card, "effectRequired", (Str(json, "EffectRequired") ?? "").ToLowerInvariant()); SetEnum(card, "cardRarity", Str(json, "CardRarity")); SetEnum(card, "cardType", Str(json, "CardType")); SetEnum(card, "cardClass", Str(json, "CardClass")); SetEnumArray(card, "cardTypeAux", Arr(json, "CardTypeAux")); SetEnum(card, "specialCardEnum", Str(json, "SpecialCardEnum")); SetCustomFlags(card, json); SetRef(card, "acEnergyBonus", Str(json, "AcEnergyBonus")); SetRef(card, "acEnergyBonus2", Str(json, "AcEnergyBonus2")); Safe(delegate { SetRaw(card, "item", FindReference?.Invoke(Str(json, "Item"), typeof(ItemData))); }); Safe(delegate { SetRaw(card, "itemEnchantment", FindReference?.Invoke(Str(json, "ItemEnchantment"), typeof(ItemData))); }); DescriptionData nested = GetNested<DescriptionData>(card, "description"); if (nested != null) { if (flag) { ClearStaleDescription(nested); } SetS(nested, "fluff", Str(json, "Fluff")); SetF(nested, "fluffPercent", Flt(json, "FluffPercent")); SetB(nested, "flipSprite", Bool(json, "FlipSprite")); SetB(nested, "showInTome", Bool(json, "ShowInTome", def: true)); SetS(nested, "descriptionId", Str(json, "DescriptionID")); SetStringList(nested, "relatedCards", new string[3] { Str(json, "RelatedCard"), Str(json, "RelatedCard2"), Str(json, "RelatedCard3") }); Sprite val = GetSprite?.Invoke(Str(json, "Sprite")); if ((Object)(object)val != (Object)null) { SetRaw(nested, "sprite", val); } } CardTargetData nested2 = GetNested<CardTargetData>(card, "targetData"); if (nested2 != null) { SetEnum(nested2, "targetSide", Str(json, "TargetSide")); SetEnum(nested2, "targetType", Str(json, "TargetType")); SetEnum(nested2, "targetPosition", Str(json, "TargetPosition")); } UpgradeData nested3 = GetNested<UpgradeData>(card, "upgrade"); if (nested3 != null) { SetS(nested3, "upgradesTo1", Str(json, "UpgradesTo1")); SetS(nested3, "upgradesTo2", Str(json, "UpgradesTo2")); SetS(nested3, "upgradedFrom", Str(json, "UpgradedFrom")); SetEnum(nested3, "cardUpgraded", Str(json, "CardUpgraded")); string value = Str(json, "UpgradesToRare"); if (!string.IsNullOrEmpty(value)) { PendingRareLinks[text] = value; } } RepeatCastData nested4 = GetNested<RepeatCastData>(card, "repeatCast"); if (nested4 != null) { SetI(nested4, "effectRepeat", Int(json, "EffectRepeat", 1)); SetF(nested4, "effectRepeatDelay", Flt(json, "EffectRepeatDelay")); SetI(nested4, "effectRepeatEnergyBonus", Int(json, "EffectRepeatEnergyBonus")); SetI(nested4, "effectRepeatMaxBonus", Int(json, "EffectRepeatMaxBonus")); SetI(nested4, "effectRepeatModificator", Int(json, "EffectRepeatModificator")); SetEnum(nested4, "effectRepeatTarget", Str(json, "EffectRepeatTarget")); } CardManagementData mgmt = GetNested<CardManagementData>(card, "cardManagement"); if (mgmt != null) { SetI(mgmt, "drawCard", Int(json, "DrawCard")); if (!flag) { Safe(delegate { SetRaw(mgmt, "drawCardSpecialValue", LegacySpecialValue(json, "DrawCardSpecialValueGlobal", global: true)); }); } SetI(mgmt, "discardCard", Int(json, "DiscardCard")); SetEnum(mgmt, "discardCardType", Str(json, "DiscardCardType")); SetEnumArray(mgmt, "discardCardTypeAux", Arr(json, "DiscardCardTypeAux")); SetB(mgmt, "discardCardAutomatic", Bool(json, "DiscardCardAutomatic")); SetEnum(mgmt, "discardCardPlace", Str(json, "DiscardCardPlace")); SetI(mgmt, "addCard", Int(json, "AddCard")); SetS(mgmt, "addCardId", Str(json, "AddCardId")); SetEnum(mgmt, "addCardType", Str(json, "AddCardType")); SetB(mgmt, "addCardOnlyCheckAuxTypes", Bool(json, "AddCardOnlyCheckAuxTypes")); SetEnumArray(mgmt, "addCardTypeAux", Arr(json, "AddCardTypeAux")); SetI(mgmt, "addCardChoose", Int(json, "AddCardChoose")); SetEnum(mgmt, "addCardFrom", Str(json, "AddCardFrom")); SetEnum(mgmt, "addCardPlace", Str(json, "AddCardPlace")); SetI(mgmt, "addCardReducedCost", Int(json, "AddCardReducedCost")); SetB(mgmt, "addCardCostTurn", Bool(json, "AddCardCostTurn")); SetB(mgmt, "addCardVanish", Bool(json, "AddCardVanish")); SetI(mgmt, "lookCards", Int(json, "LookCards")); SetI(mgmt, "lookCardsDiscardUpTo", Int(json, "LookCardsDiscardUpTo")); SetI(mgmt, "lookCardsVanishUpTo", Int(json, "LookCardsVanishUpTo")); string[] array = Arr(json, "AddCardList"); if (array == null || array.Length == 0) { SetRaw(mgmt, "addCardList", new CardDataNew[0]); } else { if (!flag) { PendingAddCardLists[text] = array; } SetRaw(mgmt, "addCardList", new CardDataNew[0]); } EnsureEmptyListField(mgmt, "AddCardListBasedOnHeroClass"); EnsureEmptyListField(mgmt, "AddCardTypeBasedOnHeroClass"); } InGameEffectsData nested5 = GetNested<InGameEffectsData>(card, "inGameEffects"); if (nested5 != null) { SetS(nested5, "effectCaster", Str(json, "EffectCaster")); SetS(nested5, "effectTarget", Str(json, "EffectTarget")); SetB(nested5, "effectCasterRepeat", Bool(json, "EffectCasterRepeat")); SetF(nested5, "effectPostCastDelay", Flt(json, "EffectPostCastDelay")); SetF(nested5, "effectPostTargetDelay", Flt(json, "EffectPostTargetDelay")); SetS(nested5, "effectPreAction", Str(json, "EffectPreAction")); SetS(nested5, "effectTrail", Str(json, "EffectTrail")); SetF(nested5, "effectTrailSpeed", Flt(json, "EffectTrailSpeed")); SetB(nested5, "effectTrailRepeat", Bool(json, "EffectTrailRepeat")); SetEnum(nested5, "effectTrailAngle", Str(json, "EffectTrailAngle")); SetB(nested5, "effectCastCenter", Bool(json, "EffectCastCenter")); SetI(nested5, "goldGainQuantity", Int(json, "GoldGainQuantity")); SetI(nested5, "shardsGainQuantity", Int(json, "ShardsGainQuantity")); } BuildDamage(card, json); BuildAuras(card, json); BuildCurses(card, json); BuildHeal(card, json, !flag); BuildSelfHealthLoss(card, json, !flag); if (!flag) { BuildAuraCurseDispels(card, json); BuildEnergyRecharges(card, json); BuildSummonAuras(card, json); BuildCardSpecialValue(card, json); } GetNested<EchoData>(card, "echoData"); SummonData summon = GetNested<SummonData>(card, "summon"); if (summon != null) { SetI(summon, "summonUnitNum", Int(json, "SummonUnitNum")); Safe(delegate { SetRaw(summon, "summonUnit", FindReference?.Invoke(Str(json, "SummonUnit"), typeof(NPCData))); }); } PetData nested6 = GetNested<PetData>(card, "petData"); if (nested6 != null) { SetB(nested6, "isPetAttack", Bool(json, "IsPetAttack")); SetB(nested6, "isPetCast", Bool(json, "IsPetCast")); SetB(nested6, "killPet", Bool(json, "KillPet")); SetB(nested6, "petFront", Bool(json, "PetFront")); SetB(nested6, "petInvert", Bool(json, "PetInvert")); } Safe(delegate { SetRaw(card, "sounds", BuildSounds(json)); }); return card; } internal static void Report(string label) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[CardImporter] {label}: mapped={mapped} failed={failed} sounds={soundsTotal} unresolved={soundsMissing}"); } } private static void BuildDamage(CardDataNew card, JObject j) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown List<DamageEffectData> list = new List<DamageEffectData>(); AddDamage(list, j, "Damage", "DamageType", "DamageSpecialValue1", "DamageSpecialValue2", "DamageSpecialValueGlobal", "DamageSpecialValueModifier1", "DamageSpecialValueModifier2", "IgnoreBlock"); AddDamage(list, j, "Damage2", "DamageType2", "Damage2SpecialValue1", "Damage2SpecialValue2", "Damage2SpecialValueGlobal", null, null, "IgnoreBlock2"); int num = Int(j, "DamageSelf"); int num2 = Int(j, "DamageSides"); if (num != 0) { list.Add(new DamageEffectData { Damage = num, DamageType = ParseEnum<DamageType>(Str(j, "DamageType")).GetValueOrDefault(), DamageTarget = (DamageTarget)3 }); } if (num2 != 0) { list.Add(new DamageEffectData { Damage = num2, DamageType = ParseEnum<DamageType>(Str(j, "DamageType")).GetValueOrDefault(), DamageTarget = (DamageTarget)1 }); } SetRaw(card, "damage", list); } private static void AddDamage(List<DamageEffectData> list, JObject j, string dmgKey, string typeKey, string sv1, string sv2, string svg, string mod1, string mod2, string ignoreKey) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown int num = Int(j, dmgKey); if (num != 0) { DamageEffectData val = new DamageEffectData { Damage = num, DamageType = ParseEnum<DamageType>(Str(j, typeKey)).GetValueOrDefault(), DamageTarget = (DamageTarget)0, IgnoreBlock = Bool(j, ignoreKey) }; SpecialValueData val2 = BuildSpecialValue(j, sv1, sv2, svg, mod1, mod2, "SpecialAuraCurseName1", "SpecialAuraCurseName2", "SpecialAuraCurseNameGlobal"); if (val2 != null) { ((EffectData)val).SpecialValue = val2; } list.Add(val); } } private static void BuildAuras(CardDataNew card, JObject j) { AuraData nested = GetNested<AuraData>(card, "auras"); if (nested != null) { List<AuraEffectData> list = new List<AuraEffectData>(); AddAura(list, j, "Aura", "AuraCharges", "AuraChargesSpecialValue1", "AuraChargesSpecialValue2", "AuraChargesSpecialValueGlobal", (AuraTarget)0); AddAura(list, j, "Aura2", "AuraCharges2", "AuraCharges2SpecialValue1", "AuraCharges2SpecialValue2", "AuraCharges2SpecialValueGlobal", (AuraTarget)0); AddAura(list, j, "Aura3", "AuraCharges3", "AuraCharges3SpecialValue1", "AuraCharges3SpecialValue2", "AuraCharges3SpecialValueGlobal", (AuraTarget)0); AddAura(list, j, "AuraSelf", "AuraCharges", null, null, null, (AuraTarget)1); AddAura(list, j, "AuraSelf2", "AuraCharges2", null, null, null, (AuraTarget)1); AddAura(list, j, "AuraSelf3", "AuraCharges3", null, null, null, (AuraTarget)1); SetRaw(nested, "auras", list); } } private static void AddAura(List<AuraEffectData> list, JObject j, string auraKey, string chargesKey, string sv1, string sv2, string svg, AuraTarget target) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown string text = Str(j, auraKey); if (string.IsNullOrEmpty(text)) { return; } AuraCurseData val = GetAuraCurse?.Invoke(text); if ((Object)(object)val == (Object)null) { failed++; return; } AuraEffectData val2 = new AuraEffectData { Aura = val, Charges = Int(j, chargesKey), Target = target }; if (sv1 != null) { SpecialValueData val3 = BuildSpecialValue(j, sv1, sv2, svg, "SpecialValueModifier1", "SpecialValueModifier2", "SpecialAuraCurseName1", "SpecialAuraCurseName2", "SpecialAuraCurseNameGlobal"); if (val3 != null) { ((EffectData)val2).SpecialValue = val3; } } list.Add(val2); } private static void BuildCurses(CardDataNew card, JObject j) { List<CurseEffectData> list = new List<CurseEffectData>(); AddCurse(list, j, "Curse", "CurseCharges", "CurseChargesSpecialValue1", "CurseChargesSpecialValue2", "CurseChargesSpecialValueGlobal", (CurseTarget)0); AddCurse(list, j, "Curse2", "CurseCharges2", "CurseCharges2SpecialValue1", "CurseCharges2SpecialValue2", "CurseCharges2SpecialValueGlobal", (CurseTarget)0); AddCurse(list, j, "Curse3", "CurseCharges3", "CurseCharges3SpecialValue1", "CurseCharges3SpecialValue2", "CurseCharges3SpecialValueGlobal", (CurseTarget)0); AddCurse(list, j, "CurseSelf", "CurseCharges", null, null, null, (CurseTarget)2); AddCurse(list, j, "CurseSelf2", "CurseCharges2", null, null, null, (CurseTarget)2); AddCurse(list, j, "CurseSelf3", "CurseCharges3", null, null, null, (CurseTarget)2); SetRaw(card, "curses", list); } private static void AddCurse(List<CurseEffectData> list, JObject j, string curseKey, string chargesKey, string sv1, string sv2, string svg, CurseTarget target) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown string text = Str(j, curseKey); if (string.IsNullOrEmpty(text)) { return; } AuraCurseData val = GetAuraCurse?.Invoke(text); if ((Object)(object)val == (Object)null) { failed++; return; } CurseEffectData val2 = new CurseEffectData { Curse = val, Charges = Int(j, chargesKey), Target = target }; if (sv1 != null) { SpecialValueData val3 = BuildSpecialValue(j, sv1, sv2, svg, "SpecialValueModifier1", "SpecialValueModifier2", "SpecialAuraCurseName1", "SpecialAuraCurseName2", "SpecialAuraCurseNameGlobal"); if (val3 != null) { ((EffectData)val2).SpecialValue = val3; } } list.Add(val2); } private static void BuildHeal(CardDataNew card, JObject j, bool newCard) { //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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown HealData nested = GetNested<HealData>(card, "heal"); if (nested == null) { return; } int num = Int(j, "Heal"); int num2 = Int(j, "HealSelf"); int num3 = Int(j, "HealSides"); SpecialValueData specialValue = (newCard ? LegacySpecialValue(j, "HealSpecialValue1", global: false) : null); SpecialValueData specialValue2 = (newCard ? LegacySpecialValue(j, "HealSelfSpecialValue1", global: false) : null); List<HealEffectData> list = new List<HealEffectData>(); if (num != 0) { list.Add(new HealEffectData { Heal = num, HealType = (HealType)0, HealTarget = (HealTarget)0, SpecialValue = specialValue }); } if (num2 != 0) { list.Add(new HealEffectData { Heal = num2, HealType = (HealType)0, HealTarget = (HealTarget)1, SpecialValue = specialValue2 }); } if (num3 != 0) { list.Add(new HealEffectData { Heal = num3, HealType = (HealType)0, HealTarget = (HealTarget)2, SpecialValue = specialValue }); } if (newCard) { int num4 = Int(j, "HealSelfPerDamageDonePercent"); if (num4 > 0) { list.Add(new HealEffectData { Heal = num4, HealType = (HealType)1, HealTarget = (HealTarget)1 }); } } if (list.Count > 0) { SetRaw(nested, "healEffects", list); } SetI(nested, "healEnergyBonus", Int(j, "HealEnergyBonus")); } private static void BuildSelfHealthLoss(CardDataNew card, JObject j, bool newCard) { int num = Int(j, "SelfHealthLoss"); SpecialValueData val = (newCard ? (LegacySpecialValue(j, "SelfHealthLossSpecialValue1", global: false) ?? LegacySpecialValue(j, "SelfHealthLossSpecialGlobal", global: true)) : null); if (num == 0 && val == null) { return; } SelfHealthLossData nested = GetNested<SelfHealthLossData>(card, "selfHealthLoss"); if (nested != null) { SetI(nested, "selfHealthLoss", num); if (val != null) { SetRaw(nested, "specialValue", val); } } } private static SpecialValueData BuildSpecialValue(JObject j, string use1, string use2, string useGlob, string mod1, string mod2, string ac1, string ac2, string acg) { if (!string.IsNullOrEmpty(useGlob) && Bool(j, useGlob)) { return LegacySpecialValue(j, useGlob, global: true); } if (!string.IsNullOrEmpty(use1) && Bool(j, use1)) { return LegacySpecialValue(j, use1, global: false, 1, mod1, ac1); } if (!string.IsNullOrEmpty(use2) && Bool(j, use2)) { return LegacySpecialValue(j, use2, global: false, 2, mod2, ac2); } return null; } private static SpecialValueData LegacySpecialValue(JObject j, string useKey, bool global, int slot = 1, string modifierKey = null, string acKey = null) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown if (string.IsNullOrEmpty(useKey) || !Bool(j, useKey)) { return null; } string s = (global ? Str(j, "SpecialValueGlobal") : Str(j, "SpecialValue" + slot)); string k = acKey ?? (global ? "SpecialAuraCurseNameGlobal" : ("SpecialAuraCurseName" + slot)); string k2 = modifierKey ?? (global ? "SpecialValueModifierGlobal" : ("SpecialValueModifier" + slot)); string arg = Str(j, k); float num = Flt(j, k2); CardSpecialValueType valueOrDefault = ParseEnum<CardSpecialValueType>(s).GetValueOrDefault(); AuraCurseData val = GetAuraCurse?.Invoke(arg); if ((int)valueOrDefault != 0 || !((Object)(object)val == (Object)null) || num != 0f) { return new SpecialValueData(val, valueOrDefault, num, (OperationType)0, global); } return null; } private static void BuildAuraCurseDispels(CardDataNew card, JObject j) { AuraCurseDispelData nested = GetNested<AuraCurseDispelData>(card, "auraCurseDispels"); if (nested == null) { return; } SetI(nested, "healCurses", Int(j, "HealCurses")); SetI(nested, "dispelAuras", Int(j, "DispelAuras")); SetI(nested, "transferCurses", Int(j, "TransferCurses")); SetI(nested, "stealAuras", Int(j, "StealAuras")); SetI(nested, "increaseAuras", Int(j, "IncreaseAuras")); SetI(nested, "increaseCurses", Int(j, "IncreaseCurses")); SetI(nested, "reduceAuras", Int(j, "ReduceAuras")); SetI(nested, "reduceCurses", Int(j, "ReduceCurses")); List<AuraCurseData> list = new List<AuraCurseData>(); string[] array = new string[4] { "HealAuraCurseName", "HealAuraCurseName2", "HealAuraCurseName3", "HealAuraCurseName4" }; foreach (string k in array) { AuraCurseData val = GetAuraCurse?.Invoke(Str(j, k)); if ((Object)(object)val != (Object)null) { list.Add(val); } } if (list.Count > 0) { SetRaw(nested, "healAuraCurses", list); } AuraCurseData val2 = GetAuraCurse?.Invoke(Str(j, "HealAuraCurseSelf")); if ((Object)(object)val2 != (Object)null) { SetRaw(nested, "healAuraCurseSelf", val2); } } private static void BuildEnergyRecharges(CardDataNew card, JObject j) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown int num = Int(j, "EnergyRecharge"); if (num != 0) { EnergyRechargeData val = new EnergyRechargeData { EnergyRecharge = num, Target = (TargetType)0 }; SpecialValueData val2 = LegacySpecialValue(j, "EnergyRechargeSpecialValueGlobal", global: true); if (val2 != null) { val.EnergyRechargeSpecialValue = val2; } SetRaw(card, "energyRecharges", new List<EnergyRechargeData> { val }); } } private static void BuildSummonAuras(CardDataNew card, JObject j) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown SummonData nested = GetNested<SummonData>(card, "summon"); if (nested == null) { return; } List<SummonAuraData> list = new List<SummonAuraData>(); string[][] array = new string[3][] { new string[2] { "SummonAura", "SummonAuraCharges" }, new string[2] { "SummonAura2", "SummonAuraCharges2" }, new string[2] { "SummonAura3", "SummonAuraCharges3" } }; foreach (string[] array2 in array) { AuraCurseData val = GetAuraCurse?.Invoke(Str(j, array2[0])); if ((Object)(object)val != (Object)null) { list.Add(new SummonAuraData { Aura = val, Charges = Int(j, array2[1]) }); } } if (list.Count > 0) { SetRaw(nested, "summonAuras", list); } } private static void BuildCardSpecialValue(CardDataNew card, JObject j) { //IL_0038: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown SpecialValueData val = LegacySpecialValue(j, "UseCardSpecialValueGlobal", global: true); if (val == null) { string s = Str(j, "SpecialValueGlobal"); float num = Flt(j, "SpecialValueModifierGlobal"); CardSpecialValueType valueOrDefault = ParseEnum<CardSpecialValueType>(s).GetValueOrDefault(); AuraCurseData val2 = GetAuraCurse?.Invoke(Str(j, "SpecialAuraCurseNameGlobal")); if ((int)valueOrDefault != 0 || (Object)(object)val2 != (Object)null || num != 0f) { val = new SpecialValueData(val2, valueOrDefault, num, (OperationType)0, true); } } if (val != null) { SetRaw(card, "cardSpecialValue", val); } } internal static string SoundName(SoundData s, int index) { if (s == null) { return null; } if (!SoundNames.TryGetValue(s, out var value) || value == null) { return null; } if (index < 0 || index >= value.Length) { return null; } return value[index]; } private static object BuildSounds(JObject j) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown SoundData val = new SoundData(); string text = Str(j, "Sound"); string text2 = Str(j, "SoundPreAction"); string text3 = Str(j, "SoundPreActionFemale"); if (string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text)) { text2 = text; } SoundNames.Add(val, new string[3] { text ?? "", text2 ?? "", text3 ?? "" }); AudioClip val2 = GetAudio?.Invoke(text); AudioClip val3 = GetAudio?.Invoke(text2); AudioClip val4 = GetAudio?.Invoke(text3); Str(j, "ID"); if (!string.IsNullOrEmpty(text)) { soundsTotal++; if ((Object)(object)val2 == (Object)null) { soundsMissing++; } } if (!string.IsNullOrEmpty(text) && (Object)(object)val2 == (Object)null && !string.IsNullOrEmpty(text2) && (Object)(object)val3 == (Object)null && !string.Equals(text2, text, StringComparison.Ordinal) && !string.IsNullOrEmpty(text3) && (Object)(object)val4 == (Object)null) { ApplySound(val, val2, val3, val4); } float num = Flt(j, "SoundHitReworkDelay"); if (num > 0f) { SetRaw(val, "soundHitReworkDelay", num); } return val; } internal static void ApplySound(SoundData s, AudioClip hit, AudioClip pre, AudioClip preFemale) { if (s != null) { if ((Object)(object)hit != (Object)null) { SetRaw(s, "sound", hit); SetRaw(s, "soundHitRework", hit); } if ((Object)(object)pre != (Object)null) { SetRaw(s, "soundPreAction", pre); SetRaw(s, "soundReleaseRework", pre); } if ((Object)(object)preFemale != (Object)null) { SetRaw(s, "soundPreActionFemale", preFemale); } } } private static void SetCustomFlags(CardDataNew card, JObject j) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) CustomFlags val = (CustomFlags)0; if (Bool(j, "Vanish")) { val = (CustomFlags)(val | 1); } if (Bool(j, "Innate")) { val = (CustomFlags)(val | 2); } if (Bool(j, "MoveToCenter")) { val = (CustomFlags)(val | 0x10); } if (Bool(j, "Lazy")) { val = (CustomFlags)(val | 4); } if (Bool(j, "EndTurn")) { val = (CustomFlags)(val | 8); } if (Bool(j, "Corrupted")) { val = (CustomFlags)(val | 0x20); } if (Bool(j, "Starter")) { val = (CustomFlags)(val | 0x40); } if (Bool(j, "OnlyInWeekly")) { val = (CustomFlags)(val | 0x80); } SetRaw(card, "customFlags", val); } private static T GetNested<T>(object parent, string field) where T : class { FieldInfo fieldInfo = FindField(parent.GetType(), field); if (fieldInfo == null) { return null; } return fieldInfo.GetValue(parent) as T; } private static FieldInfo FindField(Type type, string name) { Type type2 = type; while (type2 != null) { FieldInfo field = type2.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field; } type2 = type2.BaseType; } return null; } private static void ClearStaleDescription(DescriptionData desc) { if (desc == null) { return; } try { SetS(desc, "description", ""); SetS(desc, "descriptionNormalized", ""); SetS(desc, "preDescriptionId", ""); SetS(desc, "postDescriptionId", ""); SetB(desc, "useDescriptionFromCard", v: false); SetRaw(desc, "preDescriptionArgs", new string[0]); SetRaw(desc, "descriptionArgs", new string[0]); SetRaw(desc, "postDescriptionArgs", new string[0]); if (typeof(DescriptionData).GetField("keyNotes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(desc) is IList list) { list.Clear(); } } catch { } } private static void SetRaw(object target, string field, object value) { if (target == null || value == null) { return; } FieldInfo fieldInfo = FindField(target.GetType(), field); if (fieldInfo == null) { return; } if (!fieldInfo.FieldType.IsInstanceOfType(value)) { if (fieldInfo.FieldType.IsEnum) { _ = value is string; } } else { fieldInfo.SetValue(target, value); mapped++; } } private static void SetS(object t, string f, string v) { if (v != null) { SetRaw(t, f, v); } } private static void SetI(object t, string f, int v) { SetRaw(t, f, v); } private static void SetF(object t, string f, float v) { SetRaw(t, f, v); } private static void SetB(object t, string f, bool v) { SetRaw(t, f, v); } private static void SetEnum(object t, string f, string v) { if (string.IsNullOrEmpty(v) || (v == "None" && !HasEnumMember(FindField(t.GetType(), f)?.FieldType, v))) { return; } FieldInfo fieldInfo = FindField(t.GetType(), f); if (!(fieldInfo == null) && fieldInfo.FieldType.IsEnum) { object obj = ParseEnumAny(fieldInfo.FieldType, v); if (obj != null) { SetRaw(t, f, obj); } } } private static void SetEnumArray(object t, string f, string[] vals) { if (vals == null || vals.Length == 0) { return; } FieldInfo fieldInfo = FindField(t.GetType(), f); if (fieldInfo == null || !fieldInfo.FieldType.IsArray) { return; } Type elementType = fieldInfo.FieldType.GetElementType(); Array array = Array.CreateInstance(elementType, vals.Length); for (int i = 0; i < vals.Length; i++) { object obj = ParseEnumAny(elementType, vals[i]); if (obj != null) { array.SetValue(obj, i); } } SetRaw(t, f, array); } private static void EnsureEmptyListField(object target, string field) { if (target == null) { return; } try { FieldInfo fieldInfo = FindField(target.GetType(), field); if (!(fieldInfo == null) && fieldInfo.GetValue(target) == null && fieldInfo.FieldType.IsGenericType) { Type type = fieldInfo.FieldType.GetGenericArguments()[0]; object value = Activator.CreateInstance(typeof(List<>).MakeGenericType(type)); fieldInfo.SetValue(target, value); } } catch { } } private static void SetStringList(object t, string f, string[] vals) { string[] array = vals?.Where((string v) => !string.IsNullOrEmpty(v)).ToArray(); if (array != null && array.Length != 0) { SetRaw(t, f, array.ToList()); } } private static void SetRef(object t, string f, string id) { if (!string.IsNullOrEmpty(id)) { Safe(delegate { SetRaw(t, f, GetAuraCurse?.Invoke(id)); }); } } private static T? ParseEnum<T>(string s) where T : struct { object obj = ParseEnumAny(typeof(T), s); if (!(obj is T)) { return null; } return (T)obj; } private static object ParseEnumAny(Type enumType, string s) { if (enumType == null || !enumType.IsEnum || string.IsNullOrEmpty(s)) { return null; } try { return Enum.Parse(enumType, s, ignoreCase: true); } catch { failed++; return null; } } private static bool HasEnumMember(Type enumType, string s) { if (enumType == null || !enumType.IsEnum) { return false; } return Enum.GetNames(enumType).Any((string n) => n.Equals(s, StringComparison.OrdinalIgnoreCase)); } private static void Safe(Action a) { try { a(); } catch { failed++; } } private static string Str(JObject j, string k) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 JToken obj = j[k]; if (obj == null || (int)obj.Type != 8) { return null; } return ((object)j[k]).ToString(); } private static int Int(JObject j, string k, int def = 0) { if (j[k] == null) { return def; } if (!int.TryParse(((object)j[k]).ToString(), out var result)) { return def; } return result; } private static float Flt(JObject j, string k, float def = 0f) { if (j[k] == null) { return def; } if (!float.TryParse(((object)j[k]).ToString(), out var result)) { return def; } return result; } private static bool Bool(JObject j, string k, bool def = false) { if (j[k] == null || !bool.TryParse(((object)j[k]).ToString(), out var result)) { return def; } return result; } private static string[] Arr(JObject j, string k) { JToken obj = j[k]; return ((IEnumerable<JToken>)((obj is JArray) ? obj : null))?.Select((JToken x) => ((object)x).ToString()).ToArray(); } } [BepInPlugin("com.stiffmeds.obeliskialcontent", "Obeliskial Content (Compat)", "1.7.10.0")] [BepInProcess("AcrossTheObelisk.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ContentCompat : BaseUnityPlugin { private class PendingEmbeddedItemRef { public ItemData Item; public string SingleId; public string[] ListIds; } private struct ItemDamageContext { public Character Target; public ItemData ItemData; } private class PendingReference { public object Target; public MemberInfo Member; public string Id; public bool IsList; public Type WantedType; } private class PendingMarker { public string Id; public bool IsList; public Type WantedType; } internal static ManualLogSource Log; private static Harmony harmony; private static readonly Dictionary<string, Type> FolderTypes = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase) { { "trait", typeof(TraitData) }, { "subclass", typeof(SubClassData) }, { "perk", typeof(PerkData) }, { "perknode", typeof(PerkNodeData) }, { "npc", typeof(NPCData) }, { "loot", typeof(LootData) }, { "item", typeof(ItemData) }, { "cardback", typeof(CardbackData) }, { "skin", typeof(SkinData) }, { "pack", typeof(PackData) }, { "event", typeof(EventData) }, { "requirement", typeof(EventRequirementData) }, { "combat", typeof(CombatData) }, { "zone", typeof(ZoneData) }, { "challengetrait", typeof(ChallengeTrait) }, { "challenge", typeof(ChallengeData) }, { "corruptionpack", typeof(CorruptionPackData) }, { "cardplayer", typeof(CardPlayerPackData) }, { "cardplayerpairs", typeof(CardPlayerPairsPackData) }, { "cinematic", typeof(CinematicData) }, { "keynotes", typeof(KeyNotesData) } }; private static readonly Dictionary<Type, string> TypeToGlobalField = new Dictionary<Type, string> { { typeof(TraitData), "_TraitsSource" }, { typeof(SubClassData), "_SubClassSource" }, { typeof(PerkData), "_PerksSource" }, { typeof(PerkNodeData), "_PerksNodesSource" }, { typeof(NPCData), "_NPCsSource" }, { typeof(LootData), "_LootDataSource" }, { typeof(ItemData), "_ItemDataSource" }, { typeof(CardbackData), "_CardbackDataSource" }, { typeof(SkinData), "_SkinDataSource" }, { typeof(PackData), "_PackDataSource" }, { typeof(EventData), "_Events" }, { typeof(EventRequirementData), "_Requirements" }, { typeof(CombatData), "_CombatDataSource" }, { typeof(ZoneData), "_ZoneDataSource" }, { typeof(ChallengeTrait), "_ChallengeTraitsSource" }, { typeof(ChallengeData), "_WeeklyDataSource" }, { typeof(CorruptionPackData), "_CorruptionPackDataSource" }, { typeof(CardPlayerPackData), "_CardPlayerPackDataSource" }, { typeof(CardPlayerPairsPackData), "_CardPlayerPairsPackDataSource" }, { typeof(CinematicData), "_Cinematics" }, { typeof(KeyNotesData), "_KeyNotes" } }.ToDictionary((KeyValuePair<Type, string> kv) => kv.Key, (KeyValuePair<Type, string> kv) => kv.Value); private static readonly Dictionary<Type, string> ResourceFolderByType = new Dictionary<Type, string> { { typeof(TraitData), "Traits" }, { typeof(SubClassData), "SubClass" }, { typeof(PerkData), "Perks" }, { typeof(PerkNodeData), "PerkNode" }, { typeof(NPCData), "NPCs" }, { typeof(LootData), "Loot" }, { typeof(ItemData), "Items" }, { typeof(CardbackData), "Cardbacks" }, { typeof(SkinData), "Skins" }, { typeof(PackData), "Packs" }, { typeof(EventData), "World/Events" }, { typeof(EventRequirementData), "World/Events/Requirements" }, { typeof(CombatData), "World/Combats" }, { typeof(ZoneData), "World/Zones" }, { typeof(ChallengeTrait), "Challenge/Traits" }, { typeof(ChallengeData), "Challenge/Weeks" }, { typeof(CorruptionPackData), "CorruptionRewards" }, { typeof(CardPlayerPackData), "CardPlayer" }, { typeof(CardPlayerPairsPackData), "CardPlayerPairs" }, { typeof(CinematicData), "Cinematics" }, { typeof(KeyNotesData), "KeyNotes" } }; private static readonly Dictionary<string, string> Aliases = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "stickerindifferent", "stickerindiferent" }, { "autounlock", "initialunlock" }, { "activation", "activations" }, { "traitcardforallheroes", "traitcardforallheroes" } }; private static readonly Dictionary<string, List<object>> IdMap = new Dictionary<string, List<object>>(StringComparer.OrdinalIgnoreCase); private static readonly List<PendingReference> Pending = new List<PendingReference>(); private static readonly Dictionary<string, ItemData> EmbeddedItemsByJson = new Dictionary<string, ItemData>(StringComparer.Ordinal); private static readonly List<KeyValuePair<string, ItemData>> EmbeddedItems = new List<KeyValuePair<string, ItemData>>(); private static readonly List<PendingEmbeddedItemRef> PendingEmbeddedItemRefs = new List<PendingEmbeddedItemRef>(); private static readonly Stack<ItemDamageContext> ItemDamageContexts = new Stack<ItemDamageContext>(); private static readonly Dictionary<string, string> CurseNameToId = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static readonly Regex SpriteTagRegex = new Regex("<sprite name=([^>]+)>", RegexOptions.Compiled); private static readonly Dictionary<string, Sprite> SpriteByName = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); private static bool ModTraitTextsLoaded; private static readonly Dictionary<string, string> ModTraitNames = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, string> ModTraitDescriptions = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static int traitMigrations; private static bool moveNextPatched; private static bool importDone; private static List<KeyValuePair<string, object>> _overriddenNonCards = new List<KeyValuePair<string, object>>(); private static readonly Dictionary<string, AudioClip> AudioHits = new Dictionary<string, AudioClip>(StringComparer.Ordinal); private static readonly Dictionary<string, int> AudioAttempts = new Dictionary<string, int>(StringComparer.Ordinal); private static readonly HashSet<string> AudioLogged = new HashSet<string>(StringComparer.Ordinal); private const int AudioMaxAttempts = 3; private static readonly Dictionary<string, GameObject> GoByName = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<Type, FieldInfo[]> GoFieldCache = new Dictionary<Type, FieldInfo[]>(); private static void MapAdd(string id, object value) { if (id != null && value != null) { if (!IdMap.TryGetValue(id, out var value2)) { value2 = new List<object>(); IdMap[id] = value2; } if (!value2.Any((object v) => v.GetType() == value.GetType())) { value2.Add(value); } } } private static void MapOverride(string id, object value) { if (id != null && value != null) { if (!IdMap.TryGetValue(id, out var value2)) { value2 = new List<object>(); IdMap[id] = value2; } int num = value2.FindIndex((object v) => v.GetType() == value.GetType()); if (num >= 0) { value2[num] = value; } else { value2.Add(value); } } } private static object MapFind(string id, Type wanted) { if (id == null || !IdMap.TryGetValue(id, out var value)) { return null; } if (wanted != null) { Type type = wanted; if (wanted.IsArray) { type = wanted.GetElementType(); } else if (wanted.IsGenericType) { type = wanted.GetGenericArguments().FirstOrDefault(); } foreach (object item in value) { if (type != null && type.IsInstanceOfType(item)) { return item; } } } if (value.Count <= 0) { return null; } return value[0]; } private static void LoadModTraitTexts() { if (ModTraitTextsLoaded) { return; } Globals instance = Globals.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)Texts.Instance == (Object)null) { return; } ModTraitTextsLoaded = true; string text = instance.CurrentLang; switch (text) { case "zh-CN": text = "简体中文"; break; case "en": text = "English"; break; case "es": text = "español"; break; case "ko": text = "한국인"; break; case "sv": text = "svenska"; break; } try { int num = 0; string[] directories = Directory.GetDirectories(Paths.PluginPath); foreach (string path in directories) { if (!File.Exists(Path.Combine(path, "moretranslations.txt"))) { continue; } string path2 = Path.Combine(path, text + "_traits.txt"); if (!File.Exists(path2)) { continue; } string[] array = File.ReadAllLines(path2); foreach (string text2 in array) { int num2 = text2.IndexOf('='); if (num2 <= 0) { continue; } string text3 = text2.Substring(0, num2).Trim().Replace(" ", "") .ToLower(); if (text3.Length != 0) { string text4 = text2.Substring(num2 + 1); if (text3.EndsWith("_description")) { ModTraitDescriptions[text3.Substring(0, text3.Length - "_description".Length)] = text4; } else { ModTraitNames[text3] = text4; } try { Texts.Instance.SetText("traits_" + text3, text4); num++; } catch { } } } } } catch { } } private static void EnsureTraitSafe(TraitData td) { if ((Object)(object)td == (Object)null) { return; } try { if (td.KeyNotes == null) { td.KeyNotes = new List<KeyNotesData>(); } if (td.Activations == null) { td.Activations = new List<EventActivation>(); } } catch { } } private static void PopupManagerSetTraitPrefix(TraitData __0) { EnsureTraitSafe(__0); } private static bool ApplyModTraitTextTo(TraitData td) { if ((Object)(object)td == (Object)null || string.IsNullOrEmpty(td.Id)) { return false; } EnsureTraitSafe(td); bool result = false; if (ModTraitNames.TryGetValue(td.Id, out var value)) { td.TraitName = value; result = true; } if (ModTraitDescriptions.TryGetValue(td.Id, out var value2)) { td.Description = value2; result = true; } return result; } private static void ApplyModTraitTexts() { Globals instance = Globals.Instance; if ((Object)(object)instance == (Object)null) { return; } int num = 0; string[] array = new string[2] { "_TraitsSource", "_Traits" }; foreach (string name in array) { try { if (!(typeof(Globals).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance) is IDictionary dictionary)) { continue; } foreach (DictionaryEntry item in dictionary) { object? value = item.Value; TraitData val = (TraitData)((value is TraitData) ? value : null); if (val != null && ApplyModTraitTextTo(val)) { num++; } } } catch { } } } private static void HeroAssignTraitPrefix(Hero __instance, string traitName) { try { if (__instance == null || string.IsNullOrEmpty(traitName)) { return; } string[] traits = ((Character)__instance).Traits; if (traits == null || traits.Length == 0) { return; } SubClassData val = (((Object)(object)((Character)__instance).HeroData != (Object)null) ? ((Character)__instance).HeroData.HeroSubClass : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.Trait0 == (Object)null) && val.GetTraitLevel(traitName) == 0) { string id = val.Trait0.Id; string text = traits[0]; if (!string.IsNullOrEmpty(text) && !(text == id) && !SubClassHasTrait(val, text)) { traits[0] = ""; traitMigrations++; Log.LogInfo((object)("[TraitFix] " + ((Character)__instance).SubclassName + ": slot0 '" + text + "' -> '" + id + "' " + $"(stale save entry re-assigned; total={traitMigrations})")); } } } catch { } } private static bool SubClassHasTrait(SubClassData sc, string id) { TraitData[] array = (TraitData[])(object)new TraitData[9] { sc.Trait0, sc.Trait1A, sc.Trait1B, sc.Trait2A, sc.Trait2B, sc.Trait3A, sc.Trait3B, sc.Trait4A, sc.Trait4B }; foreach (TraitData val in array) { if ((Object)(object)val != (Object)null && string.Equals(val.Id, id, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Expected O, but got Unknown //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown harmony = new Harmony("com.stiffmeds.obeliskialcontent.compat"); Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Obeliskial Content (Compat) initialized"); Essentials.RegisterMod("Obeliskial Content", "stiffmeds", "Compatibility layer for AtO 1.7.7.x", "1.7.10.0", 20261128, "https://github.com/Shazixnar/ATOmod", (string[])null, "Obeliskial Content", 2000000000, new string[2] { "Core", "Content" }, "self-developed compatibility layer", true); try { MethodInfo methodInfo = AccessTools.Method(typeof(Globals), "CreateGameContent", (Type[])null, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "CreateGameContentPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Harmony.GetPatchInfo((MethodBase)methodInfo); } MethodInfo method = typeof(CardDescriptionUtility).GetMethod("SetDescriptionNew", BindingFlags.Static | BindingFlags.Public, null, new Type[4] { typeof(CardRealtimeData), typeof(bool), typeof(Character), typeof(bool) }, null); if (method != null) { harmony.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "SetDescriptionNewPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } PatchDynamicEnchantmentX(); PatchSoundLazyResolve(); MethodInfo methodInfo2 = AccessTools.Method(typeof(TraitRollOver), "OnMouseEnter", (Type[])null, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "TraitRollOverOnMouseEnterPrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo3 = AccessTools.Method(typeof(PopupManager), "SetTrait", new Type[2] { typeof(TraitData), typeof(bool) }, (Type[])null); if (methodInfo3 != null) { harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "PopupManagerSetTraitPrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "TraitRollOverSetTraitPostfix", (Type[])null, (Type[])null)); Type[][] array = new Type[2][] { new Type[2] { typeof(TraitData), typeof(int) }, new Type[2] { typeof(string), typeof(int) } }; foreach (Type[] array2 in array) { MethodInfo methodInfo4 = AccessTools.Method(typeof(TraitRollOver), "SetTrait", array2, (Type[])null); if (methodInfo4 != null) { harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } MethodInfo methodInfo5 = AccessTools.Method(typeof(Hero), "AssignTrait", new Type[1] { typeof(string) }, (Type[])null); if (methodInfo5 != null) { harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "HeroAssignTraitPrefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch (Exception ex) { Log.LogError((object)("Patch failed: " + ex)); } } private static void TraitRollOverSetTraitPostfix(TraitRollOver __instance) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) try { TraitData value = Traverse.Create((object)__instance).Field("traitData").GetValue<TraitData>(); if ((Object)(object)value == (Object)null) { return; } LoadModTraitTexts(); ApplyModTraitTextTo(value); if ((Object)(object)value.TraitCard == (Object)null) { BoxCollider2D component = ((Component)__instance).GetComponent<BoxCollider2D>(); if ((Object)(object)component != (Object)null && !((Behaviour)component).enabled) { ((Behaviour)component).enabled = true; } } } catch { } } private static void TraitRollOverOnMouseEnterPrefix(TraitRollOver __instance) { try { TraitData value = Traverse.Create((object)__instance).Field("traitData").GetValue<TraitData>(); if (!((Object)(object)value == (Object)null)) { LoadModTraitTexts(); value.SetNameAndDescription(); string text = Texts.Instance.GetText(value.Id + "_description", "Traits"); if (!string.IsNullOrEmpty(text)) { value.Description = text; } ApplyModTraitTextTo(value); } } catch { } } private static void CreateGameContentPostfix(ref Coroutine __result) { Globals instance = Globals.Instance; if (!((Object)(object)instance == (Object)null)) { PatchRoutineMoveNext(instance); } } private static void PatchRoutineMoveNext(Globals g) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown if (moveNextPatched) { return; } MethodInfo method = typeof(Globals).GetMethod("CreateGameContentRoutine", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { return; } object obj; try { obj = method.Invoke(g, null); } catch { return; } if (obj != null) { MethodInfo method2 = obj.GetType().GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(method2 == null)) { harmony.Patch((MethodBase)method2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "RoutineMoveNextPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); moveNextPatched = true; } } } private static void RoutineMoveNextPostfix(ref bool __result) { if (!__result && !importDone) { SafeImportAll(); } } private static void SafeImportAll() { if (importDone) { return; } try { ImportAll(); importDone = true; } catch (Exception ex) { Log.LogError((object)("Import failed: " + ex)); } } private static void ImportAll() { Pending.Clear(); IdMap.Clear(); CardImporter.PendingRareLinks.Clear(); CardImporter.PendingAddCardLists.Clear(); EmbeddedItemsByJson.Clear(); EmbeddedItems.Clear(); PendingEmbeddedItemRefs.Clear(); Globals g = Globals.Instance; if ((Object)(object)g != (Object)null) { LoadModTraitTexts(); LoadVanillaFromGlobals(g); } string text = Path.Combine(Paths.ConfigPath, "Obeliskial_importing"); if (!Directory.Exists(text)) { Log.LogWarning((object)("No Obeliskial_importing directory: " + text)); return; } ImportGameObjects(text); CardImporter.Log = Log; CardImporter.FindReference = ResolveAnyReference; CardImporter.GetAuraCurse = delegate(string id) { if (string.IsNullOrEmpty(id)) { return (AuraCurseData)null; } object obj5 = MapFind(id, typeof(AuraCurseData)); AuraCurseData val4 = (AuraCurseData)((obj5 is AuraCurseData) ? obj5 : null); if (val4 != null) { return val4; } try { return ((Object)(object)g != (Object)null) ? g.GetAuraCurseData(id) : null; } catch { return (AuraCurseData)null; } }; CardImporter.GetSprite = ResolveSprite; CardImporter.GetAudio = ResolveAudio; int num = 0; List<string> list = new List<string>(); List<KeyValuePair<string, object>> list2 = new List<KeyValuePair<string, object>>(); string[] files = Directory.GetFiles(text, "*.json", SearchOption.AllDirectories); foreach (string text2 in files) { string name = new DirectoryInfo(Path.GetDirectoryName(text2)).Name; if (name.Equals("card", StringComparison.OrdinalIgnoreCase)) { list.Add(text2); } else { if (!FolderTypes.TryGetValue(name, out var value)) { continue; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); try { JObject val = JObject.Parse(File.ReadAllText(text2)); string text3 = NormalizeId(fileNameWithoutExtension); if (value == typeof(SubClassData)) { string text4 = ((JToken)val).Value<string>((object)"SubclassName") ?? ((JToken)val).Value<string>((object)"SubClassName"); if (!string.IsNullOrEmpty(text4)) { text3 = NormalizeId(text4); } } object obj = CreateInstance(value); if (obj != null) { Populate(obj, val, value); CallInit(obj, value); object obj2 = MapFind(text3, value); if (obj2 != null && obj2 != obj) { CopyMissingFields(obj, obj2, value, val); } TraitData val2 = (TraitData)((obj is TraitData) ? obj : null); if (val2 != null) { EnsureTraitSafe(val2); } if (value == typeof(SubClassData)) { FixSubClassData(obj, val, obj2, text3); } MapOverride(text3, obj); list2.Add(new KeyValuePair<string, object>(text3, obj)); num++; } } catch (Exception ex) { Log.LogWarning((object)("Skip " + name + "/" + fileNameWithoutExtension + ": " + ex.Message)); } } } IDictionary dictionary = null; try { dictionary = typeof(Globals).GetField("_CardsSource", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(g) as IDictionary; } catch { } int num3 = 0; int num4 = 0; List<KeyValuePair<string, CardDataNew>> list3 = new List<KeyValuePair<string, CardDataNew>>(); foreach (string item in list) { string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(item); try { JObject json = JObject.Parse(File.ReadAllText(item)); CardDataNew existing = null; if (dictionary != null && dictionary.Contains(fileNameWithoutExtension2)) { object? obj4 = dictionary[fileNameWithoutExtension2]; existing = (CardDataNew)((obj4 is CardDataNew) ? obj4 : null); } CardDataNew val3 = CardImporter.Import(json, existing); if ((Object)(object)val3 != (Object)null) { MapAdd(fileNameWithoutExtension2, val3); list3.Add(new KeyValuePair<string, CardDataNew>(fileNameWithoutExtension2, val3)); num3++; } } catch (Exception ex2) { num4++; Log.LogWarning((object)("Skip card/" + fileNameWithoutExtension2 + ": " + ex2.Message)); } } foreach (KeyValuePair<string, ItemData> embeddedItem in EmbeddedItems) { MapOverride(embeddedItem.Key, embeddedItem.Value); list2.Add(new KeyValuePair<string, object>(embeddedItem.Key, embeddedItem.Value)); } ResolveEmbeddedItemRefs(); ResolvePending(); ResolveCardReferences(); _overriddenNonCards = list2; Inject(list2); InjectCards(g, list3); CardImporter.Report($"cards {num3}/{num3 + num4}"); string text5 = $"Imported {num} items + {num3} cards (new card model), {num4} card failures."; Log.LogInfo((object)text5); } private static void LoadVanillaFromGlobals(Globals g) { foreach (KeyValuePair<Type, string> item in TypeToGlobalField) { try { FieldInfo field = typeof(Globals).GetField(item.Value, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null || !(field.GetValue(g) is IDictionary dictionary)) { continue; } foreach (DictionaryEntry item2 in dictionary) { if (item2.Value != null && item2.Key != null) { MapAdd(NormalizeId(item2.Key.ToString()), item2.Value); } } } catch { } } string[] array = new string[6] { "_Traits", "_SubClass", "_AurasCurses", "_NPCs", "_Cards", "_CardsSource" }; foreach (string name in array) { try { FieldInfo field2 = typeof(Globals).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 == null || !(field2.GetValue(g) is IDictionary dictionary2)) { continue; } foreach (DictionaryEntry item3 in dictionary2) { if (item3.Value != null && item3.Key != null) { MapAdd(NormalizeId(item3.Key.ToString()), item3.Value); } } } catch { } } BuildSpriteIndex(g); } private static void BuildSpriteIndex(Globals g) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) SpriteByName.Clear(); try { string path = Path.Combine(Paths.ConfigPath, "Obeliskial_importing"); HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); int num = 0; string[] files; if (Directory.Exists(path)) { files = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories); foreach (string path2 in files) { if (!string.Equals(new DirectoryInfo(Path.GetDirectoryName(path2)).Name, "sprite", StringComparison.OrdinalIgnoreCase)) { continue; } string text = Path.GetFileNameWithoutExtension(path2).Trim().ToLowerInvariant(); if (string.IsNullOrEmpty(text) || !hashSet.Add(text)) { continue; } try { Texture2D val = new Texture2D(0, 0); if (ImageConversion.LoadImage(val, File.ReadAllBytes(path2))) { Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)val2).name = text; SpriteByName[text] = val2; num++; } } catch { } } } files = new string[2] { "_CardsSource", "_Cards" }; foreach (string name in files) { if (!(typeof(Globals).GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(g) is IDictionary dictionary)) { continue; } foreach (DictionaryEntry item in dictionary) { object? value = item.Value; CardDataNew val3 = (CardDataNew)((value is CardDataNew) ? value : null); if ((Object)(object)val3 == (Object)null) { continue; } object? obj2 = FindFieldShallow(((object)val3).GetType(), "description")?.GetValue(val3); DescriptionData val4 = (DescriptionData)((obj2 is DescriptionData) ? obj2 : null); if (val4 != null && (Object)(object)val4.Sprite != (Object)null) { string name2 = ((Object)val4.Sprite).name; if (!string.IsNullOrEmpty(name2) && !SpriteByName.ContainsKey(name2)) { SpriteByName[name2] = val4.Sprite; } } } } } catch { } } private static string TruncateCardId(string s) { if (string.IsNullOrEmpty(s)) { return s; } s = s.Replace("v2", "").ToLowerInvariant(); if (s.EndsWith("mnp") && !s.Contains("cataclysm")) { return s.Substring(0, s.Length - 3); } if (s.EndsWith("np")) { return s.Substring(0, s.Length - 2); } return s; } private static void LocalizeCard(CardRealtimeData crd) { if (crd == (CardRealtimeData)null) { return; } try { string s = crd.Id; if (!string.IsNullOrEmpty(crd.UpgradedFrom)) { s = crd.UpgradedFrom; } string text = Texts.Instance.GetText("c_" + TruncateCardId(s) + "_name", "cards"); if (!string.IsNullOrEmpty(text)) { crd.CardName = text; } string s2 = crd.Id; if (!string.IsNullOrEmpty(crd.UpgradedFrom)) { s2 = crd.UpgradedFrom; } string text2 = Texts.Instance.GetText("c_" + TruncateCardId(s2) + "_fluff", "cards"); if (!string.IsNullOrEmpty(text2)) { crd.Fluff = text2; } } catch { } } private static void ForceRebuildDescription(CardRealtimeData crd) { if (crd == (CardRealtimeData)null) { return; } try { Globals instance = Globals.Instance; IDictionary dictionary = typeof(Globals).GetProperty("CardsDescriptionNormalized", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance) as IDictionary; if (dictionary != null && dictionary.Contains(crd.Id)) { dictionary.Remove(crd.Id); } MethodInfo method = typeof(CardDescriptionUtility).GetMethod("SetDescriptionNew", BindingFlags.Static | BindingFlags.Public, null, new Type[4] { typeof(CardRealtimeData), typeof(bool), typeof(Character), typeof(bool) }, null); if (method != null) { method.Invoke(null, new object[4] { crd, true, null, false }); } string text = FixCurseSpriteNames(crd.DescriptionNormalized); if (text != null && text != crd.DescriptionNormalized) { crd.DescriptionNormalized = text; if (dictionary != null) { dictionary[crd.Id] = text; } } } catch (Exception ex) { if (ex is TargetInvocationException { InnerException: not null } ex2) { _ = ex2.InnerException; } } } private static void BuildCurseNameMap(Globals g) { CurseNameToId.Clear(); try { if (!(FindFieldShallow(typeof(Globals), "_AurasCurses")?.GetValue(g) is IDictionary dictionary)) { return; } foreach (DictionaryEntry item in dictionary) { string text = item.Key as string; object? value = item.Value; AuraCurseData val = (AuraCurseData)((value is AuraCurseData) ? value : null); if (val == null) { continue; } string text2 = val.Id; if (string.IsNullOrEmpty(text2)) { text2 = text; } if (!string.IsNullOrEmpty(text2)) { CurseNameToId[NormalizeSpriteName(text2)] = text2.ToLowerInvariant(); if (!string.IsNullOrEmpty(text)) { CurseNameToId[NormalizeSpriteName(text)] = text2.ToLowerInvariant(); } string aCName = val.ACName; if (!string.IsNullOrEmpty(aCName)) { CurseNameToId[NormalizeSpriteName(aCName)] = text2.ToLowerInvariant(); } } } } catch { } } private static string NormalizeSpriteName(string s) { if (!string.IsNullOrEmpty(s)) { return s.ToLowerInvariant().Replace(" ", ""); } return s; } private static string FixCurseSpriteNames(string desc) { if (string.IsNullOrEmpty(desc) || CurseNameToId.Count == 0) { return desc; } return SpriteTagRegex.Replace(desc, delegate(Match m) { string key = NormalizeSpriteName(m.Groups[1].Value); string value; return CurseNameToId.TryGetValue(key, out value) ? ("<sprite name=" + value + ">") : m.Value; }); } private static void SetDescriptionNewPostfix(CardRealtimeData __0) { if (!(__0 == (CardRealtimeData)null)) { SetDescriptionNewPostfixCore(__0); } } private static void SetDescriptionNewPostfixCore(CardRealtimeData __0) { try { string descriptionNormalized = __0.DescriptionNormalized; if (string.IsNullOrEmpty(descriptionNormalized)) { return; } string text = FixItemXEqualsTarget(__0, descriptionNormalized); if (CurseNameToId.Count > 0) { text = FixCurseSpriteNames(text); } if (text != null && !(text == descriptionNormalized)) { __0.DescriptionNormalized = text; Globals instance = Globals.Instance; if (typeof(Globals).GetProperty("CardsDescriptionNormalized", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance) is IDictionary dictionary && dictionary.Contains(__0.Id)) { dictionary[__0.Id] = text; } } } catch { } } private static string FixItemXEqualsTarget(CardRealtimeData data, string desc) { ItemData val = data.ItemEnchantment ?? data.Item; if ((Object)(object)val == (Object)null || !UsesTargetAuraSpecialValue(val)) { return desc; } string text = Texts.Instance.GetText("cardsXEqualsYour", ""); string text2 = Texts.Instance.GetText("cardsXEqualsTarget", ""); if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) { return desc; } int num = text.IndexOf('{'); int num2 = text2.IndexOf('{'); string text3 = ((num >= 0) ? text.Substring(0, num) : text); string text4 = ((num2 >= 0) ? text2.Substring(0, num2) : text2); if (string.IsNullOrEmpty(text3) || text3 == text4) { return desc; } return desc.Replace(text3, text4); } private static bool UsesTargetAuraSpecialValue(ItemData item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!IsAuracurseSetCharges(item.AuracurseGain1SpecialValue) && !IsAuracurseSetCharges(item.AuracurseGain2SpecialValue) && !IsAuracurseSetCharges(item.AuracurseGain3SpecialValue) && !IsAuracurseSetCharges(item.DttSpecialValues1) && !IsAuracurseSetCharges(item.DttSpecialValues2)) { return IsAuracurseSetCharges(item.HealQuantitySpecialValue); } return true; } private static bool IsAuracurseSetCharges(SpecialValues sv) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 if (sv.Use) { return (int)sv.Name == 2; } return false; } private static void PatchDynamicEnchantmentX() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00ef: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_018f: Expected O, but got Unknown Type[] array = new Type[10] { typeof(Character), typeof(string), typeof(int), typeof(CardRealtimeData), typeof(string), typeof(ItemData), typeof(Character), typeof(int), typeof(CardRealtimeData), typeof(EventActivation) }; MethodInfo methodInfo = AccessTools.Method(typeof(Item), "DoItemData", array, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "ItemDoItemDataCapturePrefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "ItemDoItemDataReleasePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } Type[] array2 = new Type[4] { typeof(int), typeof(SpecialValues), typeof(ItemData), typeof(Character) }; MethodInfo methodInfo2 = AccessTools.Method(typeof(ItemData), "GetModifiedValue", array2, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "ItemDataGetModifiedValueRestoreContextPrefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "ItemDataGetModifiedValueRoundAuracursePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void PatchSoundLazyResolve() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(SoundData), "GetSoundHit", Type.EmptyTypes, (Type[])null); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "SoundDataGetSoundHitPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } MethodInfo methodInfo2 = AccessTools.Method(typeof(SoundData), "GetSoundRelease", new Type[2] { typeof(Hero), typeof(NPC) }, (Type[])null); if (methodInfo2 != null) { harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(ContentCompat), "SoundDataGetSoundReleasePostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } catch { } } private static void SoundDataGetSoundHitPostfix(SoundData __instance, ref AudioClip __result) { if ((Object)(object)__result != (Object)null || __instance == null) { return; } string text = CardImporter.SoundName(__instance, 0); if (!string.IsNullOrEmpty(text)) { AudioClip val = ResolveAudio(text); if (!((Object)(object)val == (Object)null)) { CardImporter.ApplySound(__instance, val, null, null); __result = val; } } } private static void SoundDataGetSoundReleasePostfix(SoundData __instance, Hero hero, NPC npc, ref AudioClip __result) { if ((Object)(object)__result != (Object)null || __instance == null) { return; } string id = CardImporter.SoundName(__instance, 1); string id2 = CardImporter.SoundName(__instance, 2); bool flag = false; try { if (hero != null && (Object)(object)((Character)hero).HeroData != (Object)null && (Object)(object)((Character)hero).HeroData.HeroSubClass != (Object)null) { flag = ((Character)hero).HeroData.HeroSubClass.Female; } else if (npc != null && (Object)(object)((Character)npc).NpcData != (Object)null) { flag = ((Character)npc).NpcData.Female; } } catch { } AudioClip val = (flag ? ResolveAudio(id2) : null); AudioClip val2 = val ?? ResolveAudio(id); if (!((Object)(object)val2 == (Object)null)) { CardImporter.ApplySound(__instance, null, val2, val); __result = val2; } } private static void ItemDoItemDataCapturePrefix(Character target, ItemData itemData) { ItemDamageContexts.Push(new ItemDamageContext { Target = target, ItemData = itemData }); } private static void ItemDoItemDataReleasePostfix() { if (ItemDamageContexts.Count > 0) { ItemDamageContexts.Pop(); } } private static void ItemDataGetModifiedValueRestoreContextPrefix(ItemData __instance, SpecialValues specialValues, ref ItemData itemData, ref Character target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (IsAuracurseSetCharges(specialValues)) { ItemDamageContext itemDamageContext = ((ItemDamageContexts.Count > 0) ? ItemDamageContexts.Peek() : default(ItemDamageContext)); if ((Object)(object)itemData == (Object)null) { itemData = itemDamageContext.ItemData ?? __instance; } if (target == null) { target = itemDamageContext.Target; } } } private static void ItemDataGetModifiedValueRoundAuracursePostfix(ItemData __instance, SpecialValues specialValues, ItemData itemData, Character target, ref int __result) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (IsAuracurseSetCharges(specialValues) && target != null) { ItemDamageContext itemDamageContext = ((ItemDamageContexts.Count > 0) ? ItemDamageContexts.Peek() : default(ItemDamageContext)); ItemData val = itemData ?? itemDamageContext.ItemData ?? __instance; AuraCurseData val2 = (((Object)(object)val == (Object)null) ? null : val.AuraCurseSetted); if (!((Object)(object)val2 == (Object)null)) { __result = Functions.FuncRoundToInt((float)target.GetAuraCharges(val2.Id) * specialValues.Multiplier); } } } private static string NormalizeId(string s) { return s?.Replace(" ", "").ToLowerInvariant(); } private static string GetKey(object obj, Type type) { string[] array = new string[6] { "Id", "PackId", "TraitName", "SubClassName", "NPCName", "TierNum" }; foreach (string name in array) { MemberInfo memberInfo = FindMember(type, name); if (memberInfo == null) { continue; } object member = GetMember(memberInfo, obj); if (member != null) { string text = member.ToString(); if (type == typeof(SubClassData)) { text = text.Replace(" ", "").ToLowerInvariant(); } return text; } } return null; } private static object CreateInstance(Type type) { if (typeof(ScriptableObject).IsAssignableFrom(type)) { return ScriptableObject.CreateInstance(type); } return Activator.CreateInstance(type); } private static void FixSubClassData(object obj, JObject json, object vanilla, string key) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Invalid comparison between Unknown and I4 try { SetMemberByName(obj, "Blocked", false); SetMemberByName(obj, "MainCharacter", true); ForceHeroClassFromJson(obj, json, "HeroClassSecondary"); ForceHeroClassFromJson(obj, json, "HeroClassThird"); string value = ((JToken)json).Value<string>((object)"SourceCharacterName"); if (!string.IsNullOrEmpty(value)) { SetMemberByName(obj, "SourceCharacterName", value); } JToken value2 = json.GetValue("AutoUnlock", StringComparison.OrdinalIgnoreCase); bool flag = value2 != null && (int)value2.Type != 10 && Convert.ToBoolean(((object)value2).ToString()); SetMemberByName(obj, "InitialUnlock", flag); if (!(GetMemberByName(obj, "CardsSingularity") is ICollection { Count: >=15 }) && vanilla != null) { object memberByName = GetMemberByName(vanilla, "CardsSingularity"); if (memberByName != null) { SetMemberByName(obj, "CardsSingularity", memberByName); } } RestoreSubClassRefs(obj, vanilla); } catch { } } private static void ForceHeroClassFromJson(object obj, JObject json, string memberName) { try { MemberInfo memberInfo = FindMember(obj.GetType(), memberName); if (memberInfo == null) { return; } Type memberType = GetMemberType(memberInfo); if (memberType.IsEnum) { string value = ((object)json.GetValue(memberName, StringComparison.OrdinalIgnoreCase))?.ToString(); if (string.IsNullOrWhiteSpace(value)) { value = "None"; } object value2 = Enum.Parse(memberType, value, ignoreCase: true); SetMember(memberInfo, obj, value2); } } catch { } } private static void RestoreSubClassRefs(object obj, object vanilla) { if (obj == null || vanilla == null) { return; } string[] array = new string[10] { "Item", "Trait0", "Trait1A", "Trait1B", "Trait2A", "Trait2B", "Trait3A", "Trait3B", "Trait4A", "Trait4B" }; foreach (string name in array) { if (GetMemberByName(obj, name) == null) { object memberByName = GetMemberByName(vanilla, name); if (memberByName != null) { SetMemberByName(obj, name, memberByName); } } } object memberByName2 = GetMemberByName(obj, "Cards"); object memberByName3 = GetMemberByName(vanilla, "Cards"); if (!(memberByName3 is Array array2)) { return; } if (memberByName2 is Array { Length: not 0 } array3) { int num = Math.Min(array3.Length, array2.Length); for (int j = 0; j < num; j++) { object value = array3.GetValue(j); if (value != null && GetMemberByName(value, "Card") == null) { object value2 = array2.GetValue(j); object obj2 = ((value2 == null) ? null : GetMemberByName(value2, "Card")); if (obj2 != null) { SetMemberByName(value, "Card", obj2); } } } } else { SetMemberByName(obj, "Cards", memberByName3); } } private static void SetMemberByName(object obj, string name, object value) { MemberInfo memberInfo = FindMember(obj.GetType(), name); if (memberInfo != null) { SetMember(memberInfo, obj, value); } } private static object GetMemberByName(object obj, string name) { MemberInfo memberInfo = FindMember(obj.GetType(), name); if (!(memberInfo == null)) { return GetMember(memberInfo, obj); } return null; } private static void CallInit(object obj, Type type) { try { MethodInfo method = type.GetMethod("Init", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null && method.GetParameters().Length == 0) { method.Invoke(obj, null); } } catch { } } private static void CopyMissingFields(object target, object vanilla, Type type, JObject json) { HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (JProperty item2 in json.Properties()) { string text = Normalize(item2.Name); if (Aliases.TryGetValue(text, out var value)) { text = value; } hashSet.Add(text); } MemberInfo[] members = type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MemberInfo memberInfo in members) { if (!(memberInfo is FieldInfo) && !(memberInfo is PropertyInfo { CanWrite: not false })) { continue; } string item = Normalize(memberInfo.Name); if (hashSet.Contains(item)) { continue; } try { object member = GetMember(memberInfo, vanilla); if (member != null && GetMember(memberInfo, target) == null) { SetMember(memberInfo, target, member); } } catch { } } } private static void Populate(object target, JObject json, Type type) { Dictionary<string, MemberInfo> dictionary = new Dictionary<string, MemberInfo>(StringComparer.OrdinalIgnoreCase); MemberInfo[] members = type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MemberInfo memberInfo in members) { if (memberInfo is FieldInfo || memberInfo is PropertyInfo { CanWrite: not false }) { dictionary[Normalize(memberInfo.Name)] = memberInfo; } } foreach (JProperty item in json.Properties()) { string key = Normalize(item.Name); if (Aliases.TryGetValue(key, out var value)) { key = value; } if (!dictionary.TryGetValue(key, out var value2)) { continue; } Type memberType = GetMemberType(value2); try { object obj = ConvertToken(item.Value, memberType); if (obj is PendingMarker pendingMarker) { Pending.Add(new PendingReference { Target = target, Member = value2, Id = pendingMarker.Id, IsList = pendingMarker.IsList, WantedType = pendingMarker.WantedType }); } else if (obj != null) { SetMember(value2, target, obj); } } catch { } } } private static object ConvertToken(JToken token, Type targetType) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Invalid comparison between Unknown and I4 //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Invalid comparison between Unknown and I4 if (token == null || (int)token.Type == 10) { return null; } if (targetType == typeof(string)) { return ((object)token).ToString(); } if (targetType.IsEnum) { return Enum.Parse(targetType, ((object)token).ToString(), ignoreCase: true); } if (targetType == typeof(int) || targetType == typeof(short) || targetType == typeof(byte)) { return Convert.ToInt32(token.ToObject<object>()); } if (targetType == typeof(float)) { return Convert.ToSingle(token.ToObject<object>()); } if (targetType == typeof(double)) { return Convert.ToDouble(token.ToObject<object>()); } if (targetType == typeof(bool)) { return Convert.ToBoolean(token.ToObject<object>()); } if (typeof(IEnumerable).IsAssignableFrom(targetType) && targetType != typeof(string)) { Type type = (targetType.IsArray ? targetType.GetElementType() : targetType.GetGenericArguments().FirstOrDefault()); JArray val = (JArray)(object)((token is JArray) ? token : null); if (val == null && (int)token.Type == 8) { string text = ((object)token).ToString().Trim(); if (text.StartsWith("[") || text.StartsWith("{")) { try { JToken obj = JToken.Parse(text); val = (JArray)(object)((obj is JArray) ? obj : null); } catch { } } } if (val == null) { if (type != null && IsReferenceType(type)) { return new PendingMarker { Id = ((object)token).ToString(), IsList = true, WantedType = type }; } if (type != null && type.IsEnum) { IList obj3 = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type)); obj3.Add(Enum.Parse(type, ((object)token).ToString(), ignoreCase: true)); return obj3; } return null; } IList list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type)); foreach (JToken item in val) { object obj4 = ConvertToken(item, type); if (obj4 is PendingMarker result) { return result; } if (obj4 != null) { list.Add(obj4); } } if (targetType.IsArray) { Array array = Array.CreateInstance(type, list.Count); list.CopyTo(array, 0); return array; } return list; } if (IsReferenceType(targetType) && (int)token.Type == 8) { string text2 = ((object)token).ToString().Trim(); if (text2.StartsWith("{") || text2.StartsWith("[")) { try { object obj5 = ConvertToken(JToken.Parse(text2), targetType); if (obj5 != null && !(obj5 is PendingMarker)) { return obj5; } } catch { } } return new PendingMarker { Id = ((object)token).ToString(), IsList = false, WantedType = targetType }; } JObject val2 = (JObject)(object)((token is JObject) ? token : null); if (val2 != null) { object obj7 = CreateInstance(targetType); if (obj7 != null) { Populate(obj7, val2, targetType); return obj7; } } return null; } private static bool IsReferenceType(Type t) { if (!t.IsPrimitive && !t.IsEnum && t != typeof(string) && t != typeof(decimal)) { return !t.IsValueType; } return false; } private static void ResolvePending() { foreach (PendingReference item in Pending) { try { object obj; if (item.WantedType == typeof(AudioClip)) { obj = ResolveAudio(item.Id); if (obj != null) { goto IL_00c9; } } else if (item.WantedType == typeof(Sprite)) { obj = ResolveSprite(item.Id); if (obj != null) { goto IL_00c9; } } else if (item.WantedType == typeof(GameObject)) { obj = FindGameObject(item.Id); if (obj != null) { goto IL_00c9; } } else { obj = MapFind(item.Id, item.WantedType); if (obj != null && item.WantedType.IsInstanceOfType(obj)) { goto IL_00c9; } } goto end_IL_0018; IL_00c9: Type memberType = GetMemberType(item.Member); if (item.IsList || memberType.IsArray || (memberType.IsGenericType && memberType.GetGenericTypeDefinition() == typeof(List<>))) { Type type = (memberType.IsArray ? memberType.GetElementType() : memberType.GetGenericArguments().FirstOrDefault()); if (type == null) { continue; } List<object> list = new List<object>(); if (obj is IEnumerable enumerable && !(obj is string)) { foreach (object item2 in enumerable) { if (item2 != null && type.IsInstanceOfType(item2)) { list.Add(item2); } } } else if (type.IsInstanceOfType(obj)) { list.Add(obj); } if (list.Count == 0) { continue; } if (memberType.IsArray) { Array array = Array.CreateInstance(type, list.Count); for (int i = 0; i < list.Count; i++) { array.SetValue(list[i], i); } SetMember(item.Member, item.Target, array); continue; } IList list2 = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(type)); foreach (object item3 in list) { list2.Add(item3); } SetMember(item.Member, item.Target, list2); continue; } SetMember(item.Member, item.Target, obj); end_IL_0018:; } catch { } } Pending.Clear(); } private static void Inject(List<KeyValuePair<string, object>> overridden = null) { Globals instance = Globals.Instance; if ((Object)(object)instance == (Object)null) { Log.LogWarning((object)"Globals.Instance is null, injection skipped"); return; } Dictionary<Type, Dictionary<string, object>> dictionary = new Dictionary<Type, Dictionary<string, object>>(); foreach (KeyValuePair<string, object> item in overridden ?? _overriddenNonCards) { Type type = item.Value.GetType(); if (!dictionary.TryGetValue(type, out var value)) { value = (dictionary[type] = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase)); } value[item.Key] = item.Value; } foreach (KeyValuePair<string, List<object>> item2 in IdMap) { foreach (object item3 in item2.Value) { Type type2 = item3.GetType(); if (!TypeToGlobalField.TryGetValue(type2, out var value2)) { continue; } try { FieldInfo field = typeof(Globals).GetField(value2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { continue; } object value3 = field.GetValue(instance); if (value3 == null) { continue; } MethodInfo method = value3.GetType().GetMethod("ContainsKey", BindingFlags.Instance | BindingFlags.Public); Dictionary<string, object> value4; bool flag = dictionary.TryGetValue(type2, out value4) && value4.ContainsKey(item2.Key) && value4[item2.Key] == item3; if (!(method != null) || !(bool)method.Invoke(value3, new object[1] { item2.Key }) || flag) { if (!flag) { goto IL_01e6; } MethodInfo method2 = value3.GetType().GetMethod("set_Item", BindingFlags.Instance | BindingFlags.Public); if (!(method2 != null)) { goto IL_01e6; } method2.Invoke(value3, new object[2] { item2.Key, item3 }); } goto end_IL_00f0; IL_01e6: MethodInfo method3 = value3.GetType().GetMethod("Add", BindingFlags.Instance | BindingFlags.Public); if (!(method3 == null)) { method3.Invoke(value3, new object[2] { item2.Key, item3 }); } end_IL_00f0:; } catch { } } } try { instance.CreateTraitClones(); ApplyModTraitTexts(); } catch { } RebuildRuntime(instance, "_SubClassSource", "_SubClass", instantiate: true); CopySourceToRuntime(instance, "_AurasCursesSource", "_AurasCurses"); CopySourceToRuntime(instance, "_NPCsSource", "_NPCs"); } private static void RebuildRuntime(Globals g, string sourceField, string runtimeField, bool instantiate) { try { FieldInfo field = typeof(Globals).GetField(sourceField, BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(Globals).GetField(runtimeField, BindingFlags.Instance | BindingFlags.NonPublic); if (field == null || field2 == null) { return; } IDictionary dictionary = (IDictionary)field.GetValue(g); if (dictionary == null) { return; } IDictionary dictionary2 = (IDictionary)field2.GetValue(g); if (dictionary2 == null) { return; } dictionary2.Clear(); IDictionaryEnumerator dictionaryEnumerator = dictionary.GetEnumerator(); try { DictionaryEntry dictionaryEntry; object obj; object value2; for (; dictionaryEnumerator.MoveNext(); value2 = obj, dictionary2[dictionaryEntry.Key] = value2) { dictionaryEntry = (DictionaryEntry)dictionaryEnumerator.Current; if (instantiate) { object? value = dictionaryEntry.Value; Object val = (Object)((value is Object) ? value : null); if (val != null) { obj = Object.Instantiate(val); continue; } } obj = dictionaryEntry.Value; } } finally { IDisposable disposable = dictionaryEnumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } catch { } } private static void CopySourceToRuntime(Globals g, string sourceField, string runtimeField) { try { FieldInfo field = typeof(Globals).GetField(sourceField, BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field2 = typeof(Globals).GetField(runtimeField, BindingFlags.Instance | BindingFlags.NonPublic); if (field == null || field2 == null) { return; } IDictionary dictionary = (IDictionary)field.GetValue(g); IDictionary dictionary2 = (IDictionary)field2.GetValue(g); if (dictionary == null || dictionary2 == null) { return; } foreach (DictionaryEntry item in dictionary) { dictionary2[item.Key] = item.Value; } } catch { } } private static object ResolveAnyReference(string id, Type wanted) { if (string.IsNullOrEmpty(id)) { return null;