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 BepInEx;
using BepInEx.Logging;
using BloodHornGodMod.Nodes;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using InscryptionAPI.Items;
using InscryptionAPI.Items.Extensions;
using InscryptionAPI.Nodes;
using InscryptionAPI.Pelts;
using InscryptionAPI.Pelts.Extensions;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BloodHornGodMod
{
internal static class CardDefinitions
{
internal static CardInfo BloodHornPelt;
internal static CardInfo CockroachGod;
internal static CardInfo WolfKing;
internal static CardInfo MoleGod;
internal static void Register()
{
CreatePelt();
CreateGodCards();
RegisterPeltTrade();
LogInfo("四张卡牌注册完成。");
}
private static void CreatePelt()
{
BloodHornPelt = CardManager.New("BloodHornGodMod", "BloodHornPelt", "血角猎皮", 1, 8, "一张泛着暗红光泽的猎皮,指甲划过会留下白痕。\n毛皮商愿为它付出神明的底牌。");
CardExtensions.SetCost(BloodHornPelt, (int?)0, (int?)0, (int?)null, (List<GemType>)null);
CardExtensions.SetTraits(BloodHornPelt, (Trait[])(object)new Trait[1] { (Trait)13 });
CardExtensions.SetCardTemple(BloodHornPelt, (CardTemple)0);
BloodHornPelt.metaCategories.Clear();
SetArt(BloodHornPelt, "BloodHornPelt");
LogInfo("血角猎皮:1/8,仅作为交易货币。");
}
private static void CreateGodCards()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected I4, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected I4, but got Unknown
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected I4, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected I4, but got Unknown
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected I4, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected I4, but got Unknown
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Expected I4, but got Unknown
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected I4, but got Unknown
CockroachGod = CardManager.New("BloodHornGodMod", "CockroachGod", "蟑螂神", 1, 1, "踩死一只,还有一只。它的巢、它的粮、它的不死,缺一不可。");
CardExtensions.SetCost(CockroachGod, (int?)0, (int?)5, (int?)null, (List<GemType>)null);
CardExtensions.AddTribes(CockroachGod, (Tribe[])(object)new Tribe[1] { (Tribe)6 });
CardExtensions.AddAbilities(CockroachGod, (Ability[])(object)new Ability[3]
{
(Ability)(int)SigilDefinitions.FertileBrood,
(Ability)(int)SigilDefinitions.UndyingBug,
(Ability)(int)SigilDefinitions.Ghoul
});
MarkGodCard(CockroachGod, 1);
SetArt(CockroachGod, "CockroachGod");
LogInfo("蟑螂神:1/1,骨币 5,丰产之巢/不死之虫/食尸鬼。");
WolfKing = CardManager.New("BloodHornGodMod", "WolfKing", "狼王", 1, 3, "万狼之王。统领群狼,筑坝守疆,生生不息。");
CardExtensions.SetCost(WolfKing, (int?)4, (int?)0, (int?)null, (List<GemType>)null);
CardExtensions.AddTribes(WolfKing, (Tribe[])(object)new Tribe[1] { (Tribe)3 });
CardInfo wolfKing = WolfKing;
Ability[] array = new Ability[6];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array[0] = (Ability)(int)SigilDefinitions.FertileBrood;
array[1] = (Ability)(int)SigilDefinitions.UndyingBug;
array[5] = (Ability)(int)SigilDefinitions.EndlessLife;
CardExtensions.AddAbilities(wolfKing, (Ability[])(object)array);
MarkGodCard(WolfKing, 2);
SetArt(WolfKing, "WolfKing");
LogInfo("狼王:1/3,鲜血 4,六印记。");
MoleGod = CardManager.New("BloodHornGodMod", "MoleGod", "鼹鼠神", 0, 10, "大地之盾。以血肉筑起不可逾越的防线。");
CardExtensions.SetCost(MoleGod, (int?)4, (int?)0, (int?)null, (List<GemType>)null);
CardExtensions.AddTribes(MoleGod, (Tribe[])(object)new Tribe[1] { (Tribe)4 });
CardInfo moleGod = MoleGod;
Ability[] array2 = new Ability[5];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
array2[1] = (Ability)(int)SigilDefinitions.FertileBrood;
array2[2] = (Ability)(int)SigilDefinitions.UndyingBug;
CardExtensions.AddAbilities(moleGod, (Ability[])(object)array2);
MarkGodCard(MoleGod, 3);
SetArt(MoleGod, "MoleGod");
LogInfo("鼹鼠神:0/10,鲜血 4,高跳/丰产之巢/不死之虫/尖刺铠甲/死神之触。");
}
private static void MarkGodCard(CardInfo card, int tier)
{
card.metaCategories.Clear();
CardExtensions.SetOnePerDeck(card, true);
CardExtensions.SetExtendedProperty(card, "TradeOnly", (object)"BloodHornPelt");
CardExtensions.SetExtendedProperty(card, "IsGodCard", (object)"true");
CardExtensions.SetExtendedProperty(card, "GodTier", (object)tier.ToString());
}
private static void RegisterPeltTrade()
{
PeltData val = PeltManager.New("com.inscryptionmod.bloodhorngod", BloodHornPelt, (Func<List<CardInfo>>)GetGodChoices, 5, 0, 3);
PeltExtensions.SetTierName(val, "BloodHornPelt");
LogInfo("血角猎皮已注册为交易货币(可兑换 3 张神卡)。");
}
private static List<CardInfo> GetGodChoices()
{
return new List<CardInfo> { CockroachGod, WolfKing, MoleGod };
}
private static void SetArt(CardInfo card, string artKey)
{
Texture2D val = LoadTexture(artKey + ".png");
if ((Object)(object)val != (Object)null)
{
CardExtensions.SetPortrait(card, val, (FilterMode?)null);
}
Texture2D val2 = LoadTexture(artKey + "_pixel.png");
if ((Object)(object)val2 != (Object)null)
{
CardExtensions.SetPixelPortrait(card, val2, (FilterMode?)null);
}
}
internal static Texture2D LoadTexture(string fileName)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
try
{
string directoryName = Path.GetDirectoryName(typeof(CardDefinitions).Assembly.Location);
string path = Path.Combine(directoryName, "art", fileName);
if (!File.Exists(path))
{
LogWarning("找不到美术文件 " + fileName);
return null;
}
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val, File.ReadAllBytes(path));
((Texture)val).filterMode = (FilterMode)1;
((Object)val).name = Path.GetFileNameWithoutExtension(fileName);
return val;
}
catch (Exception ex)
{
LogWarning("读取美术 " + fileName + " 失败: " + ex.Message);
return null;
}
}
private static void LogInfo(string message)
{
Plugin.LogInfo(message);
}
private static void LogWarning(string message)
{
Plugin.LogWarning(message);
}
}
public class MirrorShardItem : ConsumableItem
{
internal static ConsumableItemData ShardData;
internal static void Register()
{
Texture2D val = CardDefinitions.LoadTexture("MemoryMirror_icon.png");
ShardData = ConsumableItemManager.New("com.inscryptionmod.bloodhorngod", "镜之碎片", "一块从记忆之镜上剥落的碎片。\n点击一张己方生物,再点击另一张:\n后者会获得前者的全部印记。", val, typeof(MirrorShardItem), (ModelType)1);
ConsumableItemDataExtensions.SetNotRandomlyGiven(ShardData, true);
ConsumableItemDataExtensions.SetAct1(ShardData);
Plugin.LogInfo("镜之碎片物品注册完成。");
}
internal static void GrantToPlayer()
{
if (!((Object)(object)ShardData == (Object)null) && RunState.Run != null)
{
if (RunState.Run.consumables.Count >= RunState.Run.MaxConsumables)
{
Plugin.LogInfo("物品栏已满,镜之碎片碎裂了。");
return;
}
RunState.Run.consumables.Add(((Object)ShardData).name);
Plugin.LogInfo("获得物品:镜之碎片。");
}
}
public override IEnumerator ActivateSequence()
{
((Item)this).PlayExitAnimation();
yield return (object)new WaitForSeconds(0.15f);
Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)0;
yield return (object)new WaitForSeconds(0.2f);
CardInfo source = null;
CardInfo target = null;
((MonoBehaviour)Singleton<TextDisplayer>.Instance).StartCoroutine(Singleton<TextDisplayer>.Instance.ShowThenClear("镜之碎片:点击一张己方生物,借走它的印记。\n(右键取消)", 3f, 0f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null));
yield return WaitForCard(null, delegate(CardInfo c)
{
source = c;
});
if ((Object)(object)source == (Object)null)
{
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("你把碎片收了回去。", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
yield break;
}
((MonoBehaviour)Singleton<TextDisplayer>.Instance).StartCoroutine(Singleton<TextDisplayer>.Instance.ShowThenClear("再点击另一张己方生物接收印记。\n(右键取消)", 3f, 0f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null));
yield return WaitForCard((CardInfo c) => ((Object)c).name != ((Object)source).name, delegate(CardInfo c)
{
target = c;
});
if ((Object)(object)target == (Object)null)
{
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("碎片里只留下一个人的影子。", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
yield break;
}
CardModificationInfo mod = new CardModificationInfo();
mod.abilities = new List<Ability>();
foreach (Ability ability in source.Abilities)
{
if (!target.Abilities.Contains(ability))
{
mod.abilities.Add(ability);
}
}
if (mod.abilities.Count > 0)
{
RunState.Run.playerDeck.ModifyCard(target, mod);
SaveManager.SaveToFile(true);
Plugin.LogInfo("镜之碎片:" + target.DisplayedNameLocalized + " 获得 " + mod.abilities.Count + " 个印记。");
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput(target.DisplayedNameLocalized + " 接住了 " + source.DisplayedNameLocalized + " 的印记。", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
}
else
{
yield return Singleton<TextDisplayer>.Instance.ShowUntilInput("两张生物早已共享同样的印记。", -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
}
}
private IEnumerator WaitForCard(Predicate<CardInfo> filter, Action<CardInfo> onPicked)
{
while (!Input.GetMouseButtonDown(1))
{
if (Input.GetMouseButtonDown(0))
{
PlayableCard card = ClickedFriendlyCard();
if ((Object)(object)card != (Object)null && (Object)(object)((Card)card).Info != (Object)null && (filter?.Invoke(((Card)card).Info) ?? true))
{
onPicked(((Card)card).Info);
Singleton<ViewManager>.Instance.Controller.LockState = (ViewLockState)1;
yield break;
}
}
yield return null;
}
onPicked(null);
}
private static PlayableCard ClickedFriendlyCard()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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)
try
{
if ((Object)(object)Camera.main == (Object)null)
{
return null;
}
Ray val = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, 100f))
{
PlayableCard componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<PlayableCard>();
if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.Slot != (Object)null && componentInParent.Slot.IsPlayerSlot)
{
return componentInParent;
}
}
}
catch (Exception)
{
}
return null;
}
}
internal static class ModState
{
internal static readonly HashSet<string> UsedNodes = new HashSet<string>();
internal static int SquirrelsRemoved = 0;
internal static CardInfo PendingEcho = null;
internal static bool EchoSpawned = false;
internal static bool HeartGuardPending = false;
internal static int HeartGuardBattlesLeft = 0;
internal static CardInfo HeartGuardCard = null;
internal static readonly FieldInfo DisplayedNameField = AccessTools.Field(typeof(CardInfo), "displayedName");
internal static readonly FieldInfo DisplayedNameLocIdField = AccessTools.Field(typeof(CardInfo), "displayedNameLocId");
internal static readonly FieldInfo BaseAttackField = AccessTools.Field(typeof(CardInfo), "baseAttack");
internal static readonly FieldInfo BaseHealthField = AccessTools.Field(typeof(CardInfo), "baseHealth");
internal static readonly FieldInfo AbilitiesField = AccessTools.Field(typeof(CardInfo), "abilities");
internal static void ResetRun()
{
UsedNodes.Clear();
SquirrelsRemoved = 0;
PendingEcho = null;
EchoSpawned = false;
HeartGuardPending = false;
HeartGuardBattlesLeft = 0;
HeartGuardCard = null;
Plugin.LogInfo("新一局:节点与镜之状态已重置。");
}
internal static void MarkNodeUsed(string key)
{
UsedNodes.Add(key);
}
internal static bool IsCorrupted(CardInfo card)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)card == (Object)null)
{
return false;
}
return card.SpecialAbilities.Contains(SigilDefinitions.Corrupted);
}
internal static bool RemoveFromDeck(CardInfo info)
{
if ((Object)(object)info == (Object)null || RunState.Run == null || RunState.Run.playerDeck == null)
{
return false;
}
DeckInfo playerDeck = RunState.Run.playerDeck;
if (((CardCollectionInfo)playerDeck).Cards.Contains(info))
{
((CardCollectionInfo)playerDeck).RemoveCard(info);
return true;
}
CardInfo val = ((IEnumerable<CardInfo>)((CardCollectionInfo)playerDeck).Cards).FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => (Object)(object)c != (Object)null && ((Object)c).name == ((Object)info).name));
if ((Object)(object)val != (Object)null)
{
((CardCollectionInfo)playerDeck).RemoveCard(val);
return true;
}
return false;
}
internal static List<CardInfo> DeckVessels()
{
List<CardInfo> list = new List<CardInfo>();
if (RunState.Run == null || RunState.Run.playerDeck == null)
{
return list;
}
HashSet<string> hashSet = new HashSet<string>();
foreach (CardInfo card in ((CardCollectionInfo)RunState.Run.playerDeck).Cards)
{
if (!((Object)(object)card == (Object)null) && (card.traits == null || (!card.traits.Contains((Trait)13) && !card.traits.Contains((Trait)12))) && ((Object)card).name.IndexOf("Pelt", StringComparison.OrdinalIgnoreCase) < 0 && hashSet.Add(((Object)card).name))
{
list.Add(card);
}
}
return list;
}
internal static int DistinctVesselCount()
{
return DeckVessels().Count;
}
internal static CardInfo TokenCard()
{
CardInfo val = FindCard("Squirrel", "GreySquirrel", "Rabbit");
if ((Object)(object)val != (Object)null)
{
return val;
}
if (RunState.Run != null && RunState.Run.playerDeck != null && ((CardCollectionInfo)RunState.Run.playerDeck).Cards.Count > 0)
{
return ((CardCollectionInfo)RunState.Run.playerDeck).Cards[0];
}
return null;
}
internal static CardInfo FindCard(params string[] names)
{
foreach (string text in names)
{
try
{
CardInfo cardByName = CardLoader.GetCardByName(text);
if ((Object)(object)cardByName != (Object)null)
{
return cardByName;
}
}
catch (Exception)
{
}
}
return null;
}
internal static CardInfo CloneCard(CardInfo source)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)source == (Object)null)
{
return null;
}
return (CardInfo)source.Clone();
}
internal static CardInfo Label(CardInfo card, string title, string description)
{
if ((Object)(object)card == (Object)null)
{
return null;
}
DisplayedNameField.SetValue(card, title);
if (DisplayedNameLocIdField != null)
{
DisplayedNameLocIdField.SetValue(card, string.Empty);
}
card.description = description;
return card;
}
internal unsafe static string Describe(CardInfo card)
{
if ((Object)(object)card == (Object)null)
{
return "null";
}
return string.Format("{0} {1}/{2} [{3}]", card.DisplayedNameLocalized, card.Attack, card.Health, string.Join(",", card.Abilities.Select((Ability a) => ((object)(*(Ability*)(&a))/*cast due to .constrained prefix*/).ToString()).ToArray()));
}
internal static string FormatAbilities(CardInfo card)
{
if ((Object)(object)card == (Object)null)
{
return "无";
}
List<Ability> abilities = card.Abilities;
if (abilities.Count == 0)
{
return "无";
}
return string.Join("、", abilities.Select((Ability a) => AbilitiesUtil.GetInfo(a).rulebookName).ToArray());
}
internal static List<Ability> GetBaseAbilities(CardInfo card)
{
object value = AbilitiesField.GetValue(card);
if (value is List<Ability>)
{
return (List<Ability>)value;
}
return new List<Ability>();
}
internal static void SetBaseAbilities(CardInfo card, List<Ability> list)
{
AbilitiesField.SetValue(card, list);
}
internal static void StripStatAndAbilityMods(CardInfo card)
{
foreach (CardModificationInfo mod in card.Mods)
{
mod.attackAdjustment = 0;
mod.healthAdjustment = 0;
if (mod.abilities != null)
{
mod.abilities.Clear();
}
if (mod.negateAbilities != null)
{
mod.negateAbilities.Clear();
}
}
}
internal static void SwapEverything(CardInfo a, CardInfo b)
{
int attack = a.Attack;
int health = a.Health;
int attack2 = b.Attack;
int health2 = b.Health;
List<Ability> list = new List<Ability>(a.Abilities);
List<Ability> list2 = new List<Ability>(b.Abilities);
StripStatAndAbilityMods(a);
StripStatAndAbilityMods(b);
BaseAttackField.SetValue(a, attack2);
BaseHealthField.SetValue(a, health2);
BaseAttackField.SetValue(b, attack);
BaseHealthField.SetValue(b, health);
SetBaseAbilities(a, list2);
SetBaseAbilities(b, list);
}
internal static void SetPendingEcho(CardInfo source)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
if ((Object)(object)source == (Object)null)
{
PendingEcho = null;
return;
}
CardInfo val = (CardInfo)source.Clone();
int value = Mathf.Max(1, source.Attack / 2);
int value2 = Mathf.Max(1, source.Health / 2);
CardExtensions.SetBaseAttackAndHealth(val, (int?)value, (int?)value2);
CardExtensions.SetCost(val, (int?)0, (int?)0, (int?)null, (List<GemType>)null);
PendingEcho = val;
Plugin.LogInfo("镜中回响登记:" + source.DisplayedNameLocalized + "(弱化 " + value + "/" + value2 + ")");
}
internal static void GrantHeartGuard()
{
HeartGuardPending = true;
HeartGuardBattlesLeft = 1;
HeartGuardCard = null;
Plugin.LogInfo("【心防】已登记:下一场战斗第一张被击杀的己方卡受到保护。");
}
internal static void AfterBattleStarted()
{
EchoSpawned = false;
HeartGuardCard = null;
if (HeartGuardPending)
{
if (HeartGuardBattlesLeft > 0)
{
HeartGuardBattlesLeft--;
}
else
{
HeartGuardPending = false;
}
}
}
internal static string RandomMirrorCostName(int index)
{
return index switch
{
0 => "褪色记忆",
1 => "镜中回响",
_ => "记忆损耗",
};
}
}
internal class RunOnceCondition : SelectionCondition
{
private readonly string key;
private readonly Func<bool> extraCheck;
internal RunOnceCondition(string key, Func<bool> extraCheck = null)
{
this.key = key;
this.extraCheck = extraCheck;
}
public override bool Satisfied(int gridY, List<NodeData> previousNodes)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
if (ModState.UsedNodes.Contains(key))
{
return false;
}
if (previousNodes != null)
{
foreach (NodeData previousNode in previousNodes)
{
if (previousNode is CustomSpecialNodeData)
{
CustomSpecialNodeData val = (CustomSpecialNodeData)previousNode;
if (val.name == key)
{
return false;
}
}
}
}
if (extraCheck == null)
{
return true;
}
try
{
return extraCheck();
}
catch (Exception)
{
return false;
}
}
}
[BepInPlugin("com.inscryptionmod.bloodhorngod", "BloodHornGodMod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "com.inscryptionmod.bloodhorngod";
public const string MOD_NAME = "BloodHornGodMod";
public const string VERSION = "1.1.0";
internal const string CARD_PREFIX = "BloodHornGodMod";
internal static Plugin Instance;
internal static ManualLogSource Logger;
internal static Harmony HarmonyInstance;
internal static void LogInfo(string message)
{
if (Logger != null)
{
Logger.LogInfo((object)("[BloodHornGodMod] " + message));
}
}
internal static void LogWarning(string message)
{
if (Logger != null)
{
Logger.LogWarning((object)("[BloodHornGodMod] " + message));
}
}
private void Awake()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
LogInfo("v1.1.0 正在加载...");
SigilDefinitions.Register();
CardDefinitions.Register();
MirrorShardItem.Register();
NodeDefinitions.Register();
HarmonyInstance = new Harmony("com.inscryptionmod.bloodhorngod");
HarmonyInstance.PatchAll(Assembly.GetExecutingAssembly());
LogInfo("加载完成!");
}
private void OnDestroy()
{
if (HarmonyInstance != null)
{
HarmonyInstance.UnpatchSelf();
}
}
}
internal static class SigilDefinitions
{
internal static Ability FertileBrood;
internal static Ability Ghoul;
internal static Ability UndyingBug;
internal static Ability EndlessLife;
internal static Ability Fragile;
internal static Ability TalkingStoat;
internal static Ability TalkingStinkbug;
internal static Ability TalkingWolf;
internal static SpecialTriggeredAbility Corrupted;
internal static void Register()
{
//IL_0020: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Expected I4, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected I4, but got Unknown
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Expected I4, but got Unknown
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Expected I4, but got Unknown
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Expected I4, but got Unknown
FertileBrood = Add("FertileBrood", "丰产之巢", "入场时:在一个空位生成一只蟑螂。", typeof(FertileBroodAbility), "Sigil_FertileBrood.png", 2);
Ghoul = Add("Ghoul", "食尸鬼", "每当有敌方生物死去:这只生物恢复 1 点生命。", typeof(GhoulAbility), "Sigil_Ghoul.png", 2);
UndyingBug = Add("UndyingBug", "不死之虫", "死去时(非献祭):在原位复活一次,复活后的它不再有本印记。", typeof(UndyingBugAbility), "Sigil_UndyingBug.png", 3);
EndlessLife = Add("EndlessLife", "生生不息", "死去时(非献祭):在原地留下一个不含本印记的复制体。", typeof(EndlessLifeAbility), "Sigil_UndyingBug.png", 3);
Fragile = Add("Fragile", "褪色记忆", "死去时(非献祭):这张牌会从卡组中永久消失。亡语仍会触发。", typeof(FragileBehaviour), "Sigil_Ghoul.png", 1);
TalkingStoat = Add("TalkingStoat", "说书人的礼物", "入场时:获得两张「空容器」,各带一个随机印记。", typeof(TalkingStoatAbility), "Sigil_FertileBrood.png", 1);
TalkingStinkbug = Add("TalkingStinkbug", "虫语者的礼物", "入场时:获得两张骷髅。", typeof(TalkingStinkbugAbility), "Sigil_FertileBrood.png", 1);
TalkingWolf = Add("TalkingWolf", "猎手的礼物", "入场时:抽两张牌。", typeof(TalkingWolfAbility), "Sigil_FertileBrood.png", 1);
Corrupted = SpecialTriggeredAbilityManager.Add("com.inscryptionmod.bloodhorngod", "CorruptedData", typeof(CorruptedMarkerBehaviour)).Id;
Plugin.LogInfo("印记注册完成:" + (int)FertileBrood + "/" + (int)Ghoul + "/" + (int)UndyingBug + "/" + (int)EndlessLife + "/" + (int)Fragile);
}
private static Ability Add(string key, string displayName, string description, Type behaviour, string iconFile, int power)
{
//IL_004e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = CardDefinitions.LoadTexture(iconFile);
Texture2D val2 = CardDefinitions.LoadTexture("Sigil_UndyingBug.png");
AbilityInfo val3 = AbilityManager.New("com.inscryptionmod.bloodhorngod", key, description, behaviour, (Texture)(object)(((Object)(object)val != (Object)null) ? val : val2));
AbilityExtensions.AddMetaCategories(val3, (AbilityMetaCategory[])(object)new AbilityMetaCategory[1]);
AbilityExtensions.SetRulebookName(val3, displayName);
AbilityExtensions.SetPowerlevel(val3, power);
return val3.ability;
}
internal static CardInfo BroodToken()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
CardInfo val = null;
try
{
val = CardLoader.GetCardByName("Cockroach");
}
catch (Exception)
{
}
if ((Object)(object)val != (Object)null)
{
return val;
}
val = (CardInfo)CardDefinitions.CockroachGod.Clone();
((Object)val).name = "BloodHornBrood";
CardExtensions.SetCost(val, (int?)0, (int?)1, (int?)null, (List<GemType>)null);
ModState.SetBaseAbilities(val, new List<Ability>());
ModState.DisplayedNameField.SetValue(val, "蟑螂");
ModState.DisplayedNameLocIdField.SetValue(val, string.Empty);
val.description = "从巢穴里钻出来的普通蟑螂。";
return val;
}
}
internal class CorruptedMarkerBehaviour : SpecialCardBehaviour
{
}
internal class FertileBroodAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.FertileBrood;
public override bool RespondsToResolveOnBoard()
{
return (Object)(object)((AbilityBehaviour)this).Card != (Object)null && (Object)(object)((AbilityBehaviour)this).Card.Slot != (Object)null && (Object)(object)FindSlot() != (Object)null;
}
public override IEnumerator OnResolveOnBoard()
{
yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
CardSlot slot = FindSlot();
if (!((Object)(object)slot == (Object)null))
{
CardInfo token = SigilDefinitions.BroodToken();
if (!((Object)(object)token == (Object)null))
{
yield return (object)new WaitForSeconds(0.2f);
yield return Singleton<BoardManager>.Instance.CreateCardInSlot(token, slot, 0.45f, false);
}
}
}
private CardSlot FindSlot()
{
//IL_009e: 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)
if ((Object)(object)((AbilityBehaviour)this).Card == (Object)null || (Object)(object)((AbilityBehaviour)this).Card.Slot == (Object)null)
{
return null;
}
List<CardSlot> list = (((AbilityBehaviour)this).Card.Slot.IsPlayerSlot ? Singleton<BoardManager>.Instance.PlayerSlotsCopy : Singleton<BoardManager>.Instance.OpponentSlotsCopy);
CardSlot result = null;
float num = float.MaxValue;
foreach (CardSlot item in list)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)item.Card != (Object)null))
{
float num2 = Mathf.Abs(((Component)item).transform.position.x - ((Component)((AbilityBehaviour)this).Card.Slot).transform.position.x);
if (num2 < num)
{
num = num2;
result = item;
}
}
}
return result;
}
}
internal class GhoulAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.Ghoul;
public override bool RespondsToOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
{
return (Object)(object)card != (Object)null && card.OpponentCard && (Object)(object)((AbilityBehaviour)this).Card != (Object)null && !((AbilityBehaviour)this).Card.Dead && ((AbilityBehaviour)this).Card.Health < ((AbilityBehaviour)this).Card.MaxHealth;
}
public override IEnumerator OnOtherCardDie(PlayableCard card, CardSlot deathSlot, bool fromCombat, PlayableCard killer)
{
yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
yield return (object)new WaitForSeconds(0.2f);
int heal = Mathf.Min(1, ((AbilityBehaviour)this).Card.MaxHealth - ((AbilityBehaviour)this).Card.Health);
if (heal > 0)
{
((AbilityBehaviour)this).Card.HealDamage(heal);
((Card)((AbilityBehaviour)this).Card).RenderCard();
}
}
}
internal class UndyingBugAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.UndyingBug;
public override bool RespondsToDie(bool wasSacrifice, PlayableCard killer)
{
return !wasSacrifice && (Object)(object)((AbilityBehaviour)this).Card != (Object)null && (Object)(object)((AbilityBehaviour)this).Card.Slot != (Object)null;
}
public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer)
{
CardSlot slot = ((AbilityBehaviour)this).Card.Slot;
CardInfo revived = (CardInfo)((Card)((AbilityBehaviour)this).Card).Info.Clone();
List<Ability> abilities = new List<Ability>(ModState.GetBaseAbilities(revived));
abilities.Remove(SigilDefinitions.UndyingBug);
ModState.SetBaseAbilities(revived, abilities);
ModState.DisplayedNameField.SetValue(revived, ((Card)((AbilityBehaviour)this).Card).Info.DisplayedNameLocalized + "(残躯)");
ModState.DisplayedNameLocIdField.SetValue(revived, string.Empty);
revived.description = "从巢穴里爬回来的那一只,已经不会再爬第二次了。";
if ((Object)(object)slot != (Object)null)
{
((MonoBehaviour)Singleton<BoardManager>.Instance).StartCoroutine(ReviveLater(slot, revived));
}
yield break;
}
private IEnumerator ReviveLater(CardSlot slot, CardInfo revived)
{
yield return (object)new WaitForSeconds(1f);
if (!((Object)(object)slot == (Object)null) && (!((Object)(object)slot.Card != (Object)null) || slot.Card.Dead))
{
yield return Singleton<BoardManager>.Instance.CreateCardInSlot(revived, slot, 0.6f, false);
}
}
}
internal class EndlessLifeAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.EndlessLife;
public override bool RespondsToDie(bool wasSacrifice, PlayableCard killer)
{
return !wasSacrifice && (Object)(object)((AbilityBehaviour)this).Card != (Object)null && (Object)(object)((AbilityBehaviour)this).Card.Slot != (Object)null;
}
public override IEnumerator OnDie(bool wasSacrifice, PlayableCard killer)
{
CardSlot slot = ((AbilityBehaviour)this).Card.Slot;
CardInfo copy = (CardInfo)((Card)((AbilityBehaviour)this).Card).Info.Clone();
List<Ability> abilities = new List<Ability>(ModState.GetBaseAbilities(copy));
abilities.Remove(SigilDefinitions.EndlessLife);
ModState.SetBaseAbilities(copy, abilities);
ModState.DisplayedNameField.SetValue(copy, ((Card)((AbilityBehaviour)this).Card).Info.DisplayedNameLocalized + "(余烬)");
ModState.DisplayedNameLocIdField.SetValue(copy, string.Empty);
copy.description = "生生不息留下的余烬。它不会再留下第二个自己。";
if ((Object)(object)slot != (Object)null)
{
((MonoBehaviour)Singleton<BoardManager>.Instance).StartCoroutine(SpawnLater(slot, copy));
}
yield break;
}
private IEnumerator SpawnLater(CardSlot slot, CardInfo copy)
{
yield return (object)new WaitForSeconds(1f);
if (!((Object)(object)slot == (Object)null) && (!((Object)(object)slot.Card != (Object)null) || slot.Card.Dead))
{
yield return Singleton<BoardManager>.Instance.CreateCardInSlot(copy, slot, 0.6f, false);
}
}
}
internal class FragileBehaviour : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.Fragile;
}
internal class TalkingStoatAbility : AbilityBehaviour
{
private static readonly Ability[] VESSEL_SIGILS;
public override Ability Ability => SigilDefinitions.TalkingStoat;
public override bool RespondsToResolveOnBoard()
{
return (Object)(object)Singleton<CardSpawner>.Instance != (Object)null;
}
public override IEnumerator OnResolveOnBoard()
{
yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
List<Ability> picks = new List<Ability>(VESSEL_SIGILS);
for (int i = 0; i < 2; i++)
{
if (picks.Count <= 0)
{
break;
}
Ability sigil = picks[Random.Range(0, picks.Count)];
picks.Remove(sigil);
CardInfo vessel = MakeVessel(sigil);
if ((Object)(object)vessel != (Object)null)
{
yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(vessel, 0.25f);
}
}
}
private static CardInfo MakeVessel(Ability sigil)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
CardInfo val = ModState.TokenCard();
if ((Object)(object)val == (Object)null)
{
return null;
}
CardInfo val2 = (CardInfo)val.Clone();
ModState.Label(val2, "空容器", "一只空空的容器,里面装着一个印记。");
CardExtensions.SetBaseAttackAndHealth(val2, (int?)0, (int?)1);
CardExtensions.SetCost(val2, (int?)0, (int?)0, (int?)null, (List<GemType>)null);
ModState.SetBaseAbilities(val2, new List<Ability> { sigil });
return val2;
}
static TalkingStoatAbility()
{
Ability[] array = new Ability[4];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
VESSEL_SIGILS = (Ability[])(object)array;
}
}
internal class TalkingStinkbugAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.TalkingStinkbug;
public override bool RespondsToResolveOnBoard()
{
return (Object)(object)Singleton<CardSpawner>.Instance != (Object)null;
}
public override IEnumerator OnResolveOnBoard()
{
yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
for (int i = 0; i < 2; i++)
{
CardInfo skeleton = ModState.FindCard("Skeleton");
if ((Object)(object)skeleton == (Object)null)
{
break;
}
yield return Singleton<CardSpawner>.Instance.SpawnCardToHand(skeleton, 0.25f);
}
}
}
internal class TalkingWolfAbility : AbilityBehaviour
{
public override Ability Ability => SigilDefinitions.TalkingWolf;
public override bool RespondsToResolveOnBoard()
{
return (Object)(object)Singleton<CardDrawPiles>.Instance != (Object)null;
}
public override IEnumerator OnResolveOnBoard()
{
yield return ((AbilityBehaviour)this).PreSuccessfulTriggerSequence();
yield return Singleton<CardDrawPiles>.Instance.DrawCardFromDeck((CardInfo)null, (Action<PlayableCard>)null);
yield return Singleton<CardDrawPiles>.Instance.DrawCardFromDeck((CardInfo)null, (Action<PlayableCard>)null);
}
}
}
namespace BloodHornGodMod.Patches
{
[HarmonyPatch(typeof(RunState), "Initialize")]
internal static class RunResetPatch
{
private static void Postfix()
{
ModState.ResetRun();
}
}
[HarmonyPatch(typeof(TurnManager), "StartGame", new Type[] { typeof(EncounterData) })]
internal static class BattleStartPatch
{
private static void Postfix()
{
ModState.AfterBattleStarted();
}
}
[HarmonyPatch(typeof(TurnManager), "PlayerTurn")]
internal static class EchoSpawnPatch
{
private static void Prefix(TurnManager __instance)
{
if (!((Object)(object)ModState.PendingEcho == (Object)null) && !ModState.EchoSpawned && !((Object)(object)__instance == (Object)null) && __instance.TurnNumber <= 1)
{
ModState.EchoSpawned = true;
((MonoBehaviour)Singleton<BoardManager>.Instance).StartCoroutine(SpawnEcho());
}
}
private static IEnumerator SpawnEcho()
{
yield return (object)new WaitForSeconds(1.2f);
CardInfo echo = ModState.PendingEcho;
try
{
CardSlot slot = null;
foreach (CardSlot candidate in Singleton<BoardManager>.Instance.OpponentSlotsCopy)
{
if ((Object)(object)candidate != (Object)null && (Object)(object)candidate.Card == (Object)null)
{
slot = candidate;
break;
}
}
if ((Object)(object)echo != (Object)null && (Object)(object)slot != (Object)null)
{
yield return Singleton<BoardManager>.Instance.CreateCardInSlot(echo, slot, 0.5f, true);
Plugin.LogInfo("镜中回响:敌方召唤了弱化版 " + echo.DisplayedNameLocalized + "。");
}
}
finally
{
ModState.PendingEcho = null;
}
}
}
[HarmonyPatch(typeof(PlayableCard), "Die")]
internal static class DeathEffectsPatch
{
private static void Prefix(PlayableCard __instance, bool wasSacrifice)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Card)__instance).Info == (Object)null))
{
if (ModState.HeartGuardPending && (Object)(object)__instance.Slot != (Object)null && __instance.Slot.IsPlayerSlot)
{
ModState.HeartGuardPending = false;
ModState.HeartGuardCard = ((Card)__instance).Info;
Plugin.LogInfo("【心防】生效:第一张被击杀的己方卡受到保护。");
}
if (!wasSacrifice && !((Object)(object)__instance.Slot == (Object)null) && __instance.Slot.IsPlayerSlot && __instance.HasAbility(SigilDefinitions.Fragile) && ModState.RemoveFromDeck(((Card)__instance).Info))
{
Plugin.LogInfo("【褪色记忆】" + ((Card)__instance).Info.DisplayedNameLocalized + " 从卡组中永久消失。");
SaveManager.SaveToFile(true);
}
}
}
}
[HarmonyPatch(typeof(BoardManager), "CreateCardInSlot")]
internal static class HeartGuardCopyBlockPatch
{
private static bool Prefix(CardInfo info, CardSlot slot)
{
if ((Object)(object)ModState.HeartGuardCard == (Object)null || (Object)(object)slot == (Object)null || slot.IsPlayerSlot)
{
return true;
}
if ((Object)(object)info == (Object)null || ((Object)info).name != ((Object)ModState.HeartGuardCard).name)
{
return true;
}
Plugin.LogInfo("【心防】拦截了敌方复制被保护卡:" + info.DisplayedNameLocalized + "。");
return false;
}
}
[HarmonyPatch(typeof(PlayableCard), "HasAbility")]
internal static class AbilitySuppressionPatch
{
private static bool Prefix(PlayableCard __instance, Ability ability, ref bool __result)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_002e: 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_0056: Invalid comparison between Unknown and I4
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Invalid comparison between Unknown and I4
if ((Object)(object)__instance == (Object)null || (Object)(object)((Card)__instance).Info == (Object)null)
{
return true;
}
CardInfo info = ((Card)__instance).Info;
if ((int)ability == 14 && info.HasAbility(SigilDefinitions.Fragile))
{
__result = false;
return false;
}
if (ModState.IsCorrupted(info) && ((int)ability == 4 || (int)ability == 13 || (int)ability == 19 || (int)ability == 53))
{
__result = false;
return false;
}
return true;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class CorruptedAttackPatch
{
private static void Postfix(PlayableCard __instance, ref int __result)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Card)__instance).Info == (Object)null) && ModState.IsCorrupted(((Card)__instance).Info))
{
if (__instance.HasAbility((Ability)100))
{
__result *= 2;
}
else if (__instance.HasAbility((Ability)25))
{
__result *= 3;
}
}
}
}
[HarmonyPatch(typeof(Part1CardDrawPiles), "get_SideDeckData")]
internal static class SquirrelSideDeckPatch
{
private static void Postfix(ref List<CardInfo> __result)
{
int num = ModState.SquirrelsRemoved;
if (num <= 0 || __result == null)
{
return;
}
int num2 = __result.Count - 1;
while (num2 >= 0 && num > 0)
{
CardInfo val = __result[num2];
if (!((Object)(object)val == (Object)null))
{
bool flag = ((Object)val).name.IndexOf("Squirrel", StringComparison.OrdinalIgnoreCase) >= 0;
if (!flag && val.tribes != null)
{
flag = val.tribes.Contains((Tribe)1);
}
if (flag)
{
__result.RemoveAt(num2);
num--;
}
}
num2--;
}
}
}
}
namespace BloodHornGodMod.Nodes
{
internal abstract class BloodHornChoiceSequencer : CustomCardChoiceNodeSequencer
{
private const int PER_ROW = 3;
private const float X_SPACING = 1.5f;
private const float Z_SPACING = 2f;
private const float LAYOUT_HEIGHT = 5.01f;
protected CardInfo picked;
protected abstract string TagName { get; }
protected void OpenAltar()
{
Singleton<ViewManager>.Instance.SwitchToView((View)3, false, true);
Singleton<TableRuleBook>.Instance.SetOnBoard(true);
}
protected IEnumerator ChooseFrom(List<CardInfo> options)
{
options.RemoveAll((CardInfo o) => (Object)(object)o == (Object)null);
picked = null;
if (options.Count == 0)
{
yield break;
}
int rowCount = Mathf.CeilToInt((float)options.Count / 3f);
Log("铺开 " + options.Count + " 张 → " + rowCount + " 行");
((CardChoicesSequencer)this).selectableCards = new List<SelectableCard>();
for (int i = 0; i < options.Count; i++)
{
CardInfo info = options[i];
int row = i / 3;
int col = i % 3;
int rowSize = Mathf.Min(3, options.Count - row * 3);
Vector3 pos = new Vector3(((float)col - (float)(rowSize - 1) * 0.5f) * 1.5f, 5.01f, ((float)(rowCount - 1) * 0.5f - (float)row) * 2f);
((CardChoicesSequencer)this).selectableCards.AddRange(((CardChoicesSequencer)this).SpawnCards(1, ((Component)this).transform, pos, 1.5f));
SelectableCard card = ((CardChoicesSequencer)this).selectableCards[((CardChoicesSequencer)this).selectableCards.Count - 1];
((Component)card).gameObject.SetActive(true);
card.SetParticlesEnabled(true);
((InteractableBase)card).SetEnabled(false);
card.Initialize(info, (Action<SelectableCard>)delegate(SelectableCard c)
{
Select(((Card)c).Info);
}, (Action<SelectableCard>)OnCardFlipped, true, (Action<SelectableCard>)((CardChoicesSequencer)this).OnCardInspected);
((Card)card).SetFaceDown(true, true);
yield return (object)new WaitForSeconds(0.12f);
}
yield return (object)new WaitForSeconds(0.3f);
((CardChoicesSequencer)this).SetCollidersEnabled(true);
((CardChoicesSequencer)this).EnableViewDeck((ControlMode)11, ((Component)this).transform.position);
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)picked != (Object)null));
((CardChoicesSequencer)this).DisableViewDeck();
yield return (object)new WaitForSeconds(0.7f);
ClearSpawned();
}
protected void Select(CardInfo info)
{
if (!((Object)(object)picked != (Object)null))
{
((CardChoicesSequencer)this).SetCollidersEnabled(false);
picked = info;
Log("点选:" + info.DisplayedNameLocalized);
}
}
protected void OnCardFlipped(SelectableCard card)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
card.SetLocalPosition(Vector3.zero, 0f, true);
if ((Object)(object)Singleton<InteractionCursor>.Instance.CurrentInteractable == (Object)(object)card)
{
((CardChoicesSequencer)this).OnCardInspected(card);
}
}
protected void ClearSpawned()
{
((CardChoicesSequencer)this).ResetLocalRotations();
foreach (SelectableCard selectableCard in ((CardChoicesSequencer)this).selectableCards)
{
if (!((Object)(object)selectableCard == (Object)null))
{
((InteractableBase)selectableCard).SetEnabled(false);
((Card)selectableCard).SetInteractionEnabled(false);
Object.Destroy((Object)(object)((Component)selectableCard).gameObject, 0.3f);
}
}
((CardChoicesSequencer)this).selectableCards.Clear();
}
protected static IEnumerator ShowText(TextDisplayer text, string message)
{
return text.ShowUntilInput(message, -2.5f, 0.5f, (Emotion)0, (LetterAnimation)0, (Speaker)0, (string[])null, true);
}
protected CardInfo RefusalCard(string title, string description)
{
return ModState.Label(ModState.CloneCard(ModState.TokenCard()), title, description);
}
protected static string Describe(CardInfo card)
{
return ModState.Describe(card);
}
protected void Log(string message)
{
Plugin.LogInfo("[" + TagName + "] " + message);
}
}
internal class DarkOfferingSequencer : BloodHornChoiceSequencer
{
private const int SIDE_DECK_SQUIRRELS = 10;
protected override string TagName => "黑暗奉献";
public override IEnumerator DoCustomSequence(CustomSpecialNodeData node)
{
ModState.MarkNodeUsed("DarkOffering");
TextDisplayer text = Singleton<TextDisplayer>.Instance;
OpenAltar();
yield return BloodHornChoiceSequencer.ShowText(text, "林间祭坛笼罩着暗红色的雾气。");
yield return BloodHornChoiceSequencer.ShowText(text, "\"石槽里养着一群饿不死的松鼠。喂它们,力量归你。\"");
int available = Mathf.Max(0, 10 - ModState.SquirrelsRemoved);
if (available <= 0)
{
yield return BloodHornChoiceSequencer.ShowText(text, "石槽空了。\n暗雾舔了舔槽底,什么也没剩下。");
yield break;
}
CardInfo squirrel = ModState.TokenCard();
if ((Object)(object)squirrel == (Object)null)
{
yield return BloodHornChoiceSequencer.ShowText(text, "祭坛里没有松鼠。");
yield break;
}
int offer = Mathf.Min(3, available);
Dictionary<CardInfo, int> counts = new Dictionary<CardInfo, int>();
List<CardInfo> options = new List<CardInfo>();
for (int i = 1; i <= offer; i++)
{
CardInfo option = ModState.Label(ModState.CloneCard(squirrel), "松鼠 x" + i, "祭坛吞下 " + i + " 只松鼠,换来 " + i + " 点力量。");
if (!((Object)(object)option == (Object)null))
{
counts[option] = i;
options.Add(option);
}
}
yield return ChooseFrom(options);
if ((Object)(object)picked == (Object)null)
{
yield break;
}
int power = ((!counts.ContainsKey(picked)) ? 1 : counts[picked]);
picked = null;
ModState.SquirrelsRemoved += power;
Log("献上松鼠 x" + power + "(累计移除 " + ModState.SquirrelsRemoved + ")");
yield return BloodHornChoiceSequencer.ShowText(text, "暗雾把 " + power + " 只松鼠绞成了血肉。\n\"谁要领走这份礼物?\"");
List<CardInfo> vessels = ModState.DeckVessels();
if (vessels.Count == 0)
{
yield return BloodHornChoiceSequencer.ShowText(text, "可是你已经没有能承载力量的造物了。");
yield break;
}
yield return ChooseFrom(vessels);
if (!((Object)(object)picked == (Object)null))
{
CardInfo vessel = picked;
picked = null;
CardModificationInfo mod = new CardModificationInfo();
mod.attackAdjustment = power;
RunState.Run.playerDeck.ModifyCard(vessel, mod);
SaveManager.SaveToFile(true);
Log(vessel.DisplayedNameLocalized + " 攻击 +" + power);
yield return BloodHornChoiceSequencer.ShowText(text, "力量落进了 " + vessel.DisplayedNameLocalized + " 的身体里。\n攻击 +" + power + "!");
}
}
}
internal class ChaoticDataSequencer : BloodHornChoiceSequencer
{
private static readonly Ability[] SAFE_ABILITIES;
private static readonly string[] TALKING_CARD_NAMES;
protected override string TagName => "混乱的数据";
private static bool IsTalkingCard(CardInfo card)
{
if ((Object)(object)card == (Object)null)
{
return false;
}
if (card.SpecialAbilities != null && card.SpecialAbilities.Contains((SpecialTriggeredAbility)9))
{
return true;
}
for (int i = 0; i < TALKING_CARD_NAMES.Length; i++)
{
if (((Object)card).name == TALKING_CARD_NAMES[i])
{
return true;
}
}
return false;
}
public override IEnumerator DoCustomSequence(CustomSpecialNodeData node)
{
ModState.MarkNodeUsed("ChaoticData");
TextDisplayer text = Singleton<TextDisplayer>.Instance;
OpenAltar();
yield return BloodHornChoiceSequencer.ShowText(text, "屏幕开始闪烁,数据流扭曲变形。\n\"01001000 01000101 01001100 01010000\"");
CardInfo glitch = BuildGlitchCard();
if ((Object)(object)glitch == (Object)null)
{
yield return BloodHornChoiceSequencer.ShowText(text, "数据没能凝聚成形状。\n屏幕暗了下去。");
yield break;
}
Log("乱码牌:" + ModState.Describe(glitch));
CardInfo refuse = RefusalCard("放手", "把数据推回屏幕里。什么都不会发生。");
List<CardInfo> options = new List<CardInfo> { glitch };
if ((Object)(object)refuse != (Object)null)
{
options.Add(refuse);
}
yield return BloodHornChoiceSequencer.ShowText(text, "一段混乱的数据凝成了一张牌。\n\n" + glitch.DisplayedNameLocalized + " " + glitch.Attack + "/" + glitch.Health + "\n印记:" + ModState.FormatAbilities(glitch) + "\n\n\"它还不稳定。你要带走它吗?\"");
yield return ChooseFrom(options);
bool accepted = (Object)(object)picked == (Object)(object)glitch;
picked = null;
if (!accepted)
{
yield return BloodHornChoiceSequencer.ShowText(text, "你松开了手。\n数据散成一片雪花点。");
yield break;
}
CardInfo added = ((CardCollectionInfo)RunState.Run.playerDeck).AddCard(glitch);
SaveManager.SaveToFile(true);
string reward = ApplyRandomReward(added);
string talk = ApplyTalkingBonus(added);
SaveManager.SaveToFile(true);
Log("加入卡组:" + ModState.Describe(added) + " 奖励=" + reward + " 语音=" + talk);
yield return BloodHornChoiceSequencer.ShowText(text, added.DisplayedNameLocalized + " 挤进了你的卡组。\n数据稳定下来,它被改写了一行:\n" + reward);
if (!string.IsNullOrEmpty(talk))
{
yield return BloodHornChoiceSequencer.ShowText(text, talk);
}
}
private CardInfo BuildGlitchCard()
{
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Expected O, but got Unknown
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Expected O, but got Unknown
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
List<CardInfo> list = new List<CardInfo>();
HashSet<string> hashSet = new HashSet<string>();
try
{
foreach (CardInfo item2 in CardManager.AllCardsCopy)
{
if (!((Object)(object)item2 == (Object)null) && item2.Attack >= 1 && item2.Health >= 1 && !((Object)item2).name.StartsWith("BloodHornGodMod") && ((Object)item2).name.IndexOf("Pelt", StringComparison.OrdinalIgnoreCase) < 0 && (item2.traits == null || (!item2.traits.Contains((Trait)13) && !item2.traits.Contains((Trait)12))) && item2.metaCategories != null && (item2.metaCategories.Contains((CardMetaCategory)0) || item2.metaCategories.Contains((CardMetaCategory)1) || item2.metaCategories.Contains((CardMetaCategory)3)) && hashSet.Add(((Object)item2).name))
{
list.Add(item2);
}
}
string[] tALKING_CARD_NAMES = TALKING_CARD_NAMES;
foreach (string talkingName in tALKING_CARD_NAMES)
{
CardInfo val = CardManager.AllCardsCopy.Find((CardInfo c) => (Object)(object)c != (Object)null && ((Object)c).name == talkingName);
if (!((Object)(object)val == (Object)null) && val.Attack >= 1 && val.Health >= 1 && hashSet.Add(((Object)val).name))
{
list.Add(val);
}
}
}
catch (Exception ex)
{
Log("取卡池失败:" + ex.Message);
}
if (list.Count == 0)
{
list = RunState.DeckList.Where((CardInfo c) => c.Attack >= 1).ToList();
}
if (list.Count == 0)
{
return null;
}
Ability item = SAFE_ABILITIES[Random.Range(0, SAFE_ABILITIES.Length)];
CardInfo val2 = ModState.CloneCard(list[Random.Range(0, list.Count)]);
ModState.Label(val2, "乱码_" + Random.Range(0, 1000).ToString("D3"), "一段没能完全解析的数据。\n它自己抓走了一个印记。");
CardModificationInfo val3 = new CardModificationInfo();
val3.abilities = new List<Ability> { item };
val2.Mods.Add(val3);
CardModificationInfo val4 = new CardModificationInfo();
val4.specialAbilities = new List<SpecialTriggeredAbility> { SigilDefinitions.Corrupted };
val2.Mods.Add(val4);
Texture2D val5 = CardDefinitions.LoadTexture("GlitchCard.png");
if ((Object)(object)val5 != (Object)null)
{
CardExtensions.SetPortrait(val2, val5, (FilterMode?)null);
}
Texture2D val6 = CardDefinitions.LoadTexture("GlitchCard_pixel.png");
if ((Object)(object)val6 != (Object)null)
{
CardExtensions.SetPixelPortrait(val2, val6, (FilterMode?)null);
}
return val2;
}
private string ApplyRandomReward(CardInfo card)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
CardModificationInfo val = new CardModificationInfo();
string result;
switch (Random.Range(0, 4))
{
case 0:
val.attackAdjustment = 3;
result = "攻击力 +3";
break;
case 1:
val.attackAdjustment = 2;
val.healthAdjustment = 2;
result = "攻击力 +2,生命值 +2";
break;
case 2:
val.bloodCostAdjustment = -1;
result = "献祭需求 -1";
break;
default:
val.bonesCostAdjustment = -4;
result = "骨币消耗 -4";
break;
}
RunState.Run.playerDeck.ModifyCard(card, val);
return result;
}
private string ApplyTalkingBonus(CardInfo card)
{
//IL_0017: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Invalid comparison between Unknown and I4
//IL_0067: 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)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!IsTalkingCard(card))
{
return null;
}
Ability val = (Ability)0;
string text = ((Object)card).name.ToLowerInvariant();
if (text.Contains("stoat"))
{
val = SigilDefinitions.TalkingStoat;
}
else if (text.Contains("stinkbug"))
{
val = SigilDefinitions.TalkingStinkbug;
}
else if (text.Contains("wolf"))
{
val = SigilDefinitions.TalkingWolf;
}
if ((int)val == 0)
{
return null;
}
CardModificationInfo val2 = new CardModificationInfo();
val2.abilities = new List<Ability> { val };
RunState.Run.playerDeck.ModifyCard(card, val2);
if (val == SigilDefinitions.TalkingStoat)
{
return "\"讲个故事吧。\"\n它决定在入场时送你两张空容器。";
}
if (val == SigilDefinitions.TalkingStinkbug)
{
return "\"虫子,虫子,到处都是虫子。\"\n它决定在入场时召唤两只骷髅。";
}
return "\"跟我来。\"\n它决定在入场时抽两张牌。";
}
static ChaoticDataSequencer()
{
Ability[] array = new Ability[20];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
SAFE_ABILITIES = (Ability[])(object)array;
TALKING_CARD_NAMES = new string[3] { "Stoat_Talking", "Stinkbug_Talking", "Wolf_Talking" };
}
}
internal class MemoryMirrorSequencer : BloodHornChoiceSequencer
{
protected override string TagName => "记忆镜";
public override IEnumerator DoCustomSequence(CustomSpecialNodeData node)
{
ModState.MarkNodeUsed("MemoryMirror");
TextDisplayer text = Singleton<TextDisplayer>.Instance;
List<CardInfo> vessels = ModState.DeckVessels();
Log("可选卡牌 " + vessels.Count);
if (vessels.Count < 2)
{
yield return BloodHornChoiceSequencer.ShowText(text, "镜中空空如也。\n\"下次多带些故事来吧。\"");
yield break;
}
OpenAltar();
yield return BloodHornChoiceSequencer.ShowText(text, "林间立着一面布满裂纹的铜镜。\n镜子里映出的不是你的脸,是你卡组里的生灵。");
yield return BloodHornChoiceSequencer.ShowText(text, "\"挑两个。它们的力气、皮肉和印记会整个调换过来。\n名字、费用、种族不变。交换永久生效。\"");
CardInfo refuse = RefusalCard("拒绝交换", "退后一步。镜子记住了你的克制。");
List<CardInfo> firstOptions = new List<CardInfo>(vessels);
if ((Object)(object)refuse != (Object)null)
{
firstOptions.Add(refuse);
}
yield return ChooseFrom(firstOptions);
if ((Object)(object)picked == (Object)(object)refuse)
{
picked = null;
ModState.GrantHeartGuard();
yield return BloodHornChoiceSequencer.ShowText(text, "你拒绝交换。\n镜子裂开一道缝,替你挡下了一次未来的窥视。\n【心防】已获得:下一场战斗第一张被击杀的己方卡不会被复制或窃取。");
yield break;
}
CardInfo first = picked;
picked = null;
if ((Object)(object)first == (Object)null)
{
yield break;
}
yield return BloodHornChoiceSequencer.ShowText(text, "镜中记下:" + ModState.Describe(first));
List<CardInfo> secondOptions = vessels.Where((CardInfo c) => ((Object)c).name != ((Object)first).name).ToList();
if ((Object)(object)refuse != (Object)null)
{
secondOptions.Add(refuse);
}
yield return ChooseFrom(secondOptions);
if ((Object)(object)picked == (Object)(object)refuse)
{
picked = null;
ModState.GrantHeartGuard();
yield return BloodHornChoiceSequencer.ShowText(text, "你放下了第一张。\n镜子裂开一道缝,替你挡下了一次未来的窥视。\n【心防】已获得。");
yield break;
}
CardInfo second = picked;
picked = null;
if (!((Object)(object)second == (Object)null))
{
yield return BloodHornChoiceSequencer.ShowText(text, "镜中又记下:" + ModState.Describe(second) + "\n\n两段记忆开始互换。");
ModState.SwapEverything(first, second);
SaveManager.SaveToFile(true);
Log("交换后 " + ModState.Describe(first) + " / " + ModState.Describe(second));
yield return BloodHornChoiceSequencer.ShowText(text, "[" + first.DisplayedNameLocalized + "]\n→ " + ModState.Describe(first) + "\n\n[" + second.DisplayedNameLocalized + "]\n→ " + ModState.Describe(second));
yield return ApplyMirrorCost(text, first, second);
MirrorShardItem.GrantToPlayer();
yield return BloodHornChoiceSequencer.ShowText(text, "古镜的光渐渐黯淡。\n\"记忆已交换,代价已支付。\"\n\n镜底掉落了一块【镜之碎片】。");
}
}
private IEnumerator ApplyMirrorCost(TextDisplayer text, CardInfo first, CardInfo second)
{
bool ouroboros = ((Object)first).name.IndexOf("Ouroboros", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)second).name.IndexOf("Ouroboros", StringComparison.OrdinalIgnoreCase) >= 0;
int roll = Random.Range(0, 3);
if (ouroboros)
{
roll = 1;
}
Log("代价=" + ModState.RandomMirrorCostName(roll) + (ouroboros ? "(衔尾蛇特判)" : ""));
switch (roll)
{
case 0:
{
CardInfo target = ((Random.value < 0.5f) ? first : second);
CardModificationInfo mod = new CardModificationInfo();
mod.abilities = new List<Ability> { SigilDefinitions.Fragile };
RunState.Run.playerDeck.ModifyCard(target, mod);
SaveManager.SaveToFile(true);
yield return BloodHornChoiceSequencer.ShowText(text, "【镜之代价 · 褪色记忆】\n" + target.DisplayedNameLocalized + " 获得了【褪色记忆】。\n它死后会从卡组中永久消失,但它的亡语仍会照常触发。");
yield break;
}
case 1:
{
CardInfo source = ((!ouroboros) ? ((Random.value < 0.5f) ? first : second) : ((((Object)first).name.IndexOf("Ouroboros", StringComparison.OrdinalIgnoreCase) >= 0) ? first : second));
ModState.SetPendingEcho(source);
yield return BloodHornChoiceSequencer.ShowText(text, "【镜之代价 · 镜中回响】\n下一场战斗中,敌方会召唤一个弱化版的 " + source.DisplayedNameLocalized + "。\n它的力气和皮肉只剩一半,费用为零。");
yield break;
}
}
List<CardInfo> others = RunState.DeckList.Where((CardInfo c) => (Object)(object)c != (Object)(object)first && (Object)(object)c != (Object)(object)second).ToList();
if (others.Count == 0)
{
yield return BloodHornChoiceSequencer.ShowText(text, "【镜之代价 · 记忆损耗】\n已经没有别的记忆可以拿走了。\n代价被豁免。");
yield break;
}
CardInfo lost = others[Random.Range(0, others.Count)];
((CardCollectionInfo)RunState.Run.playerDeck).RemoveCard(lost);
SaveManager.SaveToFile(true);
Log("记忆损耗移除 " + ModState.Describe(lost));
yield return BloodHornChoiceSequencer.ShowText(text, "【镜之代价 · 记忆损耗】\n" + lost.DisplayedNameLocalized + " 从你的卡组里被永久抹去。\n\n\"有些记忆,注定要消逝。\"");
}
}
internal static class NodeDefinitions
{
internal const string DARK_OFFERING = "DarkOffering";
internal const string CHAOTIC_DATA = "ChaoticData";
internal const string MEMORY_MIRROR = "MemoryMirror";
internal static void Register()
{
Register("DarkOffering", typeof(DarkOfferingSequencer), "DarkOffering_icon.png", () => ModState.SquirrelsRemoved < 10 && RunState.Run != null && RunState.Run.playerDeck != null && ((CardCollectionInfo)RunState.Run.playerDeck).Cards.Count > 0);
Register("ChaoticData", typeof(ChaoticDataSequencer), "ChaoticData_icon.png", null);
Register("MemoryMirror", typeof(MemoryMirrorSequencer), "MemoryMirror_icon.png", () => ModState.DistinctVesselCount() >= 2);
Plugin.LogInfo("节点注册完成:黑暗奉献 / 混乱的数据 / 记忆镜(每局各一次)。");
}
private static void Register(string key, Type sequencerType, string iconFile, Func<bool> extraCheck)
{
List<Texture2D> list = new List<Texture2D>();
Texture2D val = CardDefinitions.LoadTexture(iconFile);
if ((Object)(object)val != (Object)null)
{
list.Add(val);
}
RunOnceCondition item = new RunOnceCondition(key, extraCheck);
List<SelectionCondition> list2 = new List<SelectionCondition> { (SelectionCondition)(object)item };
NewNodeManager.New("com.inscryptionmod.bloodhorngod", key, (GenerationType)2, sequencerType, list, list2, list2, (Action<CustomSpecialNodeData>)null, (Action<CustomSpecialNodeData, MapNode2D>)null, (GameObject)null, (GameObject)null);
}
}
}