using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DiskCardGame;
using EndlessMode;
using GBC;
using HarmonyLib;
using InscryptionAPI.Guid;
using InscryptionAPI.Pelts;
using InscryptionAPI.Saves;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("EndlessMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EndlessMode")]
[assembly: AssemblyTitle("EndlessMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public static class Endless
{
private static int m_EndlessSeed;
public static int EndlessSeed => SaveManager.SaveFile.GetCurrentRandomSeed() + m_EndlessSeed++;
public static IEnumerator FinalBossKilled(Part1BossOpponent opponent)
{
Plugin.Log.LogInfo((object)$"Killed Final Boss: {((Opponent)opponent).OpponentType}");
RunStats.FinalBossKilled(opponent);
yield return opponent.BossDefeatedSequence();
}
public static void SetupNewRun()
{
RunStats.SetupNewRun();
}
public static void SetupNextRun()
{
RunStats.SetupNextRun();
RunState.Run.regionTier = 0;
AscensionSaveData.Data.RollCurrentRunRegionOrder();
RunState.Run.GenerateMapDataForCurrentRegion((PredefinedNodes)null);
}
public static void NextRegionStarted()
{
RunStats.NewFloorStarted();
}
public static void BossKilled(Part1BossOpponent opponent)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
RunStats.BossKilled(opponent);
Plugin.Log.LogInfo((object)$"Killed {((Opponent)opponent).OpponentType}");
}
public static bool EndlessRunFinished()
{
return false;
}
public static void AdjustDifficulty(PlayableCard card, Opponent opponent)
{
int num = RunStats.TotalResets * Configs.Instance.DifficultyIncreaseChancePerReset;
if (num <= 0)
{
return;
}
for (int num2 = Mathf.CeilToInt((float)num / 100f); num2 > 0; num2--)
{
int num3 = SeededRandom.Range(0, 100, EndlessSeed);
if (num3 < num)
{
BuffCard(card);
}
num -= 100;
}
}
private static void BuffCard(PlayableCard card)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
int difficultyHealthChance = Configs.Instance.DifficultyHealthChance;
int difficultyAttackChance = Configs.Instance.DifficultyAttackChance;
int difficultySigilChance = Configs.Instance.DifficultySigilChance;
int num = difficultyHealthChance + difficultyAttackChance + difficultySigilChance;
CardModificationInfo val = new CardModificationInfo();
val.fromCardMerge = true;
int num2 = SeededRandom.Range(0, num, EndlessSeed);
if (num2 < difficultyHealthChance)
{
val.healthAdjustment = Configs.Instance.DifficultyHealthBuff;
}
else if (num2 < difficultyHealthChance + difficultyAttackChance)
{
val.attackAdjustment = Configs.Instance.DifficultyAttackBuff;
}
else
{
val.abilities = new List<Ability>();
val.abilities.Add(AbilitiesUtil.GetRandomLearnedAbility(EndlessSeed, false, 0, 5, (AbilityMetaCategory)1));
}
card.AddTemporaryMod(val);
}
}
namespace EndlessMode
{
public class Configs
{
public static Configs Instance;
private ConfigEntry<bool> m_ResetPeltPricesAfterFinalBosses = Bind("Pelts", "Reset Prices after Final Bosses", defaultValue: false, "If disabled then the prices for pelts resets back to cheapest after killing a final boss");
private ConfigEntry<int> m_DifficultyIncreaseChancePerReset = Bind("Difficulty", "Chance per Reset", 5, "Chance that each of Leshy's cards gets a buff after defeating a final boss.");
private ConfigEntry<int> m_DifficultyHealthBuff = Bind("Difficulty", "Health Buff", 1, "How much a cards health will buff if chosen to be buffed.");
private ConfigEntry<int> m_DifficultyHealthChance = Bind("Difficulty", "Health Chance", 40, "Chance that a card will get a health buff.");
private ConfigEntry<int> m_DifficultyAttackBuff = Bind("Difficulty", "Attack Buff", 1, "How much a cards attack will buff if chosen to be buffed.");
private ConfigEntry<int> m_DifficultyAttackChance = Bind("Difficulty", "Attack Chance", 35, "Chance that a card will get a attack buff.");
private ConfigEntry<int> m_DifficultySigilChance = Bind("Difficulty", "Sigil Chance", 25, "Chance that a card will get a sigil buff.");
public bool ResetPeltPricesAfterFinalBosses
{
get
{
return m_ResetPeltPricesAfterFinalBosses.Value;
}
set
{
m_ResetPeltPricesAfterFinalBosses.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultyIncreaseChancePerReset
{
get
{
return m_DifficultyIncreaseChancePerReset.Value;
}
set
{
m_DifficultyIncreaseChancePerReset.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultyHealthBuff
{
get
{
return m_DifficultyHealthBuff.Value;
}
set
{
m_DifficultyHealthBuff.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultyHealthChance
{
get
{
return m_DifficultyHealthChance.Value;
}
set
{
m_DifficultyHealthChance.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultyAttackBuff
{
get
{
return m_DifficultyAttackBuff.Value;
}
set
{
m_DifficultyAttackBuff.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultyAttackChance
{
get
{
return m_DifficultyAttackChance.Value;
}
set
{
m_DifficultyAttackChance.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
public int DifficultySigilChance
{
get
{
return m_DifficultySigilChance.Value;
}
set
{
m_DifficultySigilChance.Value = value;
((BaseUnityPlugin)Plugin.Instance).Config.Save();
}
}
private static ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
return ((BaseUnityPlugin)Plugin.Instance).Config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
}
}
[BepInPlugin("jamesgames.inscryption.endlessmode", "Endless Mode", "0.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PluginGuid = "jamesgames.inscryption.endlessmode";
public const string PluginName = "Endless Mode";
public const string PluginVersion = "0.3.0";
public static Plugin Instance;
public static ManualLogSource Log;
public static string PluginDirectory;
private void Awake()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Endless Mode...");
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Configs.Instance = new Configs();
PluginDirectory = ((BaseUnityPlugin)this).Info.Location.Replace("EndlessMode.dll", "");
new Harmony("jamesgames.inscryption.endlessmode").PatchAll();
Custom_AscensionStat.AddCustomStat("jamesgames.inscryption.endlessmode", "Final Bosses Killed", () => RunStats.TotalFinalBossesKilled);
Custom_AscensionStat.AddCustomStat("jamesgames.inscryption.endlessmode", "Highest Floor", () => RunStats.CurrentFloor + 1);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Endless Mode!");
}
}
[HarmonyPatch]
public static class Custom_AscensionStat
{
private class CustomStat
{
public string GUID;
public string Name;
public Type Type;
public Func<int> GetValue;
}
public static List<Type> BaseStatTypes = GetBaseStats();
public static List<Type> CustomStatTypes = new List<Type>();
public static List<Type> AllStatTypes = GetBaseStats();
private static List<CustomStat> NewCustomStat = new List<CustomStat>();
private static List<Type> GetBaseStats()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
List<Type> list = new List<Type>();
foreach (Type value in Enum.GetValues(typeof(Type)))
{
list.Add(value);
}
return list;
}
public static Type AddCustomStat(string guid, string name, Func<int> GetValue)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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)
CustomStat customStat = new CustomStat();
customStat.Type = GuidManager.GetEnumValue<Type>(guid, name);
customStat.GUID = guid;
customStat.Name = name;
customStat.GetValue = GetValue;
NewCustomStat.Add(customStat);
CustomStatTypes.Add(customStat.Type);
return customStat.Type;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AscensionStat), "GetStringForType", new Type[] { })]
public static bool AscensionStat_GetStringForType(AscensionStat __instance, ref string __result)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (CustomStatTypes.Contains(__instance.type))
{
foreach (CustomStat item in NewCustomStat)
{
if (item.Type == __instance.type)
{
__result = item.Name;
return false;
}
}
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AscensionStatsScreen), "FillStatsText", new Type[] { })]
public static bool AscensionStatsScreen_FillStatsText(AscensionStatsScreen __instance)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: 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_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Expected O, but got Unknown
Plugin.Log.LogInfo((object)("AscensionStatsScreen_FillStatsText " + NewCustomStat.Count));
AscensionMenuScreenTransition component = ((Component)__instance).GetComponent<AscensionMenuScreenTransition>();
List<AscensionStat> list = new List<AscensionStat>(__instance.allTimeStats ? AscensionSaveData.Data.stats.allTimeStats : AscensionSaveData.Data.stats.currentRunStats);
foreach (CustomStat item in NewCustomStat)
{
list.Add(new AscensionStat(item.Type, item.GetValue()));
__instance.displayedStatTypes.Add(item.Type);
PixelText val = __instance.statsText[__instance.statsText.Count - 1];
Vector3 val2 = ((Component)__instance.statsText[1]).transform.position - ((Component)__instance.statsText[0]).transform.position;
PixelText val3 = Object.Instantiate<PixelText>(val, ((Component)val).transform.parent);
__instance.statsText.Add(val3);
((Component)val3).transform.position = ((Component)val).transform.position + val2;
component.screenInteractables.Insert(component.screenInteractables.Count - 2, (MainInputInteractable)(object)((Component)val3).GetComponentInParent<AscensionMenuInteractable>());
component.onEnableRevealedObjects.Insert(1, ((Component)((Component)val3).transform.parent).gameObject);
}
int i;
for (i = 0; i < __instance.displayedStatTypes.Count && i < __instance.statsText.Count; i++)
{
AscensionStat val4 = list.Find((AscensionStat x) => x.type == __instance.displayedStatTypes[i]);
if (val4 == null)
{
val4 = new AscensionStat(__instance.displayedStatTypes[i], 0);
}
int num = val4.value;
if (__instance.allTimeStats)
{
AscensionStat val5 = AscensionSaveData.Data.stats.currentRunStats.Find((AscensionStat x) => x.type == __instance.displayedStatTypes[i]);
if (val5 != null)
{
num += val5.value;
}
}
string text = Localization.ToUpper(Localization.Translate(val4.GetStringForType())) + ": " + num;
__instance.statsText[i].SetText(text, false);
}
return false;
}
}
[HarmonyPatch]
public static class Difficulty_Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Opponent), "CreateCard")]
public static void Opponent_CreateCard(CardInfo cardInfo, Opponent __instance, ref PlayableCard __result)
{
Endless.AdjustDifficulty(__result, __instance);
}
}
[HarmonyPatch]
public static class Encounter_Patches
{
}
[HarmonyPatch]
public static class FinalBoss_Patches
{
[HarmonyPatch]
public static class FinalBoss_LifeLostSequence
{
public static IEnumerable<MethodBase> TargetMethods()
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
int count = 0;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (type.IsSubclassOf(typeof(Part1BossOpponent)))
{
MethodInfo method = type.GetMethod("LifeLostSequence", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (method != null)
{
yield return method;
count++;
}
}
}
}
stopwatch.Stop();
Plugin.Log.LogInfo((object)$"Found {count} methods in {stopwatch.ElapsedMilliseconds}ms");
}
public static IEnumerator Postfix(IEnumerator sequenceEvent, Part1BossOpponent __instance)
{
yield return sequenceEvent;
if (((Opponent)__instance).NumLives == 0)
{
Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>().SetColor(Color.black);
((ScreenEffect)Singleton<UIManager>.Instance.Effects.GetEffect<ScreenColorEffect>()).SetIntensity(0f, 3f);
yield return (object)new WaitForSeconds(0.8f);
Singleton<InteractionCursor>.Instance.SetHidden(false);
CustomCoroutine.WaitThenExecute(1.25f, (Action)delegate
{
AudioController.Instance.StopAllLoops();
}, false);
yield return Endless.FinalBossKilled(__instance);
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Part1BossOpponent), "TransitionFromFinalBoss", new Type[] { })]
public static bool Part1BossOpponent_TransitionFromFinalBoss(Part1BossOpponent __instance)
{
Plugin.Log.LogInfo((object)"Part1BossOpponent_TransitionFromFinalBoss");
return Endless.EndlessRunFinished();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SceneManager), "LoadScene", new Type[] { typeof(string) })]
public static bool SceneManager_LoadScene(string sceneName)
{
if (sceneName == "Ascension_Credits")
{
if (Environment.StackTrace.Contains("LifeLostSequence"))
{
Plugin.Log.LogInfo((object)"Credits called from LifeLostSequence, skipping.");
return Endless.EndlessRunFinished();
}
Plugin.Log.LogInfo((object)"Credits NOT called from LifeLostSequence, skipping.");
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Part1BossOpponent), "EndAscensionRun", new Type[] { })]
public static bool Part1BossOpponent_EndAscensionRun(Part1BossOpponent __instance)
{
return Endless.EndlessRunFinished();
}
}
[HarmonyPatch]
public static class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(AscensionSaveData), "NewRun", new Type[] { typeof(List<CardInfo>) })]
public static void AscensionSaveData_NewRun(RunState __instance)
{
Endless.SetupNewRun();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(RunState), "NextRegion")]
public static bool RunState_NextRegion(RunState __instance)
{
if (RunState.Run.regionTier == 3)
{
Endless.SetupNextRun();
return false;
}
Endless.NextRegionStarted();
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Part1BossOpponent), "BossDefeatedSequence")]
public static bool Part1BossOpponent_BossDefeatedSequence(Part1BossOpponent __instance)
{
Endless.BossKilled(__instance);
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(RunInfoUIBar), "UpdateText")]
public static bool RunInfoUIBar_UpdateText(RunInfoUIBar __instance)
{
string text = string.Format(Localization.Translate("MAP #{0}"), RunState.Run.regionTier + 1);
text = text + " - " + string.Format(Localization.Translate("Floor #{0}"), RunStats.CurrentFloor);
text = text + " - " + string.Format(Localization.Translate("Resets #{0}"), RunStats.TotalResets);
__instance.mapIndexText.SetText(text, false);
return false;
}
}
[HarmonyPatch]
public static class RunState_regionTier_Patches
{
public static IEnumerable<MethodInfo> TargetMethods()
{
BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
yield return typeof(AscensionSaveData).GetMethod("EndRun", allFlags);
yield return typeof(SaveFile).GetMethod("GetCurrentRandomSeed", allFlags);
yield return typeof(RunState).GetProperty("RandomSeed", allFlags).GetMethod;
if (!Configs.Instance.ResetPeltPricesAfterFinalBosses)
{
yield return typeof(PeltManager).GetProperty("BasePeltPrices", allFlags).GetMethod;
}
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
MethodInfo getMethod = typeof(RunState).GetProperty("CurrentRegionTier", bindingAttr).GetMethod;
MethodInfo method = typeof(RunState_regionTier_Patches).GetMethod("GetRegionTier2", bindingAttr);
FieldInfo field = typeof(RunState).GetField("regionTier", bindingAttr);
MethodInfo method2 = typeof(RunState_regionTier_Patches).GetMethod("GetRegionTier", bindingAttr);
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (val.opcode == OpCodes.Ldfld && val.operand == field)
{
list[i] = new CodeInstruction(OpCodes.Call, (object)method2);
}
else if (val.opcode == OpCodes.Call && val.operand == getMethod)
{
list[i] = new CodeInstruction(OpCodes.Call, (object)method);
}
}
return list;
}
public static int GetRegionTier(RunState runState)
{
return RunStats.CurrentFloor;
}
public static int GetRegionTier2()
{
return RunStats.CurrentFloor;
}
}
[HarmonyPatch]
public static class RunStats
{
private static int m_currentFloor = 0;
private static int m_totalResets = 0;
private static int m_totalFinalBossesKilled = 0;
private static Dictionary<Type, int> m_bossKillLookup = new Dictionary<Type, int>();
public static int TotalFinalBossesKilled => m_totalFinalBossesKilled;
public static int CurrentFloor => m_currentFloor;
public static int TotalResets => m_totalResets;
public static void SetupNewRun()
{
m_totalResets = 0;
m_currentFloor = 0;
m_totalFinalBossesKilled = 0;
m_bossKillLookup = new Dictionary<Type, int>();
Save();
}
public static void FinalBossKilled(Part1BossOpponent opponent)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
m_totalFinalBossesKilled++;
if (!m_bossKillLookup.ContainsKey(((Opponent)opponent).OpponentType))
{
m_bossKillLookup.Add(((Opponent)opponent).OpponentType, 0);
}
m_bossKillLookup[((Opponent)opponent).OpponentType]++;
Save();
}
public static void BossKilled(Part1BossOpponent opponent)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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)
if (!m_bossKillLookup.ContainsKey(((Opponent)opponent).OpponentType))
{
m_bossKillLookup.Add(((Opponent)opponent).OpponentType, 0);
}
m_bossKillLookup[((Opponent)opponent).OpponentType]++;
Save();
}
public static void SetupNextRun()
{
m_totalResets++;
m_currentFloor++;
Save();
}
public static void NewFloorStarted()
{
m_currentFloor++;
Save();
}
private static void Save()
{
ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.endlessmode", "TotalFinalBossesKilled", (object)m_totalFinalBossesKilled);
ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.endlessmode", "TotalResets", (object)m_totalResets);
ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.endlessmode", "CurrentFloor", (object)m_currentFloor);
string text = JsonUtility.ToJson((object)new SerializedDictionary(m_bossKillLookup));
ModdedSaveManager.RunState.SetValue("jamesgames.inscryption.endlessmode", "BossKillLookup", (object)text);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ModdedSaveManager), "ReadDataFromFile", new Type[] { })]
public static void ModdedSaveManager_ReadDataFromFile()
{
m_totalFinalBossesKilled = ModdedSaveManager.RunState.GetValueAsInt("jamesgames.inscryption.endlessmode", "TotalFinalBossesKilled");
m_totalResets = ModdedSaveManager.RunState.GetValueAsInt("jamesgames.inscryption.endlessmode", "TotalResets");
m_currentFloor = ModdedSaveManager.RunState.GetValueAsInt("jamesgames.inscryption.endlessmode", "CurrentFloor");
m_bossKillLookup = new Dictionary<Type, int>();
string value = ModdedSaveManager.RunState.GetValue("jamesgames.inscryption.endlessmode", "BossKillLookup");
if (!string.IsNullOrEmpty(value))
{
SerializedDictionary serializedDictionary = JsonUtility.FromJson<SerializedDictionary>(value);
serializedDictionary.LoadIntoDictionary(m_bossKillLookup);
}
}
}
[Serializable]
internal class SerializedDictionary
{
public int[] keys;
public int[] values;
public SerializedDictionary(IDictionary<Type, int> dictionary)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected I4, but got Unknown
keys = new int[dictionary.Count];
values = new int[dictionary.Count];
int num = 0;
foreach (KeyValuePair<Type, int> item in dictionary)
{
keys[num] = (int)item.Key;
values[num] = item.Value;
num++;
}
}
public void LoadIntoDictionary(Dictionary<Type, int> dictionary)
{
for (int i = 0; i < keys.Length; i++)
{
dictionary.Add((Type)keys[i], values[i]);
}
}
}
}