using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ShinyShoe;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Patty_PyreHeartEffectEnabler_MOD")]
[assembly: AssemblyDescription("Pyre Heart Effect Enabler")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patty_PyreHeartEffectEnabler_MOD")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("33fcf1fc-7ba7-4793-b247-99c24c4566f6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.1.0")]
namespace Patty_PyreHeartEffectEnabler_MOD;
[BepInPlugin("Patty_PyreHeartEffectEnabler_MOD", "Pyre Heart Effect Enabler", "1.1.1")]
internal class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <CreateAllEntry>d__35 : IEnumerable<ConfigEntry<bool>>, IEnumerable, IEnumerator<ConfigEntry<bool>>, IDisposable, IEnumerator
{
private int <>1__state;
private ConfigEntry<bool> <>2__current;
private int <>l__initialThreadId;
public Plugin <>4__this;
ConfigEntry<bool> IEnumerator<ConfigEntry<bool>>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateAllEntry>d__35(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
//IL_00e0: Expected O, but got Unknown
//IL_010b: 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_0126: Expected O, but got Unknown
//IL_0126: Expected O, but got Unknown
//IL_0151: 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_016c: Expected O, but got Unknown
//IL_016c: Expected O, but got Unknown
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Expected O, but got Unknown
//IL_01b2: Expected O, but got Unknown
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Expected O, but got Unknown
//IL_01f8: Expected O, but got Unknown
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Expected O, but got Unknown
//IL_023e: Expected O, but got Unknown
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Expected O, but got Unknown
//IL_0284: Expected O, but got Unknown
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Expected O, but got Unknown
//IL_02ca: Expected O, but got Unknown
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Expected O, but got Unknown
//IL_0310: Expected O, but got Unknown
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Expected O, but got Unknown
//IL_0357: Expected O, but got Unknown
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Expected O, but got Unknown
//IL_039e: Expected O, but got Unknown
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Expected O, but got Unknown
//IL_03e5: Expected O, but got Unknown
//IL_0411: Unknown result type (might be due to invalid IL or missing references)
//IL_0422: Unknown result type (might be due to invalid IL or missing references)
//IL_042c: Expected O, but got Unknown
//IL_042c: Expected O, but got Unknown
//IL_0458: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: Unknown result type (might be due to invalid IL or missing references)
//IL_0473: Expected O, but got Unknown
//IL_0473: Expected O, but got Unknown
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Expected O, but got Unknown
//IL_04ba: Expected O, but got Unknown
//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0501: Expected O, but got Unknown
//IL_0501: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Proto Heartcage"), true, new ConfigDescription("No special capabilities.\n无特殊能力", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Heart of the Pact"), true, new ConfigDescription("After playing a card from your Primary and Allied clan, draw +1 next turn.\n打出一张你主氏族和盟友氏族的卡牌后,下个回合抽 +1 张牌。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Lifemothers Pyre"), true, new ConfigDescription("Adds the option to copy cards at the Merchants of Steel, Magic, and Trinkets.\n新增在钢铁、魔法和杂货商人处复制卡牌的选项。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Malickas Shifting Pyre"), true, new ConfigDescription("All drafted cards appear with an upgrade.\n所有自选卡牌都带有升级。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Wynghs Spirit"), true, new ConfigDescription("Once per battle, select the Heart to restore the front friendly units on all floors to full health.\n选择薪火之心可为所有层的前排友方单位恢复所有生命值,每场战斗一次。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Fhyras Greed"), true, new ConfigDescription("When your Pyre takes damage, gain 10 Gold.\n当薪火收到伤害时,获得 10 金币。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Aquaths Reservation"), true, new ConfigDescription("Once per battle, select the Heart to gain 3 Ember.\n选择薪火之心可获得 3 余烬,每场战斗一次。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Bogwurms Growth"), true, new ConfigDescription("Permanently add 1 Capacity to a random floor after each battle.\n每场战斗后,为随机楼层永久增加 1 容量。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Echo of the Time Father"), true, new ConfigDescription("Once per battle, select the Heart to apply Frozen to all non-Blight and non-Scourge cards in hand.\n选择薪火之心可使所有非祸患和非天灾手牌获得冻结,每场战斗一次。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 9;
return true;
case 9:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Herzals Horde"), true, new ConfigDescription("Gain 4 Deployment Ember. Deployable upgrade is 50% cheaper.\n获得 4 部署阶段余烬。升级可部署的价格降低 50%。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 10;
return true;
case 10:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Pyre of Savagery"), true, new ConfigDescription("Friendly units gain Slay: +1 Attack permanently.\n友方单位获得“杀戮:永久 +1 攻击力。”", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 11;
return true;
case 11:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Pyre of Dominion"), true, new ConfigDescription("Remove Train Stewards and starting cards. Immediately draft four packs, and double each card picked.\n移除乘务员和初始卡牌。立刻获取四个自选卡包,并双倍获取挑选的卡牌。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 12;
return true;
case 12:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Pyre of Entropy"), true, new ConfigDescription("Add a Vengeful Shard to your deck after each battle. Draw 1 extra card for every 2 Blights in your deck.\n每场战斗后在你的卡组中添加 1 张复仇碎片。你的卡组中每有 2 张祸患,额外抽 1 张牌。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 13;
return true;
case 13:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Unassigned 1"), true, new ConfigDescription("(WIP) Gain a duplicate of each drafted card.\n(制作中)每次自选卡牌可获得一张复制品。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 14;
return true;
case 14:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Unassigned 2"), true, new ConfigDescription("Fhyra_ArtifactDataGainSpellPower.", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 15;
return true;
case 15:
<>1__state = -1;
<>2__current = ((BaseUnityPlugin)<>4__this).Config.Bind<bool>(new ConfigDefinition("Pyre Heart Effects", "Unassigned 3"), true, new ConfigDescription("-1 Capacity on all floors. Add 1 Capacity to a random floor after each battle.\n所有层 -1 容量。每场战斗后,随机层增加 1 容量。", (AcceptableValueBase)null, Array.Empty<object>()));
<>1__state = 16;
return true;
case 16:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<ConfigEntry<bool>> IEnumerable<ConfigEntry<bool>>.GetEnumerator()
{
<CreateAllEntry>d__35 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <CreateAllEntry>d__35(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<ConfigEntry<bool>>)this).GetEnumerator();
}
}
internal const string PROTO_HEARTCAGE = "Proto Heartcage";
internal const string HEART_OF_THE_PACT = "Heart of the Pact";
internal const string LIFEMOTHERS_PYRE = "Lifemothers Pyre";
internal const string MALICKAS_SHIFTING_PYRE = "Malickas Shifting Pyre";
internal const string WYNGHS_SPIRIT = "Wynghs Spirit";
internal const string FHYRAS_GREED = "Fhyras Greed";
internal const string AQUATHS_RESERVATION = "Aquaths Reservation";
internal const string BOGWURMS_GROWTH = "Bogwurms Growth";
internal const string ECHO_OF_THE_TIME_FATHER = "Echo of the Time Father";
internal const string HERZALS_HORDE = "Herzals Horde";
internal const string PYRE_OF_SAVAGERY = "Pyre of Savagery";
internal const string PYRE_OF_DOMINION = "Pyre of Dominion";
internal const string PYRE_OF_ENTROPY = "Pyre of Entropy";
internal const string UNASSIGNED_1 = "Unassigned 1";
internal const string UNASSIGNED_2 = "Unassigned 2";
internal const string UNASSIGNED_3 = "Unassigned 3";
internal static List<RelicState> PyreHeartArtifacts = new List<RelicState>();
internal static ManualLogSource LogSource { get; private set; }
internal static Harmony PluginHarmony { get; private set; }
internal static List<ConfigEntry<bool>> ConfigEntries { get; private set; } = new List<ConfigEntry<bool>>();
internal static Dictionary<string, string> GUIDToName { get; private set; } = new Dictionary<string, string>
{
{ "17c0693e-5b08-4252-b300-b4b377b9540d", "Proto Heartcage" },
{ "17ed1b69-ffb7-436c-b87c-98c07aba0242", "Heart of the Pact" },
{ "39dd8cf1-d611-4804-8ab9-a0f992afe691", "Lifemothers Pyre" },
{ "68a9b977-3407-4128-bf35-245fd92f8e2b", "Malickas Shifting Pyre" },
{ "7f5fff27-455e-4fc7-825d-df92f07e084d", "Wynghs Spirit" },
{ "cc792aac-4b82-40af-bf80-3a83bc511383", "Fhyras Greed" },
{ "36075977-411e-43e4-a075-0c4e3b81349b", "Aquaths Reservation" },
{ "7a60e645-e4f0-403c-9b4a-e794675f3a60", "Bogwurms Growth" },
{ "c36f7f21-9293-4c77-8f89-a7919180186e", "Echo of the Time Father" },
{ "db66de87-1fbe-4f29-9e62-3926d639b413", "Herzals Horde" },
{ "cc6a381e-0723-490a-af72-78cc82978094", "Pyre of Savagery" },
{ "c0c09adc-b23e-422e-bb75-689ee82cfa36", "Pyre of Dominion" },
{ "87d50a3b-dade-455f-9012-04f46bac02a5", "Pyre of Entropy" },
{ "7d9d33b9-2a9e-4e98-a205-600023d5386f", "Unassigned 1" },
{ "197f8e8d-cefe-4fa2-af94-d84f9631509c", "Unassigned 2" },
{ "96cca2fd-d096-4340-9054-d498826a0781", "Unassigned 3" }
};
public void Awake()
{
//IL_002c: Expected O, but got Unknown
LogSource = ((BaseUnityPlugin)this).Logger;
try
{
PluginHarmony = Harmony.CreateAndPatchAll(typeof(PatchList), "Patty_PyreHeartEffectEnabler_MOD");
}
catch (HarmonyException val)
{
HarmonyException val2 = val;
LogSource.LogError((object)((Exception)(((object)((Exception)(object)val2).InnerException) ?? ((object)val2))).Message);
}
foreach (ConfigEntry<bool> item in CreateAllEntry())
{
ConfigEntries.Add(item);
}
}
public static List<RelicState> GetPyreHeartArtifacts()
{
return PyreHeartArtifacts;
}
[IteratorStateMachine(typeof(<CreateAllEntry>d__35))]
private IEnumerable<ConfigEntry<bool>> CreateAllEntry()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateAllEntry>d__35(-2)
{
<>4__this = this
};
}
}
internal class PatchList
{
[HarmonyPostfix]
[HarmonyPatch(typeof(AppManager), "DoesThisBuildReportErrors")]
public static void DisableErrorReportingPatch(ref bool __result)
{
__result = false;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(SaveManager), "SetupRun")]
private static IEnumerable<CodeInstruction> SetupRun(IEnumerable<CodeInstruction> instructions)
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = list.FindLastIndex((CodeInstruction codeInstruction) => codeInstruction.opcode == OpCodes.Callvirt && codeInstruction.operand.ToString().Contains("AddRange"));
num++;
MethodInfo methodInfo = typeof(ListExtensions).GetMethods(AccessTools.allDeclared).First((MethodInfo method) => method.Name == "RemoveDuplicates" && method.IsGenericMethod && method.GetParameters().Length == 1).MakeGenericMethod(typeof(RelicState));
List<CodeInstruction> list2 = new List<CodeInstruction>();
list2.Add(new CodeInstruction(OpCodes.Ldloc_2, (object)null));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "GetPyreHeartArtifacts", (Type[])null, (Type[])null)));
list2.Add(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(List<RelicState>), "AddRange", (Type[])null, (Type[])null)));
list2.Add(new CodeInstruction(OpCodes.Ldloc_2, (object)null));
list2.Add(new CodeInstruction(OpCodes.Callvirt, (object)methodInfo));
List<CodeInstruction> collection = list2;
list.InsertRange(num, collection);
return list.AsEnumerable();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SaveManager), "GetAllRelics", new Type[] { typeof(List<RelicState>) })]
private static void GetAllRelics(List<RelicState> allRelics)
{
allRelics.AddRange(Plugin.GetPyreHeartArtifacts());
ListExtensions.RemoveDuplicates<RelicState>(allRelics);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SaveManager), "SetActiveSavePyreCharacter")]
private static void SetActiveSavePyreCharacter(SaveManager __instance, ref MutableRules ___mutableRules)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
Plugin.PyreHeartArtifacts.Clear();
foreach (PyreArtifactData allPyreArtifactData in __instance.GetAllGameData().GetAllPyreArtifactDatas())
{
if (Plugin.GUIDToName.TryGetValue(((GameData)allPyreArtifactData).GetID(), out var artifactName) && Plugin.ConfigEntries.Exists((ConfigEntry<bool> entry) => ((ConfigEntryBase)entry).Definition.Key == artifactName && entry.Value))
{
Plugin.PyreHeartArtifacts.Add((RelicState)new PyreArtifactState(allPyreArtifactData, ___mutableRules));
}
}
}
}
public static class PluginInfo
{
public const string GUID = "Patty_PyreHeartEffectEnabler_MOD";
public const string Name = "Pyre Heart Effect Enabler";
public const string Version = "1.1.1";
}