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.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using DiskCardGame; using HarmonyLib; using InscryptionAPI.Card; using InscryptionAPI.Dialogue; using InscryptionAPI.Helpers; using InscryptionAPI.Pelts; using InscryptionAPI.Pelts.Extensions; using OLD_SA.Pelt; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OldSa_Pelt")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OldSa_Pelt")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b8818afc-f159-4d5d-a320-9616352cd5db")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace OLD_SA.Incorporal { [HarmonyPatch(typeof(RenderStatsLayer), "AssignCopiedRenderTexture")] public static class GhostCardRenderTexturePatch { [HarmonyPostfix] private static void Postfix(RenderStatsLayer __instance, Texture tex, bool emission) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)tex == (Object)null)) { object? obj = AccessTools.Property(typeof(RenderStatsLayer), "PlayableCard")?.GetValue(__instance, null); PlayableCard val = (PlayableCard)((obj is PlayableCard) ? obj : null); if (!((Object)(object)val == (Object)null) && GhostCard.IsApplied(val)) { GhostCard.SyncRenderTexture(val, tex, emission); } } } } } namespace OLD_SA.Pelt { public static class GhostCard { private static AssetBundle ghostBundle; private static Material ghostBaseMaterial; private static readonly Dictionary originalMaterials = new Dictionary(); private static readonly Dictionary ghostMaterials = new Dictionary(); private static string BundlePath => Path.Combine(Paths.PluginPath, "OLD_SA_DLC", "OLD_SA_Card", "old_sa_ghost"); private static bool LoadGhostBundle() { if ((Object)(object)ghostBaseMaterial != (Object)null) { return true; } if ((Object)(object)ghostBundle == (Object)null) { if (!File.Exists(BundlePath)) { return false; } ghostBundle = AssetBundle.LoadFromFile(BundlePath); if ((Object)(object)ghostBundle == (Object)null) { return false; } } ghostBaseMaterial = ghostBundle.LoadAsset("assets/ghostcard_material.mat"); if ((Object)(object)ghostBaseMaterial == (Object)null) { return false; } return true; } public static void SyncRenderTexture(PlayableCard card, Texture tex, bool emission) { if ((Object)(object)card == (Object)null || (Object)(object)tex == (Object)null) { return; } Material value = null; if (!ghostMaterials.TryGetValue(card, out value) || (Object)(object)value == (Object)null) { return; } if (emission) { if (value.HasProperty("_EmissionMap")) { value.SetTexture("_EmissionMap", tex); } } else if (value.HasProperty("_MainTex")) { value.SetTexture("_MainTex", tex); } Material value2 = null; if (!originalMaterials.TryGetValue(card, out value2) || !((Object)(object)value2 != (Object)null)) { return; } if (emission) { if (value2.HasProperty("_EmissionMap")) { value2.SetTexture("_EmissionMap", tex); } } else if (value2.HasProperty("_MainTex")) { value2.SetTexture("_MainTex", tex); } } public static void Apply(PlayableCard card) { //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown if ((Object)(object)card == (Object)null || (Object)(object)((Card)card).StatsLayer == (Object)null) { return; } Material value = null; if (ghostMaterials.TryGetValue(card, out value)) { if (!((Object)(object)value == (Object)null)) { if ((Object)(object)((Card)card).StatsLayer.Material != (Object)(object)value) { ((Card)card).StatsLayer.Material = value; } return; } ghostMaterials.Remove(card); } if ((Object)(object)((Card)card).StatsLayer.Material == (Object)null || !LoadGhostBundle()) { return; } Material material = ((Card)card).StatsLayer.Material; if ((Object)(object)material == (Object)null) { return; } Material val = new Material(ghostBaseMaterial); if (material.HasProperty("_MainTex") && val.HasProperty("_MainTex")) { Texture texture = material.GetTexture("_MainTex"); if ((Object)(object)texture != (Object)null) { val.SetTexture("_MainTex", texture); } } if (material.HasProperty("_EmissionMap") && val.HasProperty("_EmissionMap")) { Texture texture2 = material.GetTexture("_EmissionMap"); if ((Object)(object)texture2 != (Object)null) { val.SetTexture("_EmissionMap", texture2); } } originalMaterials[card] = material; ghostMaterials[card] = val; ((Card)card).StatsLayer.Material = val; } public static void Refresh(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { Material value = null; if (ghostMaterials.TryGetValue(card, out value) && !((Object)(object)value == (Object)null) && !((Object)(object)((Card)card).StatsLayer == (Object)null) && (Object)(object)((Card)card).StatsLayer.Material != (Object)(object)value) { ((Card)card).StatsLayer.Material = value; } } } public static void Remove(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { Material value = null; originalMaterials.TryGetValue(card, out value); Material value2 = null; ghostMaterials.TryGetValue(card, out value2); if ((Object)(object)((Card)card).StatsLayer != (Object)null && (Object)(object)value != (Object)null) { ((Card)card).StatsLayer.Material = value; } if ((Object)(object)value2 != (Object)null) { Object.Destroy((Object)(object)value2); } originalMaterials.Remove(card); ghostMaterials.Remove(card); } } public static bool IsApplied(PlayableCard card) { if ((Object)(object)card == (Object)null) { return false; } Material value = null; if (!ghostMaterials.TryGetValue(card, out value)) { return false; } if ((Object)(object)value == (Object)null) { return false; } if ((Object)(object)((Card)card).StatsLayer == (Object)null) { return false; } return (Object)(object)((Card)card).StatsLayer.Material == (Object)(object)value; } public static Material GetGhostMaterial(PlayableCard card) { if ((Object)(object)card == (Object)null) { return null; } Material value = null; if (ghostMaterials.TryGetValue(card, out value)) { return value; } return null; } public static void Forget(PlayableCard card) { if (!((Object)(object)card == (Object)null)) { Material value = null; if (ghostMaterials.TryGetValue(card, out value) && (Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } originalMaterials.Remove(card); ghostMaterials.Remove(card); } } } public static class HolyPelt { private const string HolyPeltName = "OLD_SA_HOLY_PELT"; public static void Initialize() { RegisterHolyPelt(); } private static void RegisterHolyPelt() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) CardInfo cardByName = CardLoader.GetCardByName("OLD_SA_HOLY_PELT"); Func> func = () => CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0); PeltData val = PeltManager.New("OLD_SA.Pelt", cardByName, func, 11, 1, 4); val.peltTierName = "Holy"; val.isSoldByTrapper = true; DialogueManager.GenerateTraderPeltsEvent("OLD_SA.Pelt", val, new List { CustomLine.op_Implicit("Your creatures have all been driven wild by this.") }, (List>)null); } private static int GetHolyPeltPrice(SelectableCard card) { PeltData val = PeltManager.AllPeltsAvailableAtTrader().Find((PeltData x) => x != null && x.peltCardName == "OLD_SA_HOLY_PELT"); if (val != null) { return val.BuyPrice; } return 11; } } public class OldSaEerieForestBackground : CardAppearanceBehaviour { public static Appearance ID; private static Texture2D BackgroundTexture; public override void ApplyAppearance() { if ((Object)(object)BackgroundTexture == (Object)null) { BackgroundTexture = TextureHelper.GetImageAsTexture("OldSa_Eerie_Forest_Background.png", (FilterMode)0); } ((CardAppearanceBehaviour)this).Card.RenderInfo.baseTextureOverride = (Texture)(object)BackgroundTexture; } } public class OldSaMythBackground : CardAppearanceBehaviour { public static Appearance ID; private static Texture2D BackgroundTexture; public override void ApplyAppearance() { if ((Object)(object)BackgroundTexture == (Object)null) { BackgroundTexture = TextureHelper.GetImageAsTexture("OldSa_Myth_Background.png", (FilterMode)0); } ((CardAppearanceBehaviour)this).Card.RenderInfo.baseTextureOverride = (Texture)(object)BackgroundTexture; } } public class OldSaPlantBackground : CardAppearanceBehaviour { public static Appearance ID; private static Texture2D BackgroundTexture; public override void ApplyAppearance() { if ((Object)(object)BackgroundTexture == (Object)null) { BackgroundTexture = TextureHelper.GetImageAsTexture("OldSa_Plant_Background.png", (FilterMode)0); } ((CardAppearanceBehaviour)this).Card.RenderInfo.baseTextureOverride = (Texture)(object)BackgroundTexture; } } [BepInPlugin("OLD_SA.Pelt", "OLD SA Pelt", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "OLD_SA.Pelt"; public const string PluginName = "OLD SA Pelt"; public const string PluginVersion = "1.0.0"; internal static Plugin Instance; internal static ManualLogSource Log; private const string BrokenPeltName = "OLD_SA_BROKEN_PELT"; private const string HolyPeltName = "OLD_SA_HOLY_PELT"; private const string BrokenModificationId = "OLD_SA_BROKEN_PELT_MOD"; private void Awake() { //IL_002e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; try { FullCardAppearanceBehaviour val = CardAppearanceBehaviourManager.Add("OLD_SA.Pelt", "RainbowEmission", typeof(RainbowEmission)); RainbowEmission.ID = val.Id; FullCardAppearanceBehaviour val2 = CardAppearanceBehaviourManager.Add("OLD_SA.Pelt", "SacredSilver", typeof(SacredSilver)); SacredSilver.ID = val2.Id; FullCardAppearanceBehaviour val3 = CardAppearanceBehaviourManager.Add("OLD_SA.Pelt", "OldSa_Eerie_Forest_Background", typeof(OldSaEerieForestBackground)); OldSaEerieForestBackground.ID = val3.Id; FullCardAppearanceBehaviour val4 = CardAppearanceBehaviourManager.Add("OLD_SA.Pelt", "OldSa_Plant_Background", typeof(OldSaPlantBackground)); OldSaPlantBackground.ID = val4.Id; FullCardAppearanceBehaviour val5 = CardAppearanceBehaviourManager.Add("OLD_SA.Pelt", "OldSa_Myth_Background", typeof(OldSaMythBackground)); OldSaMythBackground.ID = val5.Id; RegisterBrokenPelt(); HolyPelt.Initialize(); PurePelt.Initialize(); Harmony val6 = new Harmony("OLD_SA.Pelt"); val6.PatchAll(); } catch (Exception ex) { Log.LogError((object)("[OLD SA Pelt] Initialization failed: " + ex)); } } private void RegisterBrokenPelt() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) CardInfo cardByName = CardLoader.GetCardByName("OLD_SA_BROKEN_PELT"); if ((Object)(object)cardByName == (Object)null) { Log.LogError((object)"[OLD SA Pelt] Could not find card: OLD_SA_BROKEN_PELT"); return; } Func> func = delegate { List unlockedCards = CardLoader.GetUnlockedCards((CardMetaCategory)1, (CardTemple)0); unlockedCards.RemoveAll((CardInfo card) => !CanBeBroken(card)); return unlockedCards; }; PeltData val = PeltManager.New("OLD_SA.Pelt", cardByName, func, 1, 0, 8); val.isSoldByTrapper = false; val.peltTierName = "Broken"; DialogueManager.GenerateTraderPeltsEvent("OLD_SA.Pelt", val, new List { CustomLine.op_Implicit("What good do you think I have to offer you?") }, (List>)null); PeltExtensions.SetModifyCardChoiceAtTrader(val, (Action)ModifyBrokenCard); PeltExtensions.SetModifyCardChoiceAtTrader(val, (Action)ModifyBrokenCard); Log.LogInfo((object)"[OLD SA Pelt] Registered OLD_SA_BROKEN_PELT."); } private static bool CanBeBroken(CardInfo cardInfo) { if ((Object)(object)cardInfo == (Object)null) { return false; } if (cardInfo.Attack > 0) { return true; } if (cardInfo.Health > 2) { return true; } if (cardInfo.Abilities != null && cardInfo.Abilities.Count > 0) { return true; } return false; } private static void ModifyBrokenCard(CardInfo cardInfo) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown if ((Object)(object)cardInfo == (Object)null) { return; } if (cardInfo.Mods != null) { foreach (CardModificationInfo mod in cardInfo.Mods) { if (mod == null || !(mod.singletonId == "OLD_SA_BROKEN_PELT_MOD")) { continue; } return; } } int attack = cardInfo.Attack; int health = cardInfo.Health; bool flag = attack > 0; bool flag2 = health > 2; CardModificationInfo val = new CardModificationInfo(); if (flag && flag2) { if (Random.Range(0, 2) == 0) { val.attackAdjustment = -1; } else { val.healthAdjustment = -2; } } else if (flag) { val.attackAdjustment = -1; } else if (flag2) { val.healthAdjustment = -2; } else { RemoveRandomAbility(cardInfo, val); } string text = cardInfo.DisplayedNameLocalized; if (string.IsNullOrEmpty(text)) { text = ((Object)cardInfo).name; } val.nameReplacement = string.Format(Localization.Translate("Broken {0}"), text); val.singletonId = "OLD_SA_BROKEN_PELT_MOD"; if (cardInfo.Mods == null) { cardInfo.Mods = new List(); } cardInfo.Mods.Add(val); } private static void RemoveRandomAbility(CardInfo cardInfo, CardModificationInfo brokenMod) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (cardInfo.Abilities != null && cardInfo.Abilities.Count != 0) { List list = new List(cardInfo.Abilities); if (list.Count != 0) { Ability item = list[Random.Range(0, list.Count)]; brokenMod.negateAbilities = new List(); brokenMod.negateAbilities.Add(item); } } } internal static bool HasBrokenPeltInHand() { if ((Object)(object)Singleton.Instance == (Object)null) { return false; } foreach (PlayableCard item in Singleton.Instance.CardsInHand) { if ((Object)(object)item == (Object)null || (Object)(object)((Card)item).Info == (Object)null || !(((Object)((Card)item).Info).name == "OLD_SA_BROKEN_PELT")) { continue; } return true; } return false; } internal static bool HasHolyPeltInHand() { if ((Object)(object)Singleton.Instance == (Object)null) { return false; } foreach (PlayableCard item in Singleton.Instance.CardsInHand) { if ((Object)(object)item == (Object)null || (Object)(object)((Card)item).Info == (Object)null || !(((Object)((Card)item).Info).name == "OLD_SA_HOLY_PELT")) { continue; } return true; } return false; } } public static class PurePelt { private const string PurePeltName = "OLD_SA_PURE_PELT"; private const string PureModificationId = "OLD_SA_PURE_PELT_MOD"; public static void Initialize() { RegisterPurePelt(); } private static void RegisterPurePelt() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) CardInfo cardByName = CardLoader.GetCardByName("OLD_SA_PURE_PELT"); if ((Object)(object)cardByName == (Object)null) { Debug.LogError((object)"[OLD SA Pelt] Could not find card: OLD_SA_PURE_PELT"); return; } Func> func = delegate { List unlockedCards = CardLoader.GetUnlockedCards((CardMetaCategory)3, (CardTemple)0); unlockedCards.RemoveAll((CardInfo card) => !CanReceivePure(card)); return unlockedCards; }; PeltData val = PeltManager.New("OLD_SA.Pelt", cardByName, func, 11, 0, 4); val.peltTierName = "Pure"; val.isSoldByTrapper = true; DialogueManager.GenerateTraderPeltsEvent("OLD_SA.Pelt", val, new List { CustomLine.op_Implicit("Your creatures are purged of impurity and grow stronger.") }, (List>)null); PeltExtensions.SetModifyCardChoiceAtTrader(val, (Action)ModifyPureCard); } private static bool CanReceivePure(CardInfo cardInfo) { if ((Object)(object)cardInfo == (Object)null) { return false; } bool flag = HasAttackParameter(cardInfo); bool flag2 = HasHealthParameter(cardInfo); if (flag && flag2) { return false; } return true; } private static bool HasAttackParameter(CardInfo cardInfo) { if ((Object)(object)cardInfo == (Object)null) { return false; } if (HasSpecialStatIconAttack(cardInfo)) { return true; } if (cardInfo.Mods != null) { foreach (CardModificationInfo mod in cardInfo.Mods) { if (mod == null || mod.attackAdjustment <= 0) { continue; } return true; } } return false; } private static bool HasHealthParameter(CardInfo cardInfo) { if ((Object)(object)cardInfo == (Object)null) { return false; } if (HasSpecialStatIconHealth(cardInfo)) { return true; } if (cardInfo.Mods != null) { foreach (CardModificationInfo mod in cardInfo.Mods) { if (mod == null || mod.healthAdjustment <= 0) { continue; } return true; } } return false; } private static bool HasSpecialStatIconAttack(CardInfo cardInfo) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cardInfo == (Object)null) { return false; } List specialTriggeredAbilities = GetSpecialTriggeredAbilities(cardInfo); if (specialTriggeredAbilities == null || specialTriggeredAbilities.Count == 0) { return false; } foreach (FullStatIcon allStatIcon in StatIconManager.AllStatIcons) { if (allStatIcon == null || (Object)(object)allStatIcon.Info == (Object)null || !allStatIcon.Info.appliesToAttack || !specialTriggeredAbilities.Contains(allStatIcon.AbilityId)) { continue; } return true; } return false; } private static bool HasSpecialStatIconHealth(CardInfo cardInfo) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cardInfo == (Object)null) { return false; } List specialTriggeredAbilities = GetSpecialTriggeredAbilities(cardInfo); if (specialTriggeredAbilities == null || specialTriggeredAbilities.Count == 0) { return false; } foreach (FullStatIcon allStatIcon in StatIconManager.AllStatIcons) { if (allStatIcon == null || (Object)(object)allStatIcon.Info == (Object)null || !allStatIcon.Info.appliesToHealth || !specialTriggeredAbilities.Contains(allStatIcon.AbilityId)) { continue; } return true; } return false; } private static List GetSpecialTriggeredAbilities(CardInfo cardInfo) { List list = new List(); if ((Object)(object)cardInfo == (Object)null) { return list; } Type type = ((object)cardInfo).GetType(); while (type != null) { FieldInfo[] fields = type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (!(fieldInfo == null)) { object value; try { value = fieldInfo.GetValue(cardInfo); } catch { continue; } if (value != null) { AddSpecialTriggeredAbilities(value, list); } } } PropertyInfo[] properties = type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); PropertyInfo[] array2 = properties; foreach (PropertyInfo propertyInfo in array2) { if (!(propertyInfo == null) && propertyInfo.CanRead && propertyInfo.GetIndexParameters().Length == 0) { object value2; try { value2 = propertyInfo.GetValue(cardInfo, null); } catch { continue; } if (value2 != null) { AddSpecialTriggeredAbilities(value2, list); } } } type = type.BaseType; } return list.Distinct().ToList(); } private static void AddSpecialTriggeredAbilities(object value, List result) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0026: Invalid comparison between Unknown and I4 //IL_0030: 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_007b: 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_0080: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (value == null) { return; } if (value is SpecialTriggeredAbility val) { if ((int)val > 0) { result.Add(val); } } else { if (!(value is IEnumerable enumerable)) { return; } foreach (object item in enumerable) { if (item is SpecialTriggeredAbility val2 && (int)val2 > 0) { result.Add(val2); } } } } private static void ModifyPureCard(CardInfo cardInfo) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown if ((Object)(object)cardInfo == (Object)null) { return; } if (cardInfo.Mods != null) { foreach (CardModificationInfo mod in cardInfo.Mods) { if (mod == null || !(mod.singletonId == "OLD_SA_PURE_PELT_MOD")) { continue; } return; } } bool flag = HasAttackParameter(cardInfo); bool flag2 = HasHealthParameter(cardInfo); if (!(flag && flag2)) { CardModificationInfo val = new CardModificationInfo(); if (flag) { val.healthAdjustment = 2; } else if (flag2) { val.attackAdjustment = 1; } else if (Random.Range(0, 2) == 0) { val.attackAdjustment = 1; } else { val.healthAdjustment = 2; } string text = cardInfo.DisplayedNameLocalized; if (string.IsNullOrEmpty(text)) { text = ((Object)cardInfo).name; } val.nameReplacement = string.Format(Localization.Translate("Pure {0}"), text); val.singletonId = "OLD_SA_PURE_PELT_MOD"; if (cardInfo.Mods == null) { cardInfo.Mods = new List(); } cardInfo.Mods.Add(val); } } } public class RainbowEmission : CardAppearanceBehaviour { public static Appearance ID; private static AssetBundle rainbowBundle; private static Material rainbowBaseMaterial; private Material originalMaterial; private Material rainbowMaterial; private static string GetBundlePath() { string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); if (string.IsNullOrEmpty(directoryName)) { Debug.LogError((object)"[OLD SA Pelt] Failed to locate DLL directory."); return null; } return Path.Combine(directoryName, "old_sa_rainbow"); } private static bool LoadRainbowBundle() { if ((Object)(object)rainbowBaseMaterial != (Object)null) { return true; } if ((Object)(object)rainbowBundle == (Object)null) { string bundlePath = GetBundlePath(); if (string.IsNullOrEmpty(bundlePath)) { return false; } if (!File.Exists(bundlePath)) { Debug.LogError((object)("[OLD SA Pelt] Rainbow AssetBundle not found: " + bundlePath)); return false; } rainbowBundle = AssetBundle.LoadFromFile(bundlePath); if ((Object)(object)rainbowBundle == (Object)null) { Debug.LogError((object)("[OLD SA Pelt] Failed to load Rainbow AssetBundle: " + bundlePath)); return false; } } rainbowBaseMaterial = rainbowBundle.LoadAsset("assets/rainbowoilfilm_material.mat"); if ((Object)(object)rainbowBaseMaterial == (Object)null) { Debug.LogError((object)"[OLD SA Pelt] RainbowOilFilm_Material not found in AssetBundle."); return false; } return true; } public override void ApplyAppearance() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (!((Object)(object)((CardAppearanceBehaviour)this).Card == (Object)null) && !((Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer == (Object)null) && !((Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer.Material == (Object)null) && LoadRainbowBundle()) { originalMaterial = ((CardAppearanceBehaviour)this).Card.StatsLayer.Material; rainbowMaterial = new Material(rainbowBaseMaterial); ((CardAppearanceBehaviour)this).Card.StatsLayer.Material = rainbowMaterial; } } public override void ManagedUpdate() { if (!((Object)(object)rainbowMaterial == (Object)null)) { } } public override void ResetAppearance() { if ((Object)(object)((CardAppearanceBehaviour)this).Card != (Object)null && (Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer != (Object)null && (Object)(object)originalMaterial != (Object)null) { ((CardAppearanceBehaviour)this).Card.StatsLayer.Material = originalMaterial; } if ((Object)(object)rainbowMaterial != (Object)null) { Object.Destroy((Object)(object)rainbowMaterial); rainbowMaterial = null; } originalMaterial = null; } } public class SacredSilver : CardAppearanceBehaviour { public static Appearance ID; private static AssetBundle sacredSilverBundle; private static Material sacredSilverBaseMaterial; private Material originalMaterial; private Material sacredSilverMaterial; private static string GetBundlePath() { string location = Assembly.GetExecutingAssembly().Location; string directoryName = Path.GetDirectoryName(location); if (string.IsNullOrEmpty(directoryName)) { Debug.LogError((object)"[OLD SA Pelt] Failed to locate DLL directory."); return null; } return Path.Combine(directoryName, "oldsa_sacred_silver"); } private static bool LoadSacredSilverBundle() { if ((Object)(object)sacredSilverBaseMaterial != (Object)null) { return true; } if ((Object)(object)sacredSilverBundle == (Object)null) { string bundlePath = GetBundlePath(); if (string.IsNullOrEmpty(bundlePath)) { return false; } if (!File.Exists(bundlePath)) { Debug.LogError((object)("[OLD SA Pelt] Sacred Silver AssetBundle not found: " + bundlePath)); return false; } sacredSilverBundle = AssetBundle.LoadFromFile(bundlePath); if ((Object)(object)sacredSilverBundle == (Object)null) { Debug.LogError((object)("[OLD SA Pelt] Failed to load Sacred Silver AssetBundle: " + bundlePath)); return false; } } sacredSilverBaseMaterial = sacredSilverBundle.LoadAsset("assets/sacredsilver.mat"); if ((Object)(object)sacredSilverBaseMaterial == (Object)null) { Debug.LogError((object)"[OLD SA Pelt] SacredSilver Material not found in AssetBundle."); return false; } return true; } public override void ApplyAppearance() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (!((Object)(object)((CardAppearanceBehaviour)this).Card == (Object)null) && !((Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer == (Object)null) && !((Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer.Material == (Object)null) && LoadSacredSilverBundle()) { originalMaterial = ((CardAppearanceBehaviour)this).Card.StatsLayer.Material; sacredSilverMaterial = new Material(sacredSilverBaseMaterial); ((CardAppearanceBehaviour)this).Card.StatsLayer.Material = sacredSilverMaterial; } } public override void ManagedUpdate() { if (!((Object)(object)sacredSilverMaterial == (Object)null)) { } } public override void ResetAppearance() { if ((Object)(object)((CardAppearanceBehaviour)this).Card != (Object)null && (Object)(object)((CardAppearanceBehaviour)this).Card.StatsLayer != (Object)null && (Object)(object)originalMaterial != (Object)null) { ((CardAppearanceBehaviour)this).Card.StatsLayer.Material = originalMaterial; } if ((Object)(object)sacredSilverMaterial != (Object)null) { Object.Destroy((Object)(object)sacredSilverMaterial); sacredSilverMaterial = null; } originalMaterial = null; } } }