using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Text; using BepInEx.Logging; using CsvHelper; using HarmonyLib; using I2.Loc; using Malee; using Microsoft.CodeAnalysis; using Microsoft.Extensions.Configuration; using MonoMod.Utils; using NVorbis; using RotaryHeart.Lib.SerializableDictionary; using ShinyShoe; using ShinyShoe.Audio; using ShinyShoe.Logging; using Spine; using Spine.Unity; using TMPro; using TrainworksReloaded.Base.Card; using TrainworksReloaded.Base.Extensions; using TrainworksReloaded.Base.Localization; using TrainworksReloaded.Base.Prefab; using TrainworksReloaded.Base.Trigger; using TrainworksReloaded.Core.Enum; using TrainworksReloaded.Core.Extensions; using TrainworksReloaded.Core.Impl; using TrainworksReloaded.Core.Interfaces; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.Rendering; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.ResourceManagement.Util; using UnityEngine.TextCore; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TrainworksReloaded.Base")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.7.17.0")] [assembly: AssemblyInformationalVersion("0.7.17+70425a1dcb597e90fd3db40c36bb4d19c1a44045")] [assembly: AssemblyProduct("TrainworksReloaded.Base")] [assembly: AssemblyTitle("TrainworksReloaded.Base")] [assembly: AssemblyVersion("0.7.17.0")] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlyList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Count; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Count; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Count; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyList(List items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return _items.Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { _items.CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return _items.IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TrainworksReloaded.Base { public class ProviderDetails { public bool IsInitialized { get; set; } public IProvider Provider { get; set; } public ProviderDetails(bool isInit, IProvider provider) { IsInitialized = isInit; Provider = provider; } } public class GameDataClient : Dictionary, IClient { public void NewProviderAvailable(IProvider newProvider) { base[((object)newProvider).GetType()] = new ProviderDetails(isInit: false, newProvider); } public void NewProviderFullyInstalled(IProvider newProvider) { if (ContainsKey(((object)newProvider).GetType())) { base[((object)newProvider).GetType()].IsInitialized = true; } } public void ProviderRemoved(IProvider removeProvider) { Remove(((object)removeProvider).GetType()); } public bool TryGetProvider([NotNullWhen(true)] out T? provider) where T : IProvider { bool fullyInitialized; return TryGetProvider(out provider, out fullyInitialized); } public bool TryGetProvider([NotNullWhen(true)] out T? provider, out bool fullyInitialized) where T : IProvider { if (TryGetValue(typeof(T), out ProviderDetails value)) { fullyInitialized = value.IsInitialized; provider = (T)(object)value.Provider; return true; } fullyInitialized = false; provider = default(T); return false; } } public class ModLoggerWrapper(Type type, object data) { private readonly Type type = type; private readonly object data = data; public override string ToString() { string text = DateTime.UtcNow.ToString("HH:mm:ss.ffffff"); return string.Format("{0,-32} {1}", "[" + text + "] [" + type.Name + "]", data); } } public class ModLogger(ManualLogSource manualLogSource) : IModLogger, ILogProvider { private readonly ManualLogSource manualLogSource = manualLogSource; public void CloseLog() { } public void Debug(string log, LogOptions options) { Log((LogLevel)32, log); } public void Error(string log, LogOptions options) { Log((LogLevel)2, log); } public void Info(string log, LogOptions options) { Log((LogLevel)16, log); } public void Log(LogLevel level, object data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) manualLogSource.Log((LogLevel)level, (object)new ModLoggerWrapper(typeof(T), data)); } public void Verbose(string log, LogOptions options) { Log((LogLevel)32, log); } public void Warning(string log, LogOptions options) { Log((LogLevel)4, log); } } public class ScriptableObjectInstanceGenerator : IInstanceGenerator where T : ScriptableObject, new() { public T CreateInstance() { return ScriptableObject.CreateInstance(); } } public static class TemplateConstants { public const string Effect = "Effect"; public const string Upgrade = "Upgrade"; public const string UpgradeMask = "UpgradeMask"; public const string Class = "Class"; public const string Card = "Card"; public const string Vfx = "Vfx"; public const string CardTrigger = "Trigger"; public const string Trait = "Trait"; public const string CharacterTrigger = "CTrigger"; public const string RoomModifier = "RoomModifier"; public const string CardPool = "CardPool"; public const string RelicPool = "RelicPool"; public const string EnhancerPool = "EnhancerPool"; public const string RewardData = "RewardData"; public const string MapNode = "MapNode"; public const string Sprite = "Sprite"; public const string GameObject = "GameObject"; public const string StatusEffect = "StatusEffect"; public const string CardTriggerEnum = "TriggerEnum"; public const string CharacterTriggerEnum = "CTriggerEnum"; public const string TargetModeEnum = "TargetModeEnum"; public const string RelicData = "RelicData"; public const string RelicEffectData = "RelicEffectData"; public const string Character = "Character"; public const string Chatter = "Chatter"; public const string Subtype = "Subtype"; public const string AdditionalTooltip = "AdditionalTooltip"; public const string RelicEffectCondition = "RelicEffectCondition"; public const string Scenario = "Scenario"; public const string Background = "Background"; public const string BossVariants = "BossVariants"; public const string TrialList = "TrialList"; public const string Trial = "Trial"; public const string SkeletonData = "SkeletonData"; public const string StatusEffectTriggerStageEnum = "StatusEffectTriggerStage"; public const string ClassCardStyle = "ClassCardStyle"; public const string TrackedValueTypeEnum = "TrackedValueTypeEnum"; public const string AudioClip = "AudioClip"; public const string SoundCueDefinition = "SoundCueDefinition"; public const string PyreHeart = "PyreHeart"; public const string SoulPool = "SoulPool"; public const string Challenge = "Challenge"; } } namespace TrainworksReloaded.Base.Trigger { public class CardTriggerEffectDefinition(string key, CardTriggerEffectData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CardTriggerEffectData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class CardTriggerEffectFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly IRegister effectRegister; private readonly IRegister upgradeRegister; private readonly IRegister triggerEnumRegister; private readonly ICache> cache; private readonly PluginAtlas atlas; public CardTriggerEffectFinalizer(PluginAtlas atlas, IModLogger logger, IRegister effectRegister, IRegister upgradeRegister, IRegister triggerEnumRegister, ICache> cache) { this.atlas = atlas; this.logger = logger; this.effectRegister = effectRegister; this.upgradeRegister = upgradeRegister; this.triggerEnumRegister = triggerEnumRegister; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeTrigger(cacheItem); } cache.Clear(); } private void FinalizeTrigger(IDefinition definition) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0117: 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) IConfiguration configuration = definition.Configuration; string key = definition.Key; CardTriggerEffectData data = definition.Data; logger.Log((LogLevel)16, (object)("Finalizing Card Trigger " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); CardTriggerType val = (CardTriggerType)0; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("trigger").ParseReference(); if (referencedObject != null && triggerEnumRegister.TryLookupId(referencedObject.ToId(key, "TriggerEnum"), out var lookup, out var IsModded, referencedObject.context)) { val = lookup; } AccessTools.Field(typeof(CardTriggerEffectData), "trigger").SetValue(data, val); List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("trigger_effects").GetChildren()) { CardTriggerData val2 = new CardTriggerData(); val2.persistenceMode = child.GetDeprecatedSection("persistence", "persistence_mode").ParsePersistenceMode().GetValueOrDefault(); val2.paramInt = ParseExtensions.ParseInt(child.GetSection("param_int")).GetValueOrDefault(); ParseReferenceExtensions.ReferencedObject referencedObject2 = child.GetSection("trigger_effect").ParseReference(); if (referencedObject2 == null) { continue; } string id = referencedObject2.id; string text = referencedObject2.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load trigger effect state name " + id + " in " + definition.Id + " with mod reference " + text + ". Make sure the class implements interface ICardTriggerEffect.")); continue; } val2.cardTriggerEffect = fullyQualifiedName; referencedObject2 = child.GetSection("buff_effect").ParseReference(); if (referencedObject2 == null) { continue; } string id2 = referencedObject2.id; text = referencedObject2.mod_reference ?? key; PluginDefinition valueOrDefault2 = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text, (PluginDefinition)null); assembly = ((valueOrDefault2 != null) ? valueOrDefault2.Assembly : null); if (!id.GetFullyQualifiedName(assembly, out fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load effect state name " + id2 + " in " + definition.Id + " with mod reference " + text + ". Make sure the class inherits from CardEffectBase.")); } else { val2.buffEffectType = fullyQualifiedName; ParseReferenceExtensions.ReferencedObject referencedObject3 = child.GetSection("param_upgrade").ParseReference(); if (referencedObject3 != null) { upgradeRegister.TryLookupName(referencedObject3.ToId(key, "Upgrade"), out CardUpgradeData lookup2, out IsModded, referencedObject3.context); val2.paramUpgrade = lookup2; } list.Add(val2); } } AccessTools.Field(typeof(CardTriggerEffectData), "cardTriggerEffects").SetValue(data, list); List list2 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id3 = item.ToId(key, "Effect"); if (effectRegister.TryLookupId(id3, out CardEffectData lookup3, out IsModded, item.context)) { list2.Add(lookup3); } } AccessTools.Field(typeof(CardTriggerEffectData), "cardEffects").SetValue(data, list2); } } public class CardTriggerEffectPipeline : IDataPipeline, CardTriggerEffectData> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; public CardTriggerEffectPipeline(PluginAtlas atlas, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadTriggers(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadTriggers(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("card_triggers").GetChildren()) { CardTriggerEffectDefinition cardTriggerEffectDefinition = LoadTriggerConfiguration(service, key, child); if (cardTriggerEffectDefinition != null) { list.Add(cardTriggerEffectDefinition); } } return list; } private CardTriggerEffectDefinition? LoadTriggerConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Trigger", text); string text2 = "CardTriggerEffectData_descriptionKey-" + id; CardTriggerEffectData val = new CardTriggerEffectData(); LocalizationTerm localizationTerm = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(CardTriggerEffectData), "descriptionKey").SetValue(val, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } bool valueOrDefault = ParseExtensions.ParseBool(configuration.GetSection("trigger_keyword_tooltip_suppressed")) == true; AccessTools.Field(typeof(CardTriggerEffectData), "triggerKeywordTooltipSuppressed").SetValue(val, valueOrDefault); bool valueOrDefault2 = ParseExtensions.ParseBool(configuration.GetSection("trigger_keyword_card_text_suppressed")) == true; AccessTools.Field(typeof(CardTriggerEffectData), "triggerKeywordCardTextSuppressed").SetValue(val, valueOrDefault2); ((IRegisterableDictionary)(object)service).Register(id, val); return new CardTriggerEffectDefinition(key, val, configuration) { Id = text }; } } public class CardTriggerEffectRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public CardTriggerEffectRegister(IModLogger logger) { this.logger = logger; } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((CardTriggerEffectData trigger) => trigger.GetDebugName()).ToList(); } public void Register(string key, CardTriggerEffectData item) { logger.Log((LogLevel)32, (object)("Register Card Trigger Effect (" + key + ")")); Add(key, item); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardTriggerEffectData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (CardTriggerEffectData value in base.Values) { if (value.GetDebugName() == identifier) { lookup = value; IsModded = true; return true; } } return false; } } public class CharacterTriggerDefinition(string key, CharacterTriggerData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CharacterTriggerData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class CharacterTriggerFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly IRegister effectRegister; private readonly IRegister triggerEnumRegister; private readonly IRegister statusRegister; private readonly ICache> cache; public CharacterTriggerFinalizer(IModLogger logger, IRegister effectRegister, IRegister triggerEnumRegister, IRegister statusRegister, ICache> cache) { this.logger = logger; this.effectRegister = effectRegister; this.triggerEnumRegister = triggerEnumRegister; this.statusRegister = statusRegister; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCharacterTrigger(cacheItem); } cache.Clear(); } private void FinalizeCharacterTrigger(IDefinition definition) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected O, but got Unknown IConfiguration configuration = definition.Configuration; string key = definition.Key; CharacterTriggerData data = definition.Data; logger.Log((LogLevel)16, (object)("Finalizing Character Trigger " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); Trigger val = (Trigger)0; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("trigger").ParseReference(); if (referencedObject != null && triggerEnumRegister.TryLookupId(referencedObject.ToId(key, "CTriggerEnum"), out var lookup, out var IsModded, referencedObject.context)) { val = lookup; } AccessTools.Field(typeof(CharacterTriggerData), "trigger").SetValue(data, val); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (effectRegister.TryLookupId(item.ToId(key, "Effect"), out CardEffectData lookup2, out IsModded, item.context)) { list.Add(lookup2); } } AccessTools.Field(typeof(CharacterTriggerData), "effects").SetValue(data, list); List list2 = data.GetRequiredStatusEffects() ?? new List(); foreach (IConfigurationSection child in configuration.GetSection("required_status_effects").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject2 = child.GetSection("status").ParseReference(); if (referencedObject2 != null) { string id = referencedObject2.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id, out StatusEffectData lookup3, out IsModded, referencedObject2.context)) { StatusEffectStackData val2 = new StatusEffectStackData { statusId = lookup3.GetStatusId(), count = ParseExtensions.ParseInt(child.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); val2.fromPermanentUpgrade = IsModded == true; list2.Add(val2); } } } AccessTools.Field(typeof(CharacterTriggerData), "requiredStatusEffects").SetValue(data, list2); List list3 = data.GetRequiredStatusEffectsForDyingCharacter() ?? new List(); foreach (IConfigurationSection child2 in configuration.GetSection("required_status_effects_for_dying_character").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject3 = child2.GetSection("status").ParseReference(); if (referencedObject3 != null) { string id2 = referencedObject3.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup4, out IsModded, referencedObject3.context)) { StatusEffectStackData val3 = new StatusEffectStackData { statusId = lookup4.GetStatusId(), count = ParseExtensions.ParseInt(child2.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child2.GetSection("from_permanent_upgrade")); val3.fromPermanentUpgrade = IsModded == true; list3.Add(val3); } } } AccessTools.Field(typeof(CharacterTriggerData), "requiredStatusEffectsForDyingCharacter").SetValue(data, list3); } } public class CharacterTriggerPipeline : IDataPipeline, CharacterTriggerData> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; public CharacterTriggerPipeline(PluginAtlas atlas, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadTriggers(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadTriggers(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("character_triggers").GetChildren()) { CharacterTriggerDefinition characterTriggerDefinition = LoadTriggerConfiguration(service, key, child); if (characterTriggerDefinition != null) { list.Add(characterTriggerDefinition); } } return list; } private CharacterTriggerDefinition? LoadTriggerConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("CTrigger", text); string text2 = "CharacterTriggerData_descriptionKey-" + id; string text3 = "CharacterTriggerData_textOnTriggerKey-" + id; CharacterTriggerData val = new CharacterTriggerData((Trigger)0, (CardEffectData)null); LocalizationTerm localizationTerm = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(CharacterTriggerData), "descriptionKey").SetValue(val, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetDeprecatedSection("text_on_trigger", "additional_text_on_trigger").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(CharacterTriggerData), "additionalTextOnTriggerKey").SetValue(val, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } bool flag = false; AccessTools.Field(typeof(CharacterTriggerData), "showAdditionalTriggerTextOnSuccessOnly").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("show_text_on_trigger_success_only", "show_additional_text_on_trigger_success_only")) ?? flag); bool flag2 = false; AccessTools.Field(typeof(CharacterTriggerData), "displayEffectHintText").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("display_hint_text", "display_effect_hint_text")) ?? flag2); bool flag3 = false; AccessTools.Field(typeof(CharacterTriggerData), "hideVisualAndIgnoreSilence").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("hide_tooltip", "hide_visual_and_ignore_silence")) ?? flag3); bool flag4 = false; AccessTools.Field(typeof(CharacterTriggerData), "allowAdditionalTooltipsWhenVisualIsHidden").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("allow_tooltips_when_hidden", "allow_additional_tooltips_when_visual_is_hidden")) ?? flag4); bool flag5 = false; AccessTools.Field(typeof(CharacterTriggerData), "suppressTriggerNotification").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("suppress_notifications")) ?? flag5); bool flag6 = false; AccessTools.Field(typeof(CharacterTriggerData), "triggerOnce").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("trigger_once")) ?? flag6); int num = 0; AccessTools.Field(typeof(CharacterTriggerData), "triggerAtThreshold").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("trigger_at_threshold")) ?? num); bool flag7 = false; AccessTools.Field(typeof(CharacterTriggerData), "onlyTriggerIfEquipped").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("only_trigger_if_equipped")) ?? flag7); bool flag8 = false; AccessTools.Field(typeof(CharacterTriggerData), "removeOnRelentlessChange").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_on_relentless_change")) ?? flag8); ((IRegisterableDictionary)(object)service).Register(id, val); return new CharacterTriggerDefinition(key, val, configuration) { Id = text }; } } public class CharacterTriggerRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public CharacterTriggerRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, CharacterTriggerData item) { logger.Log((LogLevel)32, (object)("Register Character Trigger (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((CharacterTriggerData trigger) => trigger.GetDebugName()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CharacterTriggerData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (CharacterTriggerData value in base.Values) { if (value.GetDebugName() == identifier) { lookup = value; IsModded = true; return true; } } return false; } } } namespace TrainworksReloaded.Base.Trait { public class CardTraitDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister upgradeRegister; private readonly IRegister cardRegister; private readonly IRegister statusRegister; private readonly IRegister subtypeRegister; private readonly IRegister trackedValueTypeRegister; public CardTraitDataFinalizer(IModLogger logger, ICache> cache, IRegister upgradeRegister, IRegister cardRegister, IRegister statusRegister, IRegister subtypeRegister, IRegister trackedValueTypeRegister) { this.logger = logger; this.cache = cache; this.upgradeRegister = upgradeRegister; this.cardRegister = cardRegister; this.statusRegister = statusRegister; this.subtypeRegister = subtypeRegister; this.trackedValueTypeRegister = trackedValueTypeRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardTrait(cacheItem); } cache.Clear(); } private void FinalizeCardTrait(IDefinition definition) { //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; CardTraitData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Card Trait " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetDeprecatedSection("param_card_data", "param_card").ParseReference(); CardData lookup = null; bool? IsModded; if (referencedObject != null) { cardRegister.TryLookupName(referencedObject.ToId(key, "Card"), out lookup, out IsModded, referencedObject.context); } AccessTools.Field(typeof(CardTraitData), "paramCardData").SetValue(data, lookup); ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("param_upgrade").ParseReference(); CardUpgradeData lookup2 = null; if (referencedObject2 != null) { string name = referencedObject2.ToId(key, "Upgrade"); upgradeRegister.TryLookupName(name, out lookup2, out IsModded, referencedObject2.context); } AccessTools.Field(typeof(CardTraitData), "paramCardUpgradeData").SetValue(data, lookup2); List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("param_status_effects").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject3 = child.GetSection("status").ParseReference(); if (referencedObject3 != null) { string id = referencedObject3.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id, out StatusEffectData lookup3, out IsModded, referencedObject3.context)) { StatusEffectStackData val = new StatusEffectStackData { statusId = lookup3.GetStatusId(), count = ParseExtensions.ParseInt(child.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); val.fromPermanentUpgrade = IsModded == true; list.Add(val); } } } AccessTools.Field(typeof(CardTraitData), "paramStatusEffects").SetValue(data, list.ToArray()); string value = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("param_subtype").ParseReference(); if (referencedObject4 != null && subtypeRegister.TryLookupId(referencedObject4.ToId(key, "Subtype"), out SubtypeData lookup4, out IsModded, referencedObject4.context)) { value = lookup4.Key; } AccessTools.Field(typeof(CardTraitData), "paramSubtype").SetValue(data, value); ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("param_tracked_value").ParseReference(); if (referencedObject5 != null) { string id2 = referencedObject5.ToId(key, "TrackedValueTypeEnum"); trackedValueTypeRegister.TryLookupId(id2, out var lookup5, out IsModded, referencedObject5.context); AccessTools.Field(typeof(CardTraitData), "paramTrackedValue").SetValue(data, lookup5); } } } public class CardTraitDataPipeline : IDataPipeline, CardTraitData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister localizationService; public CardTraitDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister localizationService) { this.atlas = atlas; this.logger = logger; this.localizationService = localizationService; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadTraits(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadTraits(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("traits").GetChildren()) { CardTraitDefinition cardTraitDefinition = LoadTraitConfiguration(service, key, child); if (cardTraitDefinition != null) { list.Add(cardTraitDefinition); } } return list; } private CardTraitDefinition? LoadTraitConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Trait", text); CardTraitData val = new CardTraitData(); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("name").ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text2 = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text2, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load trait state name " + id2 + " in " + text + " mod " + text2 + ", Make sure the class exists in " + text2 + " and that the class inherits from CardTraitState.")); return null; } AccessTools.Field(typeof(CardTraitData), "traitStateName").SetValue(val, fullyQualifiedName); CardTypeTarget val2 = (CardTypeTarget)0; AccessTools.Field(typeof(CardTraitData), "paramCardType").SetValue(val, configuration.GetDeprecatedSection("card_type", "param_card_type").ParseCardTypeTarget() ?? val2); EntryDuration val3 = (EntryDuration)0; AccessTools.Field(typeof(CardTraitData), "paramEntryDuration").SetValue(val, configuration.GetDeprecatedSection("entry_duraction", "param_entry_duration").ParseEntryDuration() ?? val3); string text3 = ""; AccessTools.Field(typeof(CardTraitData), "paramStr").SetValue(val, ParseExtensions.ParseString(configuration.GetSection("param_str")) ?? text3); LocalizationTerm localizationTerm = configuration.GetSection("param_description").ParseLocalizationTerm(); if (localizationTerm != null) { string value = (localizationTerm.Key = "CardTraitData_descriptionKey-" + id); ((IRegisterableDictionary)(object)localizationService).Register(localizationTerm.Key, localizationTerm); AccessTools.Field(typeof(CardTraitData), "paramDescription").SetValue(val, value); } int num = 0; AccessTools.Field(typeof(CardTraitData), "paramInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int")) ?? num); int num2 = 0; AccessTools.Field(typeof(CardTraitData), "paramInt2").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int_2")) ?? num2); int num3 = 0; AccessTools.Field(typeof(CardTraitData), "paramInt3").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int_3")) ?? num3); float num4 = 1f; AccessTools.Field(typeof(CardTraitData), "paramFloat").SetValue(val, ParseExtensions.ParseFloat(configuration.GetSection("param_float")) ?? num4); bool flag = false; AccessTools.Field(typeof(CardTraitData), "paramUseScalingParams").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_use_scaling_params")) ?? flag); bool flag2 = false; AccessTools.Field(typeof(CardTraitData), "paramBool").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_bool")) ?? flag2); bool flag3 = true; AccessTools.Field(typeof(CardTraitData), "traitIsRemovable").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("trait_is_removable")) ?? flag3); bool flag4 = false; AccessTools.Field(typeof(CardTraitData), "tooltipSuppressed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("tooltip_suppressed")) ?? flag4); bool flag5 = false; AccessTools.Field(typeof(CardTraitData), "effectTextSuppressed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("effect_text_suppressed")) ?? flag5); bool flag6 = false; AccessTools.Field(typeof(CardTraitData), "statusEffectTooltipsSuppressed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("status_effect_tooltips_suppressed")) ?? flag6); Type val4 = (Type)0; AccessTools.Field(typeof(CardTraitData), "paramTeamType").SetValue(val, configuration.GetSection("param_team").ParseTeamType() ?? val4); StackMode val5 = (StackMode)0; AccessTools.Field(typeof(CardTraitData), "stackMode").SetValue(val, configuration.GetSection("stack_mode").ParseStackMode() ?? val5); bool flag7 = false; AccessTools.Field(typeof(CardTraitData), "drawInDeploymentPhase").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("draw_in_deployment_phase")) ?? flag7); ((IRegisterableDictionary)(object)service).Register(id, val); return new CardTraitDefinition(key, val, configuration) { Id = text }; } } public class CardTraitDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public CardTraitDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, CardTraitData item) { logger.Log((LogLevel)32, (object)("Register Trait " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((CardTraitData trait) => trait.traitStateName).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardTraitData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (CardTraitData value in base.Values) { if (value.traitStateName == identifier) { lookup = value; IsModded = true; return true; } } return false; } } public class CardTraitDefinition(string key, CardTraitData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CardTraitData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } } namespace TrainworksReloaded.Base.Tooltips { public class AdditionalTooltipDefinition(string key, AdditionalTooltipData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public AdditionalTooltipData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class AdditionalTooltipPipeline : IDataPipeline, AdditionalTooltipData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; public AdditionalTooltipPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("additional_tooltips").GetChildren()) { IDefinition val = ProcessItem(service, key, child); if (val != null) { list.Add(val); } } } return list; } public IDefinition? ProcessItem(IRegister service, string key, IConfiguration configuration) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("AdditionalTooltip", text); AdditionalTooltipData val = new AdditionalTooltipData(); LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { string key2 = "AdditionalTooltipData_tooltipTitleKey-" + id; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm.Key)) { localizationTerm.Key = key2; } val.titleKey = localizationTerm.Key; if (localizationTerm.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { string key3 = "AdditionalTooltipData_tooltipDescriptionKey-" + id; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm2.Key)) { localizationTerm2.Key = key3; } val.descriptionKey = localizationTerm2.Key; if (localizationTerm2.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm2.Key, localizationTerm2); } } val.style = (TooltipDesignType)(((??)configuration.GetSection("style").ParseTooltipDesignType()) ?? 8); val.allowSecondaryPlacement = ParseExtensions.ParseBool(configuration.GetSection("allow_secondary_placement")) == true; val.hideInTrainRoomUI = ParseExtensions.ParseBool(configuration.GetSection("hide_in_train_room_ui")) == true; ((IRegisterableDictionary)(object)service).Register(id, val); return (IDefinition?)(object)new AdditionalTooltipDefinition(key, val, configuration) { Id = text }; } } public class AdditionalTooltipRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public AdditionalTooltipRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, AdditionalTooltipData item) { logger.Log((LogLevel)32, (object)("Register Additional Tooltip " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out AdditionalTooltipData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Subtype { public class SubtypeDataPipeline : IDataPipeline, SubtypeData> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; public SubtypeDataPipeline(PluginAtlas atlas, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; } public List> Run(IRegister service) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("subtypes").GetChildren()) { string text = ParseExtensions.ParseString(child.GetSection("id")); if (text != null) { LocalizationTerm localizationTerm = child.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { string id = key.GetId("Subtype", text); string text2 = "SubtytpesData_nameKey-" + id; SubtypeData val = new SubtypeData(); localizationTerm.Key = text2; ((IDictionary)termRegister).Add(text2, localizationTerm); AccessTools.Field(typeof(SubtypeData), "_subtype").SetValue(val, text2); ((IRegisterableDictionary)(object)service).Register(id, val); list.Add((IDefinition)(object)new SubtypeDefinition(key, val, child) { Id = text }); } } } } return list; } } public class SubtypeDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy SaveManager; public SubtypeDataRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.logger = logger; } public void Register(string key, SubtypeData item) { logger.Log((LogLevel)16, (object)("Register Subtype " + key + "...")); Add(key, item); SubtypeManager.AllData.Add(item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 List list = base.Keys.ToList(); if ((int)identifierType == 1) { List list2 = new List(); list2.AddRange(SubtypeManager.AllData.Select((SubtypeData subtype) => subtype.Key)); list.AddRange(new <>z__ReadOnlyList(list2)); } return list; } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out SubtypeData? lookup, [NotNullWhen(true)] out bool? IsModded) { lookup = null; IsModded = true; if (TryGetValue(identifier, out lookup)) { return true; } lookup = SubtypeManager.GetSubtypeData(identifier); IsModded = false; return lookup != null; } } public class SubtypeDefinition(string key, SubtypeData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public SubtypeData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } } namespace TrainworksReloaded.Base.StatusEffects { public class StatusEffectDataDefinition(string key, StatusEffectData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public StatusEffectData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class StatusEffectDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister vfxRegister; private readonly IRegister spriteRegister; private readonly IRegister triggerStageRegister; private readonly IRegister soundCueRegister; public StatusEffectDataFinalizer(IModLogger logger, ICache> cache, IRegister vfxRegister, IRegister spriteRegister, IRegister triggerStageRegister, IRegister soundCueRegister) { this.logger = logger; this.cache = cache; this.vfxRegister = vfxRegister; this.spriteRegister = spriteRegister; this.triggerStageRegister = triggerStageRegister; this.soundCueRegister = soundCueRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeStatusEffect(cacheItem); } cache.Clear(); } public void FinalizeStatusEffect(IDefinition definition) { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Expected O, but got Unknown //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Expected O, but got Unknown //IL_069c: Unknown result type (might be due to invalid IL or missing references) //IL_0745: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; StatusEffectData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing StatusEffect " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("icon").ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(StatusEffectData), "icon").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("added_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject2?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup2, out IsModded, referencedObject2?.context)) { AccessTools.Field(typeof(StatusEffectData), "addedVFX").SetValue(data, lookup2); } VfxAtLocList val = new VfxAtLocList(); List vfxList = val.GetVfxList(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("more_added_vfx").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (vfxRegister.TryLookupId(item.ToId(key, "Vfx"), out VfxAtLoc lookup3, out IsModded, item.context)) { vfxList.Add(lookup3); } } AccessTools.Field(typeof(StatusEffectData), "moreAddedVFX").SetValue(data, val); ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("persistent_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject3?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup4, out IsModded, referencedObject3?.context)) { AccessTools.Field(typeof(StatusEffectData), "persistentVFX").SetValue(data, lookup4); } VfxAtLocList val2 = new VfxAtLocList(); List vfxList2 = val2.GetVfxList(); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("more_persistent_vfx").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (vfxRegister.TryLookupId(item2.ToId(key, "Vfx"), out VfxAtLoc lookup5, out IsModded, item2.context)) { vfxList2.Add(lookup5); } } AccessTools.Field(typeof(StatusEffectData), "morePersistentVFX").SetValue(data, val2); ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("triggered_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject4?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup6, out IsModded, referencedObject4?.context)) { AccessTools.Field(typeof(StatusEffectData), "triggeredVFX").SetValue(data, lookup6); } VfxAtLocList val3 = new VfxAtLocList(); List vfxList3 = val3.GetVfxList(); foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in configuration.GetSection("more_triggered_vfx").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (vfxRegister.TryLookupId(item3.ToId(key, "Vfx"), out VfxAtLoc lookup7, out IsModded, item3.context)) { vfxList3.Add(lookup7); } } AccessTools.Field(typeof(StatusEffectData), "moreTriggeredVFX").SetValue(data, val3); ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("removed_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject5?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup8, out IsModded, referencedObject5?.context)) { AccessTools.Field(typeof(StatusEffectData), "removedVFX").SetValue(data, lookup8); } VfxAtLocList val4 = new VfxAtLocList(); List vfxList4 = val4.GetVfxList(); foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in configuration.GetSection("more_removed_vfx").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (vfxRegister.TryLookupId(item4.ToId(key, "Vfx"), out VfxAtLoc lookup9, out IsModded, item4.context)) { vfxList4.Add(lookup9); } } AccessTools.Field(typeof(StatusEffectData), "moreRemovedVFX").SetValue(data, val4); ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("affected_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject6?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup10, out IsModded, referencedObject6?.context)) { AccessTools.Field(typeof(StatusEffectData), "affectedVFX").SetValue(data, lookup10); } ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("trigger_stage").ParseReference(); if (referencedObject7 != null) { triggerStageRegister.TryLookupId(referencedObject7.ToId(key, "StatusEffectTriggerStage"), out var lookup11, out IsModded, referencedObject7.context); AccessTools.Field(typeof(StatusEffectData), "triggerStage").SetValue(data, lookup11); } List additionalTriggerStages = data.GetAdditionalTriggerStages(); foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in configuration.GetSection("additional_trigger_stages").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { triggerStageRegister.TryLookupId(item5.ToId(key, "StatusEffectTriggerStage"), out var lookup12, out IsModded, item5.context); additionalTriggerStages.Add(lookup12); } ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetSection("applied_sfx").ParseReference(); string value = ""; if (referencedObject8 != null) { soundCueRegister.TryLookupName(referencedObject8.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup13, out IsModded, referencedObject8.context); value = lookup13?.Name ?? string.Empty; } AccessTools.Field(typeof(StatusEffectData), "appliedSFXName").SetValue(data, value); ParseReferenceExtensions.ReferencedObject referencedObject9 = configuration.GetSection("triggered_sfx").ParseReference(); string value2 = ""; if (referencedObject9 != null) { soundCueRegister.TryLookupName(referencedObject9.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup14, out IsModded, referencedObject9.context); value2 = lookup14?.Name ?? string.Empty; } AccessTools.Field(typeof(StatusEffectData), "triggeredSFXName").SetValue(data, value2); } } public class StatusEffectDataPipeline : IDataPipeline, StatusEffectData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister replacementTextRegister; private readonly IRegister termRegister; public StatusEffectDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister replacementTextRegister, IRegister termRegister) { this.atlas = atlas; this.logger = logger; this.replacementTextRegister = replacementTextRegister; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadStatusEffects(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private IEnumerable> LoadStatusEffects(IRegister service, string key, IConfiguration configuration) { List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("status_effects").GetChildren()) { StatusEffectDataDefinition statusEffectDataDefinition = LoadEffectConfiguration(service, key, child); if (statusEffectDataDefinition != null) { list.Add(statusEffectDataDefinition); } } return (IEnumerable>)list; } private StatusEffectDataDefinition? LoadEffectConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("StatusEffect", text); StatusEffectData val = new StatusEffectData(); AccessTools.Field(typeof(StatusEffectData), "statusId").SetValue(val, id); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("class_name").ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text2 = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text2, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load status effect state name " + id2 + " in " + text + " mod " + text2 + ", Make sure the class exists in " + text2 + " and that the class inherits from StatusEffectState.")); return null; } AccessTools.Field(typeof(StatusEffectData), "statusEffectStateName").SetValue(val, fullyQualifiedName); string text3 = "StatusEffect_" + id; LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = text3 + "_CardText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("stackable_names").ParseLocalizationTerm(); if (localizationTerm2 != null) { localizationTerm2.Key = text3 + "_Stack_CardText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm2.Key, localizationTerm2); } LocalizationTerm localizationTerm3 = configuration.GetSection("card_tooltips").ParseLocalizationTerm(); if (localizationTerm3 != null) { localizationTerm3.Key = text3 + "_CardTooltipText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm3.Key, localizationTerm3); } LocalizationTerm localizationTerm4 = configuration.GetSection("character_tooltips").ParseLocalizationTerm(); if (localizationTerm4 != null) { localizationTerm4.Key = text3 + "_CharacterTooltipText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm4.Key, localizationTerm4); } LocalizationTerm localizationTerm5 = configuration.GetSection("notifications").ParseLocalizationTerm(); if (localizationTerm5 != null) { localizationTerm5.Key = text3 + "_NotificationText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm5.Key, localizationTerm5); } LocalizationTerm localizationTerm6 = configuration.GetSection("replacement_texts").ParseLocalizationTerm(); if (localizationTerm6 != null) { string text4 = key + "_" + text; string key2 = "ReplacementStringsData_replacement-" + text4; localizationTerm6.Key = key2; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm6.Key, localizationTerm6); ReplacementStringData val2 = new ReplacementStringData(); AccessTools.Field(typeof(ReplacementStringData), "_keyword").SetValue(val2, text4); AccessTools.Field(typeof(ReplacementStringData), "_replacement").SetValue(val2, localizationTerm6.Key); ((IRegisterableDictionary)(object)replacementTextRegister).Register(text4, val2); } DisplayCategory val3 = (DisplayCategory)0; AccessTools.Field(typeof(StatusEffectData), "displayCategory").SetValue(val, configuration.GetSection("display_category").ParseDisplayCategory() ?? val3); VFXDisplayType val4 = (VFXDisplayType)0; AccessTools.Field(typeof(StatusEffectData), "vfxDisplayType").SetValue(val, configuration.GetSection("vfx_display_type").ParseVFXDisplayType() ?? val4); bool flag = false; AccessTools.Field(typeof(StatusEffectData), "hidden").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("hidden")) ?? flag); bool flag2 = false; AccessTools.Field(typeof(StatusEffectData), "removeStackAtEndOfTurn").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_stack_at_end_of_turn")) ?? flag2); bool flag3 = false; AccessTools.Field(typeof(StatusEffectData), "removeAtEndOfTurnAfterPostCombat").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_at_end_of_turn_after_post_combat")) ?? flag3); bool flag4 = false; AccessTools.Field(typeof(StatusEffectData), "removeAtEndOfTurn").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_at_end_of_turn")) ?? flag4); bool flag5 = false; AccessTools.Field(typeof(StatusEffectData), "removeDuringDeployment").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_during_deployment")) ?? flag5); bool flag6 = false; AccessTools.Field(typeof(StatusEffectData), "removeWhenTriggered").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_when_triggered")) ?? flag6); bool flag7 = false; AccessTools.Field(typeof(StatusEffectData), "removeWhenTriggeredAfterCardPlayed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_when_triggered_after_card_played")) ?? flag7); bool flag8 = false; AccessTools.Field(typeof(StatusEffectData), "removeAtEndOfTurnIfTriggered").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("remove_at_end_of_turn_if_triggered")) ?? flag8); bool flag9 = true; AccessTools.Field(typeof(StatusEffectData), "isStackable").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("is_stackable")) ?? flag9); bool flag10 = false; AccessTools.Field(typeof(StatusEffectData), "isPropagatable").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("is_propagatable")) ?? flag10); bool flag11 = true; AccessTools.Field(typeof(StatusEffectData), "scalesInEndless").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("scales_in_endless")) ?? flag11); bool flag12 = false; AccessTools.Field(typeof(StatusEffectData), "skipTriggerDuringDeployment").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("skip_trigger_during_deployment")) ?? flag12); bool flag13 = false; AccessTools.Field(typeof(StatusEffectData), "excludeHeroPropagation").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_hero_propagation")) ?? flag13); bool flag14 = false; AccessTools.Field(typeof(StatusEffectData), "excludeMonsterPropagation").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_monster_propagation")) ?? flag14); bool flag15 = true; AccessTools.Field(typeof(StatusEffectData), "showStackCount").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("show_stack_count")) ?? flag15); bool flag16 = true; AccessTools.Field(typeof(StatusEffectData), "showNotificationsOnRemoval").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("show_notifications_on_removal")) ?? flag16); bool flag17 = false; AccessTools.Field(typeof(StatusEffectData), "showOnPyreHeart").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("show_on_pyre_heart")) ?? flag17); string text5 = ""; AccessTools.Field(typeof(StatusEffectData), "paramStr").SetValue(val, ParseExtensions.ParseString(configuration.GetSection("param_str")) ?? text5); int num = 0; AccessTools.Field(typeof(StatusEffectData), "paramInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int")) ?? num); int num2 = 0; AccessTools.Field(typeof(StatusEffectData), "paramSecondaryInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetDeprecatedSection("param_secondary_int", "param_int_2")) ?? num2); float num3 = 0f; AccessTools.Field(typeof(StatusEffectData), "paramFloat").SetValue(val, ParseExtensions.ParseFloat(configuration.GetSection("param_float")) ?? num3); bool flag18 = false; AccessTools.Field(typeof(StatusEffectData), "allowSecondaryTooltipPlacement").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("allow_secondary_tooltip_placement")) ?? flag18); bool flag19 = false; AccessTools.Field(typeof(StatusEffectData), "allowSecondaryUIPlacement").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("allow_secondary_ui_placement")) ?? flag19); ((IRegisterableDictionary)(object)service).Register(id, val); return new StatusEffectDataDefinition(key, val, configuration) { Id = id }; } } public class StatusEffectDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public StatusEffectDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, StatusEffectData item) { logger.Log((LogLevel)16, (object)("Register Status Effect (" + key + ")")); StatusEffectManager.Instance.GetAllStatusEffectsData().GetStatusEffectData().Add(item); StatusEffectManager.StatusIdToLocalizationExpression.Add(item.GetStatusId(), "StatusEffect_" + item.GetStatusId()); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from effect in StatusEffectManager.Instance.GetAllStatusEffectsData().GetStatusEffectData() select effect.GetStatusId()).ToList(); } return new List(); } return (from effect in StatusEffectManager.Instance.GetAllStatusEffectsData().GetStatusEffectData() select effect.GetStatusId()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out StatusEffectData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 lookup = null; identifier = identifier.ToLowerInvariant(); IsModded = ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (StatusEffectData statusEffectDatum in StatusEffectManager.Instance.GetAllStatusEffectsData().GetStatusEffectData()) { if (statusEffectDatum.GetStatusId() == identifier) { lookup = statusEffectDatum; return true; } } return false; } return false; } foreach (StatusEffectData statusEffectDatum2 in StatusEffectManager.Instance.GetAllStatusEffectsData().GetStatusEffectData()) { if (statusEffectDatum2.GetStatusId() == identifier) { lookup = statusEffectDatum2; return true; } } return false; } } } namespace TrainworksReloaded.Base.Sound { public class AudioClipPipeline : IDataPipeline, AudioClip> { private readonly PluginAtlas atlas; private readonly IModLogger logger; public AudioClipPipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { List> result = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("audio_clips").GetChildren()) { string value = child.GetSection("id").Value; string value2 = child.GetSection("path").Value; if (value2 == null || value == null || (!value2.EndsWith(".wav") && !value2.EndsWith(".ogg"))) { continue; } string id = key.GetId("AudioClip", value); foreach (string assetDirectory in pluginDefinition.Value.AssetDirectories) { string text = Path.Combine(assetDirectory, value2); if (!File.Exists(text)) { logger.Log((LogLevel)4, (object)("Could not find asset at path: " + text + ". Sprite will not exist.")); continue; } AudioClip val = ((!value2.EndsWith(".wav")) ? LoadOggFile(text) : LoadWavFile(text)); if ((Object)(object)val == (Object)null) { continue; } ((Object)val).name = id; ((IRegisterableDictionary)(object)service).Register(id, val); break; } } } return result; } private AudioClip? LoadWavFile(string path) { byte[] array = File.ReadAllBytes(path); int pos = 0; if (ReadString(array, ref pos, 4) != "RIFF") { logger.Log((LogLevel)2, (object)("Invalid WAV file " + path + ": RIFF header not found.")); return null; } pos += 4; if (ReadString(array, ref pos, 4) != "WAVE") { logger.Log((LogLevel)2, (object)("Invalid WAV file " + path + ": WAVE header not found.")); return null; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; bool flag = false; bool flag2 = false; while (pos < array.Length) { string text = ReadString(array, ref pos, 4); int num6 = BitConverter.ToInt32(array, pos); pos += 4; if (text == "fmt ") { flag = true; int num7 = BitConverter.ToInt16(array, pos); pos += 2; num = BitConverter.ToInt16(array, pos); pos += 2; num2 = BitConverter.ToInt32(array, pos); pos += 4; pos += 6; num3 = BitConverter.ToInt16(array, pos); pos += 2; if (num7 != 1) { logger.Log((LogLevel)2, (object)$"Invalid WAV file {path}: WAV format {num7} not supported. Only PCM supported."); return null; } if (num3 != 16) { logger.Log((LogLevel)2, (object)$"Invalid WAV file {path}: Only 16-bit PCM WAV supported. Got {num3}-bit."); return null; } pos = pos - 16 + num6; } else { if (text == "data") { flag2 = true; num5 = num6; num4 = pos; break; } pos += num6; } } if (!flag) { logger.Log((LogLevel)2, (object)("Invalid WAV file " + path + ": Missing fmt chunk.")); return null; } if (!flag2) { logger.Log((LogLevel)2, (object)("Invalid WAV file " + path + ": Missing data chunk.")); return null; } int num8 = num5 / 2; float[] array2 = new float[num8]; int num9 = num4; for (int i = 0; i < num8; i++) { array2[i] = (float)BitConverter.ToInt16(array, num9 + i * 2) / 32768f; } AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num8 / num, num, num2, false); obj.SetData(array2, 0); return obj; } private static string ReadString(byte[] data, ref int pos, int length) { string result = Encoding.ASCII.GetString(data, pos, length); pos += length; return result; } public AudioClip? LoadOggFile(string path) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown try { using MemoryStream memoryStream = new MemoryStream(File.ReadAllBytes(path)); VorbisReader val = new VorbisReader((Stream)memoryStream, false); try { int channels = val.Channels; int sampleRate = val.SampleRate; int num = (int)val.TotalSamples; float[] array = new float[num * channels]; val.ReadSamples(array, 0, array.Length); AudioClip obj = AudioClip.Create(Path.GetFileNameWithoutExtension(path), num, channels, sampleRate, false); obj.SetData(array, 0); return obj; } finally { ((IDisposable)val)?.Dispose(); } } catch (Exception ex) { logger.Log((LogLevel)2, (object)("Could not load ogg file " + path + ", " + ex.Message + ". Only Vorbis ogg files are supported.")); return null; } } } public class AudioClipRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public AudioClipRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, AudioClip item) { logger.Log((LogLevel)16, (object)("Register AudioClip (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((AudioClip clip) => ((Object)clip).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out AudioClip? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (AudioClip value in base.Values) { if (((Object)value).name == identifier) { lookup = value; IsModded = true; return true; } } return false; } } public class GlobalSoundCueDelegator { internal List GlobalSounds = new List(); public void Add(SoundCueDefinition soundCueDataDefinition) { GlobalSounds.Add(soundCueDataDefinition); } public IReadOnlyList GetSounds() { return GlobalSounds; } } public class SoundCueDataDefinition(string key, SoundCueDefinition data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public SoundCueDefinition Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class SoundCueFinalizer : IDataFinalizer { private readonly IRegister audioClipRegister; private readonly IModLogger logger; private readonly ICache> cache; public SoundCueFinalizer(IRegister audioClipRegister, IModLogger logger, ICache> cache) { this.audioClipRegister = audioClipRegister; this.logger = logger; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeItem(cacheItem); } cache.Clear(); } private void FinalizeItem(IDefinition definition) { IConfiguration configuration = definition.Configuration; SoundCueDefinition data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Sound Effect " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); IEnumerable enumerable = (from x in configuration.GetSection("clips").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in enumerable) { if (audioClipRegister.TryLookupId(item.ToId(key, "AudioClip"), out AudioClip lookup, out bool? _, item.context)) { list.Add(lookup); } } data.Clips = list.ToArray(); } } public class SoundCuePipeline : IDataPipeline, SoundCueDefinition> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly GlobalSoundCueDelegator globalSoundDelegator; public SoundCuePipeline(PluginAtlas atlas, IModLogger logger, GlobalSoundCueDelegator globalSoundDelegator) { this.atlas = atlas; this.logger = logger; this.globalSoundDelegator = globalSoundDelegator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadItems(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private IEnumerable> LoadItems(IRegister service, string key, IConfiguration configuration) { List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("sound_effects").GetChildren()) { SoundCueDataDefinition soundCueDataDefinition = LoadConfiguration(service, key, child); if (soundCueDataDefinition != null) { list.Add(soundCueDataDefinition); } } return (IEnumerable>)list; } private SoundCueDataDefinition? LoadConfiguration(IRegister service, string key, IConfigurationSection configuration) { //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown string text = ParseExtensions.ParseString(configuration.GetSection("id")); string text2 = ParseExtensions.ParseString(configuration.GetSection("name")); bool flag = configuration.GetSection("clips").Exists(); bool valueOrDefault = ParseExtensions.ParseBool(configuration.GetSection("global")) == true; if (text == null || !flag) { logger.Log((LogLevel)2, (object)(configuration.Path + " missing one or more required properties (id, clips)")); return null; } if (text2 == null && !valueOrDefault) { logger.Log((LogLevel)2, (object)("Non-global " + configuration.Path + " missing required property (name)")); return null; } string id = key.GetId("SoundCueDefinition", text); float volumeMin = ParseExtensions.ParseFloat(configuration.GetSection("volume_min")) ?? 1f; float volumeMax = ParseExtensions.ParseFloat(configuration.GetSection("volume_max")) ?? 1f; float pitchMin = ParseExtensions.ParseFloat(configuration.GetSection("pitch_min")) ?? 1f; float pitchMax = ParseExtensions.ParseFloat(configuration.GetSection("pitch_max")) ?? 1f; bool valueOrDefault2 = ParseExtensions.ParseBool(configuration.GetSection("loop")) == true; string[] tags = (from x in configuration.GetSection("tags").GetChildren() select ParseExtensions.ParseString(x) into x where x != null select x).Cast().ToArray(); SoundCueDefinition val = new SoundCueDefinition { Name = (valueOrDefault ? id : text2), VolumeMin = volumeMin, VolumeMax = volumeMax, PitchMin = pitchMin, PitchMax = pitchMax, Loop = valueOrDefault2, Tags = tags }; ((IRegisterableDictionary)(object)service).Register(id, val); if (valueOrDefault) { globalSoundDelegator.Add(val); } return new SoundCueDataDefinition(key, val, configuration) { Id = text }; } } public class SoundCueRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy soundEffectData; public SoundCueRegister(IModLogger logger, GameDataClient client) { this.logger = logger; soundEffectData = new Lazy((Func)delegate { if (client.TryGetProvider(out SoundManager provider)) { object? value = AccessTools.Field(typeof(SoundManager), "audioSystem").GetValue(provider); CoreAudioSystem obj = (CoreAudioSystem)((value is CoreAudioSystem) ? value : null); object? value2 = AccessTools.Field(typeof(CoreAudioSystem), "AudioSystemData").GetValue(obj); return ((CoreAudioSystemData)(((value2 is CoreAudioSystemData) ? value2 : null)?)).GlobalSoundEffectData; } return (CoreSoundEffectData?)null; }); } public void Register(string key, SoundCueDefinition item) { logger.Log((LogLevel)16, (object)("Register SoundCueDefinition (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out SoundCueDefinition? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; SoundCueDefinition[] sounds; if ((int)identifierType != 0) { if ((int)identifierType == 1) { if (TryGetValue(identifier, out lookup)) { return true; } if ((Object)(object)soundEffectData.Value == (Object)null) { return false; } sounds = soundEffectData.Value.Sounds; foreach (SoundCueDefinition val in sounds) { if (val.Name == identifier) { lookup = val; IsModded = false; return true; } } return false; } return false; } if (TryGetValue(identifier, out lookup)) { return true; } if ((Object)(object)soundEffectData.Value == (Object)null) { return false; } sounds = soundEffectData.Value.Sounds; foreach (SoundCueDefinition val2 in sounds) { if (val2.Name == identifier) { lookup = val2; IsModded = false; return true; } } return false; } public void RegisterGlobalSoundEffects(IReadOnlyList sounds) { CoreSoundEffectData value = soundEffectData.Value; if (!IEnumerableUtility.IsNullOrEmpty((IEnumerable)sounds) && !((Object)(object)value == (Object)null)) { List list = value.Sounds.ToList(); list.AddRange(sounds); value.Sounds = list.ToArray(); } } } } namespace TrainworksReloaded.Base.Trials { public class TrialDataDefinition(string key, TrialData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public TrialData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class TrialDataPipeline : IDataPipeline, TrialData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; public TrialDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadTrials(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private IEnumerable> LoadTrials(IRegister service, string key, IConfiguration configuration) { List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("trials").GetChildren()) { TrialDataDefinition trialDataDefinition = LoadConfiguration(service, key, child); if (trialDataDefinition != null) { list.Add(trialDataDefinition); } } return (IEnumerable>)list; } private TrialDataDefinition? LoadConfiguration(IRegister service, string key, IConfiguration configuration) { string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Trial", text); TrialData val = ScriptableObject.CreateInstance(); ((Object)val).name = id; Guid guidDeterministic = guidProvider.GetGuidDeterministic(id); AccessTools.Field(typeof(TrialData), "id").SetValue(val, guidDeterministic.ToString()); ((IRegisterableDictionary)(object)service).Register(id, val); return new TrialDataDefinition(key, val, configuration) { Id = text, IsModded = true }; } } public class TrialDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Trials; public TrialDataRegister(GameDataClient client, IModLogger logger) { Trials = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? ((AccessTools.Field(typeof(AllGameData), "trialDatas").GetValue(provider.GetAllGameData()) as List) ?? new List()) : new List()); this.logger = logger; } public void Register(string key, TrialData item) { logger.Log((LogLevel)16, (object)("Register Trial (" + key + ")")); Trials.Value.Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return Trials.Value.Select((TrialData Trial) => ((GameData)Trial).GetID()).ToList(); } return new List(); } return Trials.Value.Select((TrialData Trial) => ((Object)Trial).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out TrialData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = false; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (TrialData item in Trials.Value) { if (((GameData)item).GetID() == identifier) { lookup = item; IsModded = ContainsKey(((Object)item).name); return true; } } return false; } return false; } foreach (TrialData item2 in Trials.Value) { if (((Object)item2).name == identifier) { lookup = item2; IsModded = ContainsKey(((Object)item2).name); return true; } } return false; } } } namespace TrainworksReloaded.Base.Scenarios { public class BackgroundRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Backgrounds; public BackgroundRegister(GameDataClient client, IModLogger logger) { Backgrounds = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? ((AccessTools.Field(typeof(AllGameData), "backgroundDatas").GetValue(provider.GetAllGameData()) as List) ?? new List()) : new List()); this.logger = logger; } public void Register(string key, BackgroundData item) { logger.Log((LogLevel)32, (object)("Register Background (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out BackgroundData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { if (TryGetValue(identifier, out lookup)) { return true; } foreach (BackgroundData item in Backgrounds.Value) { if (item.GetAssetKey() == identifier) { IsModded = false; lookup = item; return true; } } lookup = GetDefault(); IsModded = false; return (Object)(object)lookup != (Object)null; } return false; } if (TryGetValue(identifier, out lookup)) { return true; } foreach (BackgroundData item2 in Backgrounds.Value) { if (item2.GetAssetKey() == identifier) { IsModded = false; lookup = item2; return true; } } lookup = GetDefault(); IsModded = false; return (Object)(object)lookup != (Object)null; } private BackgroundData? GetDefault() { foreach (BackgroundData item in Backgrounds.Value) { if (item.GetAssetKey() == "CaveBackgroundData") { return item; } } return null; } } public class BossVariantSpawnRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Scenarios; private readonly Lazy BossVariantField; public BossVariantSpawnRegister(GameDataClient client, IModLogger logger) { Scenarios = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? provider.GetAllGameData().GetAllScenarioDatas() : Array.Empty()); BossVariantField = new Lazy(() => AccessTools.Field(typeof(ScenarioData), "bossVariant")); this.logger = logger; } public void Register(string key, BossVariantSpawnData item) { logger.Log((LogLevel)32, (object)("Register BossVariantSpawnData (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out BossVariantSpawnData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (ScenarioData item in Scenarios.Value) { object? value = BossVariantField.Value.GetValue(item); BossVariantSpawnData val = (BossVariantSpawnData)((value is BossVariantSpawnData) ? value : null); if (((val != null) ? ((Object)val).name : null) == identifier) { lookup = val; IsModded = false; } } return TryGetValue(identifier, out lookup); } return false; } foreach (ScenarioData item2 in Scenarios.Value) { object? value2 = BossVariantField.Value.GetValue(item2); BossVariantSpawnData val2 = (BossVariantSpawnData)((value2 is BossVariantSpawnData) ? value2 : null); if (((val2 != null) ? ((Object)val2).name : null) == identifier) { lookup = val2; IsModded = false; } } return TryGetValue(identifier, out lookup); } } public class ScenarioDefinition(string key, ScenarioData data, ScenarioData copyData, OverrideMode overrideMode, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public ScenarioData Data { get; set; } = data; public ScenarioData CopyData { get; set; } = copyData; public OverrideMode OverrideMode { get; set; } = overrideMode; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class ScenarioDelegator { public struct ScenarioEntry { public int Distance { get; set; } public string RunType { get; set; } public ScenarioData Scenario { get; set; } } public List Scenarios = new List(); public void Add(ScenarioData data, int distance, string run_type) { Scenarios.Add(new ScenarioEntry { Scenario = data, Distance = distance, RunType = run_type }); } } public class ScenarioDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister gameObjectRegister; private readonly IRegister characterRegister; private readonly IRegister relicRegister; private readonly IRegister cardRegister; private readonly IRegister backgroundRegister; private readonly IRegister bossVariantRegister; private readonly IRegister trialListRegister; private readonly IRegister termRegister; private readonly IRegister soundCueRegister; private readonly IRegister subtypeRegister; private readonly Lazy saveManager; public ScenarioDataFinalizer(IModLogger logger, ICache> cache, GameDataClient client, IRegister spriteRegister, IRegister gameObjectRegister, IRegister characterRegister, IRegister relicRegister, IRegister cardRegister, IRegister backgroundRegister, IRegister bossVariantRegister, IRegister trialListRegister, IRegister soundCueRegister, IRegister termRegister, IRegister subtypeRegister) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.gameObjectRegister = gameObjectRegister; this.characterRegister = characterRegister; this.relicRegister = relicRegister; this.cardRegister = cardRegister; this.backgroundRegister = backgroundRegister; this.bossVariantRegister = bossVariantRegister; this.trialListRegister = trialListRegister; this.termRegister = termRegister; this.soundCueRegister = soundCueRegister; this.subtypeRegister = subtypeRegister; saveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeScenario(cacheItem); } cache.Clear(); } public void FinalizeScenario(IDefinition definition) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Invalid comparison between Unknown and I4 //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Invalid comparison between Unknown and I4 //IL_04ee: Unknown result type (might be due to invalid IL or missing references) //IL_07be: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Invalid comparison between Unknown and I4 //IL_0905: Unknown result type (might be due to invalid IL or missing references) //IL_0908: Invalid comparison between Unknown and I4 //IL_09f5: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; ScenarioData data = definition.Data; ScenarioData val = data; string key = definition.Key; OverrideMode val2 = configuration.GetSection("override").ParseOverrideMode(); logger.Log((LogLevel)16, (object)("Finalizing Scenario " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("boss_icon").ParseReference(); AccessTools.Field(typeof(ScenarioData), "bossIcon").SetValue(data, val.GetBossIcon()); bool? IsModded; if (referencedObject != null) { spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out IsModded, referencedObject.context); AccessTools.Field(typeof(ScenarioData), "bossIcon").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("boss_portrait").ParseReference(); AccessTools.Field(typeof(ScenarioData), "bossPortrait").SetValue(data, val.GetBossPortrait()); if (referencedObject2 != null) { spriteRegister.TryLookupId(referencedObject2.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, referencedObject2.context); AccessTools.Field(typeof(ScenarioData), "bossPortrait").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("titan_trial").ParseReference(); AccessTools.Field(typeof(ScenarioData), "titanTrialSin").SetValue(data, val.GetTitanTrialSin()); if (referencedObject3 != null) { string text = referencedObject3.ToId(key, "RelicData"); relicRegister.TryLookupId(text, out RelicData lookup3, out IsModded, referencedObject3.context); if (!(lookup3 is SinsData)) { logger.Log((LogLevel)4, (object)("Enemy blessing given " + text + " is not a SinsData. Behavior may not be correct.")); } AccessTools.Field(typeof(ScenarioData), "titanTrialSin").SetValue(data, lookup3); } ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("background").ParseReference(); AccessTools.Field(typeof(ScenarioData), "backgroundData").SetValue(data, val.GetBackgroundData()); if (OverrideModeExtensions.IsNewContent(val2) || referencedObject4 != null) { string id = referencedObject4?.ToId(key, "Background") ?? ""; backgroundRegister.TryLookupId(id, out BackgroundData lookup4, out IsModded, referencedObject4?.context); AccessTools.Field(typeof(ScenarioData), "backgroundData").SetValue(data, lookup4); } ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("trials").ParseReference(); AccessTools.Field(typeof(ScenarioData), "trials").SetValue(data, val.GetTrialDataList()); if (referencedObject5 != null) { string id2 = referencedObject5.ToId(key, "TrialList"); trialListRegister.TryLookupId(id2, out TrialDataList lookup5, out IsModded, referencedObject5.context); AccessTools.Field(typeof(ScenarioData), "trials").SetValue(data, lookup5); } ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("boss_spawn_sfx_cue").ParseReference(); AccessTools.Field(typeof(ScenarioData), "bossSpawnSFXCue").SetValue(data, val.GetBossSpawnSFXCue()); if (referencedObject6 != null) { soundCueRegister.TryLookupName(referencedObject6.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup6, out IsModded, referencedObject6.context); AccessTools.Field(typeof(ScenarioData), "bossSpawnSFXCue").SetValue(data, lookup6?.Name ?? ""); } List list = (AccessTools.Field(typeof(ScenarioData), "displayedEnemies").GetValue(val) as List) ?? new List(); List list2 = val.GetDisplayedEnemyOffsets() ?? new List(); IConfigurationSection section = configuration.GetSection("displayed_enemies"); if ((Object)(object)val != (Object)(object)data) { list = list.ToList(); list2 = list2.ToList(); } if ((int)val2 == 1 && section.Exists()) { list.Clear(); list2.Clear(); } Vector2 item = default(Vector2); foreach (IConfigurationSection child in section.GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject7 = child.GetSection("character").ParseReference(); if (referencedObject7 != null && characterRegister.TryLookupName(referencedObject7.ToId(key, "Character"), out CharacterData lookup7, out IsModded, referencedObject7.context)) { IConfigurationSection section2 = configuration.GetSection("offset"); ((Vector2)(ref item))..ctor(0f, 0f); if (section2 != null) { item.x = ParseExtensions.ParseInt(section2.GetSection("x")).GetValueOrDefault(); item.y = ParseExtensions.ParseInt(section2.GetSection("y")).GetValueOrDefault(); } list.Add(lookup7); list2.Add(item); } } AccessTools.Field(typeof(ScenarioData), "displayedEnemies").SetValue(data, list); AccessTools.Field(typeof(ScenarioData), "displayedEnemyOffsets").SetValue(data, list2); List list3 = val.GetFtueCardDrawData(); ReorderableArray val3 = AccessTools.Field(typeof(ScenarioData), "ftueCardDrawData").GetValue(data) as ReorderableArray; if ((Object)(object)val != (Object)(object)data) { list3 = list3.ToList(); } IConfigurationSection section3 = configuration.GetSection("ftue_card_draws"); if ((int)val2 == 1 && section3.Exists()) { list3.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in section3.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (cardRegister.TryLookupName(item2.ToId(key, "Card"), out CardData lookup8, out IsModded, item2.context)) { list3.Add(lookup8); } } val3.CopyFrom((IEnumerable)list3); AccessTools.Field(typeof(ScenarioData), "ftueCardDrawData").SetValue(data, val3); ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetSection("prefab").ParseReference(); AccessTools.Field(typeof(ScenarioData), "mapNodePrefab").SetValue(data, val.GetMapNodePrefab()); if (referencedObject8 != null) { string id3 = referencedObject8.ToId(key, "GameObject"); gameObjectRegister.TryLookupId(id3, out GameObject lookup9, out IsModded, referencedObject8.context); AccessTools.Field(typeof(ScenarioData), "mapNodePrefab").SetValue(data, lookup9); } IConfigurationSection section4 = configuration.GetSection("boss_variants"); ParseReferenceExtensions.ReferencedObject referencedObject9 = section4.ParseReference(); BossVariantSpawnData lookup10 = null; if ((Object)(object)val != (Object)(object)data && !section4.Exists()) { object? value = AccessTools.Field(typeof(ScenarioData), "bossVariant").GetValue(val); lookup10 = (BossVariantSpawnData)((value is BossVariantSpawnData) ? value : null); } if (referencedObject9 != null) { string name = referencedObject9.ToId(key, "BossVariants"); bossVariantRegister.TryLookupName(name, out lookup10, out IsModded, referencedObject9.context); } AccessTools.Field(typeof(ScenarioData), "bossVariant").SetValue(data, lookup10); List list4 = val.GetEnemyRelicData()?.ToList() ?? new List(); if ((Object)(object)val != (Object)(object)data) { list4 = list4.ToList(); } IConfigurationSection section5 = configuration.GetSection("enemy_blessings"); if ((int)val2 == 1 && section5.Exists()) { list4.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in section5.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string text2 = item3.ToId(key, "RelicData"); if (relicRegister.TryLookupName(text2, out RelicData lookup11, out IsModded, item3.context)) { if (!(lookup11 is SinsData)) { logger.Log((LogLevel)4, (object)("Enemy blessing given " + text2 + " is not a SinsData. Behavior may not be correct.")); } list4.Add(lookup11); } } AccessTools.Field(typeof(ScenarioData), "enemyBlessingData").SetValue(data, list4.ToArray()); List list5 = val.GetTreasureCharacterPool()?.ToList() ?? new List(); if ((Object)(object)val != (Object)(object)data) { list5 = list5.ToList(); } IConfigurationSection section6 = configuration.GetSection("treasure_character_pool"); if ((int)val2 == 1 && section6.Exists()) { list5.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in section6.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (characterRegister.TryLookupName(item4.ToId(key, "Character"), out CharacterData lookup12, out IsModded, item4.context)) { list5.Add(lookup12); } } AccessTools.Field(typeof(ScenarioData), "treasureCharacterPool").SetValue(data, list5.ToArray()); ParseSpawnPattern(configuration.GetSection("spawn_pattern"), key, data, val, val2); } private void ParseSpawnPattern(IConfiguration configuration, string key, ScenarioData scenario, ScenarioData copyScenario, OverrideMode overrideMode) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) SpawnPatternData val = (SpawnPatternData)(((object)scenario.GetSpawnPattern()) ?? ((object)new SpawnPatternData())); AccessTools.Field(typeof(ScenarioData), "spawnPattern").SetValue(scenario, val); SpawnPatternData spawnPattern = copyScenario.GetSpawnPattern(); IConfigurationSection section = configuration.GetSection("boss_character"); AccessTools.Field(typeof(SpawnPatternData), "bossCharacter").SetValue(val, spawnPattern.GetOuterTrainBossCharacter(false)); ParseReferenceExtensions.ReferencedObject referencedObject = section.ParseReference(); bool? IsModded; if (referencedObject != null) { characterRegister.TryLookupName(referencedObject.ToId(key, "Character"), out CharacterData lookup, out IsModded, referencedObject.context); AccessTools.Field(typeof(SpawnPatternData), "bossCharacter").SetValue(val, lookup); } IConfigurationSection section2 = configuration.GetSection("hard_boss_character"); object value = AccessTools.Field(typeof(SpawnPatternData), "hardBossCharacter").GetValue(spawnPattern); AccessTools.Field(typeof(SpawnPatternData), "hardBossCharacter").SetValue(val, value); ParseReferenceExtensions.ReferencedObject referencedObject2 = section2.ParseReference(); if (referencedObject2 != null) { characterRegister.TryLookupName(referencedObject2.ToId(key, "Character"), out CharacterData lookup2, out IsModded, referencedObject2.context); AccessTools.Field(typeof(SpawnPatternData), "hardBossCharacter").SetValue(val, lookup2); } bool isLoopingScenario = spawnPattern.GetIsLoopingScenario(); AccessTools.Field(typeof(SpawnPatternData), "isLoopingScenario").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("is_looping_scenario")) ?? isLoopingScenario); BossType bossType = spawnPattern.GetBossType(); AccessTools.Field(typeof(SpawnPatternData), "bossType").SetValue(val, configuration.GetSection("boss_type").ParseBossType() ?? bossType); ParseTrueFinalBoss(configuration.GetSection("true_final_bosses"), key, val, spawnPattern, overrideMode); ParseSpawnGroupPools(configuration.GetSection("spawn_group_waves"), key, val, spawnPattern, overrideMode); } private void ParseSpawnGroupPools(IConfiguration configuration, string key, SpawnPatternData data, SpawnPatternData copyData, OverrideMode overrideMode) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown object? value = AccessTools.Field(typeof(SpawnPatternData), "spawnGroupWaves").GetValue(data); SpawnGroupPoolsDataList val = (SpawnGroupPoolsDataList)((value is SpawnGroupPoolsDataList) ? value : null); object? value2 = AccessTools.Field(typeof(SpawnPatternData), "spawnGroupWaves").GetValue(copyData); SpawnGroupPoolsDataList val2 = (SpawnGroupPoolsDataList)((value2 is SpawnGroupPoolsDataList) ? value2 : null); if (data != copyData) { foreach (SpawnGroupPoolData item in (ReorderableArray)(object)val2) { SpawnGroupPoolData val3 = new SpawnGroupPoolData(); object? value3 = AccessTools.Field(typeof(SpawnGroupPoolData), "possibleGroups").GetValue(item); SpawnGroupDataList val4 = (SpawnGroupDataList)((value3 is SpawnGroupDataList) ? value3 : null); object? value4 = AccessTools.Field(typeof(SpawnGroupPoolData), "possibleGroups").GetValue(item); foreach (SpawnGroupData item2 in (ReorderableArray)((value4 is SpawnGroupDataList) ? value4 : null)) { SpawnGroupData val5 = new SpawnGroupData(); AccessTools.Field(typeof(SpawnGroupData), "hasWaveMessage").SetValue(val5, item2.HasWaveMessage()); AccessTools.Field(typeof(SpawnGroupData), "waveMessageKey").SetValue(val5, AccessTools.Field(typeof(SpawnGroupData), "waveMessageKey").GetValue(item2)); object? value5 = AccessTools.Field(typeof(SpawnGroupData), "characterDataContainerList").GetValue(val5); CharacterDataContainerList val6 = (CharacterDataContainerList)((value5 is CharacterDataContainerList) ? value5 : null); object? value6 = AccessTools.Field(typeof(SpawnGroupData), "characterDataContainerList").GetValue(item2); foreach (CharacterDataContainer item3 in (ReorderableArray)((value6 is CharacterDataContainerList) ? value6 : null)) { CharacterDataContainer val7 = new CharacterDataContainer(); AccessTools.Field(typeof(CharacterDataContainer), "characterData").SetValue(val7, item3.Character); AccessTools.Field(typeof(CharacterDataContainer), "requiredCovenant").SetValue(val7, item3.Covenant); AccessTools.Field(typeof(CharacterDataContainer), "suppressSpawn").SetValue(val7, item3.SuppressSpawn); AccessTools.Field(typeof(CharacterDataContainer), "useBossCharacter").SetValue(val7, item3.UseBossCharacter); AccessTools.Field(typeof(CharacterDataContainer), "requiredDifficultyTier").SetValue(val7, item3.RequiredDifficultyTier); AccessTools.Field(typeof(CharacterDataContainer), "requiredMutator").SetValue(val7, item3.RequiredMutator); AccessTools.Field(typeof(CharacterDataContainer), "requiredRegionBossDefeated").SetValue(val7, item3.RequiredRegionBossDefeated); ((ReorderableArray)(object)val6).Add(val7); } ((ReorderableArray)(object)val4).Add(val5); } ((ReorderableArray)(object)val).Add(val3); } } int num = 0; foreach (IConfigurationSection child in configuration.GetChildren()) { if (num >= ((ReorderableArray)(object)val).Count) { ((ReorderableArray)(object)val).Add(new SpawnGroupPoolData()); } SpawnGroupPoolData obj = ((ReorderableArray)(object)val)[num]; string text = ParseExtensions.ParseString(child.GetSection("name")); if (text != null) { AccessTools.Field(typeof(SpawnGroupPoolData), "name").SetValue(obj, text); } ParseReferenceExtensions.ReferencedObject referencedObject = child.GetSection("required_mutator").ParseReference(); if (referencedObject != null) { relicRegister.TryLookupName(referencedObject.ToId(key, "RelicData"), out RelicData lookup, out bool? _, referencedObject.context); if (!(lookup is MutatorData)) { logger.Log((LogLevel)4, (object)("Relic data name: " + ((lookup != null) ? ((Object)lookup).name : null) + " given is not a MutatorData ignoring.")); } AccessTools.Field(typeof(CharacterDataContainer), "requiredMutator").SetValue(child, (lookup is MutatorData) ? lookup : null); } object? value7 = AccessTools.Field(typeof(SpawnGroupPoolData), "possibleGroups").GetValue(obj); SpawnGroupDataList val8 = (SpawnGroupDataList)((value7 is SpawnGroupDataList) ? value7 : null); int num2 = 0; foreach (IConfigurationSection child2 in child.GetSection("possible_groups").GetChildren()) { if (num2 >= ((ReorderableArray)(object)val8).Count) { ((ReorderableArray)(object)val8).Add(new SpawnGroupData()); } SpawnGroupData data2 = ((ReorderableArray)(object)val8)[num2]; ParseSpawnGroup(child2, key, data2, overrideMode); num2++; } num++; } } private void ParseSpawnGroup(IConfiguration configuration, string key, SpawnGroupData data, OverrideMode overrideMode) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Invalid comparison between Unknown and I4 //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown LocalizationTerm localizationTerm = configuration.GetSection("wave_messages").ParseLocalizationTerm(); if (localizationTerm != null) { ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } AccessTools.Field(typeof(SpawnGroupData), "hasWaveMessage").SetValue(data, localizationTerm != null); AccessTools.Field(typeof(SpawnGroupData), "waveMessageKey").SetValue(data, localizationTerm?.Key ?? ""); object? value = AccessTools.Field(typeof(SpawnGroupData), "characterDataContainerList").GetValue(data); CharacterDataContainerList val = (CharacterDataContainerList)((value is CharacterDataContainerList) ? value : null); IConfigurationSection section = configuration.GetSection("spawn_list"); if ((int)overrideMode == 1 && section.Exists()) { ((ReorderableArray)(object)val).Clear(); } int num = 0; List list = new List(); foreach (IConfigurationSection child in section.GetChildren()) { if (num >= ((ReorderableArray)(object)val).Count) { ((ReorderableArray)(object)val).Add(new CharacterDataContainer()); } CharacterDataContainer val2 = ((ReorderableArray)(object)val)[num]; ParseReferenceExtensions.ReferencedObject referencedObject = child.GetSection("character").ParseReference(); bool? IsModded; if (referencedObject != null) { characterRegister.TryLookupName(referencedObject.ToId(key, "Character"), out CharacterData lookup, out IsModded, referencedObject.context); AccessTools.Field(typeof(CharacterDataContainer), "characterData").SetValue(val2, lookup); } if ((Object)(object)val2.Character == (Object)null) { list.Add(num); } int? num2 = ParseExtensions.ParseInt(child.GetSection("required_covenant")); int num3; if (!num2.HasValue) { CovenantData covenant = val2.Covenant; num3 = ((covenant != null) ? covenant.AscensionLevel : (-1)); } else { num3 = num2.GetValueOrDefault(); } int num4 = num3; if (num4 > 0) { CovenantData ascensionCovenantForLevel = saveManager.Value.GetAllGameData().GetAscensionCovenantForLevel(num4); AccessTools.Field(typeof(CharacterDataContainer), "requiredCovenant").SetValue(val2, ascensionCovenantForLevel); } int num5 = ParseExtensions.ParseInt(child.GetSection("required_difficulty_tier")) ?? val2.RequiredDifficultyTier; AccessTools.Field(typeof(CharacterDataContainer), "requiredDifficultyTier").SetValue(val2, num5); ParseReferenceExtensions.ReferencedObject referencedObject2 = child.GetSection("required_mutator").ParseReference(); if (referencedObject2 != null) { relicRegister.TryLookupName(referencedObject2.ToId(key, "RelicData"), out RelicData lookup2, out IsModded, referencedObject2.context); if (!(lookup2 is MutatorData)) { logger.Log((LogLevel)4, (object)("Relic data name: " + ((lookup2 != null) ? ((Object)lookup2).name : null) + " given is not a MutatorData ignoring.")); } AccessTools.Field(typeof(CharacterDataContainer), "requiredMutator").SetValue(val2, ((object)((lookup2 is MutatorData) ? lookup2 : null)) ?? ((object)val2.RequiredMutator)); } ParseReferenceExtensions.ReferencedObject referencedObject3 = child.GetSection("required_region_boss_defeated").ParseReference(); if (referencedObject3 != null) { subtypeRegister.TryLookupName(referencedObject3.ToId(key, "Subtype"), out SubtypeData lookup3, out IsModded, referencedObject3.context); AccessTools.Field(typeof(CharacterDataContainer), "requiredRegionBossDefeated").SetValue(val2, ((lookup3 != null) ? lookup3.Key : null) ?? val2.RequiredRegionBossDefeated); } bool flag = ParseExtensions.ParseBool(child.GetSection("suppress_spawn")) ?? val2.SuppressSpawn; AccessTools.Field(typeof(CharacterDataContainer), "suppressSpawn").SetValue(val2, flag); IsModded = ParseExtensions.ParseBool(child.GetSection("use_boss_character")); bool flag2 = IsModded ?? val2.UseBossCharacter; AccessTools.Field(typeof(CharacterDataContainer), "useBossCharacter").SetValue(val2, flag2); num++; } foreach (int item in Enumerable.Reverse(list)) { ((ReorderableArray)(object)val).RemoveAt(item); } } private void ParseTrueFinalBoss(IConfigurationSection configuration, string key, SpawnPatternData data, SpawnPatternData copyData, OverrideMode overrideMode) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown List list = data.GetTrueFinalBosses() ?? new List(); AccessTools.Field(typeof(SpawnPatternData), "trueFinalBosses").SetValue(data, list); List list2 = copyData.GetTrueFinalBosses() ?? new List(); if (data != copyData) { foreach (TrueFinalBoss item in list2) { TrueFinalBoss val = new TrueFinalBoss(); val.characters.AddRange(item.characters); list.Add(val); } } int num = 0; foreach (IConfigurationSection child in configuration.GetChildren()) { if (num >= list.Count) { list.Add(new TrueFinalBoss()); } TrueFinalBoss val2 = list[num]; int num2 = 0; foreach (IConfigurationSection child2 in child.GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject = child2.ParseReference(); CharacterData lookup = null; if (referencedObject != null) { characterRegister.TryLookupName(referencedObject.ToId(key, "Character"), out lookup, out bool? _, referencedObject.context); } if (num2 >= val2.characters.Count) { val2.characters.Add(lookup); } else { val2.characters[num2] = lookup; } num2++; } val2.characters.RemoveAll((CharacterData character) => (Object)(object)character == (Object)null); num++; } } } public class ScenarioPipeline : IDataPipeline, ScenarioData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; private readonly ScenarioDelegator delegator; public ScenarioPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, IGuidProvider guidProvider, ScenarioDelegator delegator) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; this.delegator = delegator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadScenarios(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private IEnumerable> LoadScenarios(IRegister service, string key, IConfiguration configuration) { List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("scenarios").GetChildren()) { ScenarioDefinition scenarioDefinition = LoadConfiguration(service, key, child); if (scenarioDefinition != null) { list.Add(scenarioDefinition); } } return (IEnumerable>)list; } private ScenarioDefinition? LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Scenario", text); OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value = configuration.GetSection("clone_id").Value; string key2 = "ScenarioData_titleKey-" + id; string key3 = "ScenarioData_descriptionKey-" + id; bool? IsModded; ScenarioData lookup2; string text2; ScenarioData val2; if (value != null) { logger.Log((LogLevel)32, (object)("Cloning Scenario " + value + "...")); service.TryLookupName(value, out ScenarioData lookup, out IsModded); lookup2 = ScriptableObject.CreateInstance(); ((Object)lookup2).name = id; text2 = guidProvider.GetGuidDeterministic(id).ToString(); val2 = lookup ?? lookup2; } else if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out lookup2, out IsModded)) { logger.Log((LogLevel)16, (object)("Overriding Scenario " + text + "...")); text2 = ((GameData)lookup2).GetID(); val2 = lookup2; } else { lookup2 = ScriptableObject.CreateInstance(); ((Object)lookup2).name = id; text2 = guidProvider.GetGuidDeterministic(id).ToString(); val2 = lookup2; } AccessTools.Field(typeof(ScenarioData), "id").SetValue(lookup2, text2.ToString()); int? num = ParseExtensions.ParseInt(configuration.GetSection("distance")); string run_type = ParseExtensions.ParseString(configuration.GetSection("run_type")) ?? "primary"; if (num.HasValue) { delegator.Add(lookup2, num.Value, run_type); } string text3 = val2.GetBattleTrackNameData() ?? ""; AccessTools.Field(typeof(ScenarioData), "battleTrackNameData").SetValue(lookup2, ParseExtensions.ParseString(configuration.GetSection("battle_track_name")) ?? text3); int minTreasureUnits = val2.GetMinTreasureUnits(); AccessTools.Field(typeof(ScenarioData), "minTreasureUnits").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("min_treasure_units")) ?? minTreasureUnits); int maxTreasureUnits = val2.GetMaxTreasureUnits(); AccessTools.Field(typeof(ScenarioData), "maxTreasureUnits").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("max_treasure_units")) ?? maxTreasureUnits); int startingEnergy = val2.GetStartingEnergy(); AccessTools.Field(typeof(ScenarioData), "startingEnergy").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("starting_energy")) ?? startingEnergy); ScenarioDifficulty difficulty = val2.GetDifficulty(); AccessTools.Field(typeof(ScenarioData), "difficulty").SetValue(lookup2, configuration.GetSection("difficulty").ParseScenarioDifficulty() ?? difficulty); LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm.Key)) { localizationTerm.Key = key2; } if (localizationTerm.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } AccessTools.Field(typeof(ScenarioData), "battleNameKey").SetValue(lookup2, localizationTerm.Key); } else { object value2 = AccessTools.Field(typeof(ScenarioData), "battleNameKey").GetValue(val2); AccessTools.Field(typeof(ScenarioData), "battleNameKey").SetValue(lookup2, value2); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm2.Key)) { localizationTerm2.Key = key3; } if (localizationTerm2.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm2.Key, localizationTerm2); } AccessTools.Field(typeof(ScenarioData), "battleDescriptionKey").SetValue(lookup2, localizationTerm2.Key); } else { object value3 = AccessTools.Field(typeof(ScenarioData), "battleDescriptionKey").GetValue(val2); AccessTools.Field(typeof(ScenarioData), "battleDescriptionKey").SetValue(lookup2, value3); } bool flag = OverrideModeExtensions.IsNewContent(val) || value != null; if (flag) { ((IRegisterableDictionary)(object)service).Register(id, lookup2); } return new ScenarioDefinition(key, lookup2, val2, val, configuration) { Id = text, IsModded = flag }; } } public class ScenarioRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Scenarios; public ScenarioRegister(GameDataClient client, IModLogger logger) { Scenarios = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? ((AccessTools.Field(typeof(AllGameData), "scenarioDatas").GetValue(provider.GetAllGameData()) as List) ?? new List()) : new List()); this.logger = logger; } public void Register(string key, ScenarioData item) { logger.Log((LogLevel)16, (object)("Register Scenario (" + key + ")")); Scenarios.Value.Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return Scenarios.Value.Select((ScenarioData scenario) => ((GameData)scenario).GetID()).ToList(); } return new List(); } return Scenarios.Value.Select((ScenarioData scenario) => ((Object)scenario).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out ScenarioData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = false; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (ScenarioData item in Scenarios.Value) { if (((GameData)item).GetID() == identifier) { lookup = item; IsModded = ContainsKey(((Object)item).name); return true; } } return false; } return false; } foreach (ScenarioData item2 in Scenarios.Value) { if (((Object)item2).name == identifier) { lookup = item2; IsModded = ContainsKey(((Object)item2).name); return true; } } return false; } } public class TrialDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister relicRegister; private readonly IRegister rewardRegister; private readonly IRegister trialListRegister; public TrialDataFinalizer(IModLogger logger, ICache> cache, IRegister relicRegister, IRegister rewardRegister, IRegister trialListRegister) { this.logger = logger; this.cache = cache; this.relicRegister = relicRegister; this.rewardRegister = rewardRegister; this.trialListRegister = trialListRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeTrial(cacheItem); } cache.Clear(); } public void FinalizeTrial(IDefinition definition) { IConfiguration configuration = definition.Configuration; TrialData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Trial " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("sin").ParseReference(); bool? IsModded; if (referencedObject != null) { string id = referencedObject.ToId(key, "RelicData"); relicRegister.TryLookupId(id, out RelicData lookup, out IsModded, referencedObject.context); if (!(lookup is SinsData)) { logger.Log((LogLevel)4, (object)"Relic found is not a SinsData relic. Behavior may not be as expected."); } AccessTools.Field(typeof(TrialData), "sin").SetValue(data, lookup); } List rewardList = data.RewardList; foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("rewards").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item.ToId(key, "RewardData"); rewardRegister.TryLookupName(name, out RewardData lookup2, out IsModded, item.context); if ((Object)(object)lookup2 != (Object)null) { rewardList.Add(lookup2); } } foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id2 = item2.ToId(key, "TrialList"); trialListRegister.TryLookupId(id2, out TrialDataList lookup3, out IsModded, item2.context); if ((Object)(object)lookup3 != (Object)null) { IEnumerable source = (lookup3.TrialsData ?? Array.Empty()).Append(data); AccessTools.Field(typeof(TrialDataList), "trialDatas").SetValue(lookup3, source.ToArray()); } } } } public class TrialListRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Scenarios; public TrialListRegister(GameDataClient client, IModLogger logger) { Scenarios = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? ((AccessTools.Field(typeof(AllGameData), "scenarioDatas").GetValue(provider.GetAllGameData()) as List) ?? new List()) : new List()); this.logger = logger; } public void Register(string key, TrialDataList item) { logger.Log((LogLevel)32, (object)("Register TrialDataList (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out TrialDataList? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (ScenarioData item in Scenarios.Value) { TrialDataList trialDataList = item.GetTrialDataList(); if (((trialDataList != null) ? trialDataList.ListName : null) == identifier) { IsModded = false; lookup = item.GetTrialDataList(); return true; } } foreach (TrialDataList value in base.Values) { if (value.ListName == identifier) { lookup = value; return true; } } return false; } return false; } foreach (ScenarioData item2 in Scenarios.Value) { TrialDataList trialDataList2 = item2.GetTrialDataList(); if (((trialDataList2 != null) ? trialDataList2.ListName : null) == identifier) { IsModded = false; lookup = item2.GetTrialDataList(); return true; } } foreach (TrialDataList value2 in base.Values) { if (value2.ListName == identifier) { lookup = value2; return true; } } return false; } } } namespace TrainworksReloaded.Base.Room { public class RoomModifierDefinition(string key, RoomModifierData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public RoomModifierData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class RoomModifierFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister tooltipRegister; private readonly IRegister spriteRegister; private readonly IRegister cardDataRegister; private readonly IRegister upgradeDataRegister; private readonly IRegister cardEffectDataRegister; private readonly IRegister vfxRegister; private readonly IRegister statusRegister; private readonly IRegister triggerEnumRegister; private readonly IRegister subtypeRegister; public RoomModifierFinalizer(IModLogger logger, ICache> cache, IRegister tooltipRegister, IRegister spriteRegister, IRegister cardDataRegister, IRegister upgradeDataRegister, IRegister cardEffectDataRegister, IRegister vfxRegister, IRegister statusRegister, IRegister triggerEnumRegister, IRegister subtypeRegister) { this.logger = logger; this.cache = cache; this.tooltipRegister = tooltipRegister; this.spriteRegister = spriteRegister; this.cardDataRegister = cardDataRegister; this.upgradeDataRegister = upgradeDataRegister; this.cardEffectDataRegister = cardEffectDataRegister; this.vfxRegister = vfxRegister; this.statusRegister = statusRegister; this.triggerEnumRegister = triggerEnumRegister; this.subtypeRegister = subtypeRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRoomModifier(cacheItem); } cache.Clear(); } private void FinalizeRoomModifier(IDefinition definition) { //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown IConfiguration configuration = definition.Configuration; RoomModifierData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Room Modifier " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("param_card").ParseReference(); if (referencedObject != null && cardDataRegister.TryLookupName(referencedObject.ToId(key, "Card"), out CardData lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(RoomModifierData), "paramCardData").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("param_upgrade").ParseReference(); if (referencedObject2 != null && upgradeDataRegister.TryLookupName(referencedObject2.ToId(key, "Upgrade"), out CardUpgradeData lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(RoomModifierData), "paramCardUpgardeData").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("triggered_vfx").ParseReference(); if (referencedObject3 != null && vfxRegister.TryLookupId(referencedObject3?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup3, out IsModded, referencedObject3?.context)) { AccessTools.Field(typeof(RoomModifierData), "triggeredVFX").SetValue(data, lookup3); } List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetDeprecatedSection("effects", "param_effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item.ToId(key, "Effect"); if (cardEffectDataRegister.TryLookupId(id, out CardEffectData lookup4, out IsModded, item.context)) { list.Add(lookup4); } } if (list.Count != 0) { AccessTools.Field(typeof(RoomModifierData), "paramCardEffects").SetValue(data, list); } List list2 = new List(); foreach (IConfigurationSection child in configuration.GetSection("param_status_effects").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject4 = child.GetSection("status").ParseReference(); if (referencedObject4 == null) { continue; } string id2 = referencedObject4.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup5, out IsModded, referencedObject4.context)) { StatusEffectStackData val = new StatusEffectStackData { statusId = lookup5.GetStatusId(), count = ((child != null) ? ParseExtensions.ParseInt(child.GetSection("count")) : ((int?)null)).GetValueOrDefault() }; bool? flag; if (child == null) { IsModded = null; flag = IsModded; } else { flag = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); } IsModded = flag; val.fromPermanentUpgrade = IsModded == true; list2.Add(val); } } AccessTools.Field(typeof(RoomModifierData), "paramStatusEffects").SetValue(data, list2.ToArray()); Trigger val2 = (Trigger)0; ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetDeprecatedSection("trigger", "param_trigger").ParseReference(); if (referencedObject5 != null && !triggerEnumRegister.TryLookupId(referencedObject5.ToId(key, "CTriggerEnum"), out var lookup6, out IsModded, referencedObject5.context)) { val2 = lookup6; } AccessTools.Field(typeof(RoomModifierData), "paramTrigger").SetValue(data, val2); string value = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("param_subtype").ParseReference(); if (referencedObject6 != null && subtypeRegister.TryLookupId(referencedObject6.ToId(key, "Subtype"), out SubtypeData lookup7, out IsModded, referencedObject6.context)) { value = lookup7.Key; } AccessTools.Field(typeof(RoomModifierData), "paramSubtype").SetValue(data, value); List list3 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("additional_tooltips").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item2.ToId(key, "AdditionalTooltip"); if (tooltipRegister.TryLookupName(name, out AdditionalTooltipData lookup8, out IsModded, item2.context)) { list3.Add(lookup8); } } AccessTools.Field(typeof(RoomModifierData), "additionalTooltips").SetValue(data, list3.ToArray()); } } public class RoomModifierPipeline : IDataPipeline, RoomModifierData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; public RoomModifierPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadRoomModifiers(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadRoomModifiers(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("room_modifiers").GetChildren()) { RoomModifierDefinition roomModifierDefinition = LoadRoomModifier(service, key, child); if (roomModifierDefinition != null) { list.Add(roomModifierDefinition); } } return list; } private RoomModifierDefinition? LoadRoomModifier(IRegister service, string key, IConfiguration configuration) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("RoomModifier", text); string text2 = "RoomModifierData_titleKey-" + id; string text3 = "RoomModifierData_descriptionKey-" + id; string text4 = "RoomModifierData_descriptionKeyInPlay-" + id; string text5 = "RoomModifierData_extraTooltipTitleKey-" + id; string text6 = "RoomModifierData_extraTooltipBodyKey-" + id; RoomModifierData val = new RoomModifierData(); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("name").ParseReference(); if (referencedObject == null) { return null; } string text7 = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text7, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!referencedObject.id.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)$"Failed to load room modifier state name {referencedObject} in {text} mod {text7}, Make sure the class exists in {text7} and that the class inherits from RoomStateModifierBase."); return null; } AccessTools.Field(typeof(RoomModifierData), "roomStateModifierClassName").SetValue(val, fullyQualifiedName); LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(RoomModifierData), "overrideTitleKey").SetValue(val, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(RoomModifierData), "descriptionKey").SetValue(val, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } LocalizationTerm localizationTerm3 = configuration.GetDeprecatedSection("play_descriptions", "in_play_descriptions").ParseLocalizationTerm(); if (localizationTerm3 != null) { AccessTools.Field(typeof(RoomModifierData), "descriptionKeyInPlay").SetValue(val, text4); localizationTerm3.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm3); } LocalizationTerm localizationTerm4 = configuration.GetSection("extra_title_tooltips").ParseLocalizationTerm(); if (localizationTerm4 != null) { AccessTools.Field(typeof(RoomModifierData), "extraTooltipTitleKey").SetValue(val, text5); localizationTerm4.Key = text5; ((IRegisterableDictionary)(object)termRegister).Register(text5, localizationTerm4); } else { AccessTools.Field(typeof(RoomModifierData), "extraTooltipTitleKey").SetValue(val, string.Empty); } LocalizationTerm localizationTerm5 = configuration.GetSection("extra_body_tooltips").ParseLocalizationTerm(); if (localizationTerm5 != null) { AccessTools.Field(typeof(RoomModifierData), "extraTooltipBodyKey").SetValue(val, text6); localizationTerm5.Key = text6; ((IRegisterableDictionary)(object)termRegister).Register(text6, localizationTerm5); } else { AccessTools.Field(typeof(RoomModifierData), "extraTooltipBodyKey").SetValue(val, string.Empty); } bool flag = false; AccessTools.Field(typeof(RoomModifierData), "useTitleForCardDescription").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("use_name_as_description", "use_title_for_card_description")) ?? flag); bool flag2 = false; AccessTools.Field(typeof(RoomModifierData), "disallowedInDeploymentPhase").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("disallow_in_deployment")) ?? flag2); int num = 0; AccessTools.Field(typeof(RoomModifierData), "paramInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int")) ?? num); int num2 = 0; AccessTools.Field(typeof(RoomModifierData), "paramInt2").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int_2")) ?? num2); float num3 = 0f; AccessTools.Field(typeof(RoomModifierData), "paramFloat").SetValue(val, ParseExtensions.ParseFloat(configuration.GetSection("param_float")) ?? num3); bool flag3 = false; AccessTools.Field(typeof(RoomModifierData), "tooltipsSuppressed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("tooltips_suppressed")) ?? flag3); ((IRegisterableDictionary)(object)service).Register(id, val); return new RoomModifierDefinition(key, val, configuration) { Id = text }; } } public class RoomModifierRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public RoomModifierRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, RoomModifierData item) { logger.Log((LogLevel)32, (object)("Register Room Modifier (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RoomModifierData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Reward { public class CardPoolRewardDataFactory : IFactory { public string FactoryKey => "card_pool"; public RewardData? GetValue() { return (RewardData?)(object)ScriptableObject.CreateInstance(); } } public class CardPoolRewardDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister cardPoolRegister; private readonly IDataFinalizer decoratee; public CardPoolRewardDataFinalizerDecorator(IModLogger logger, ICache> cache, IRegister cardPoolRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.cardPoolRegister = cardPoolRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRewardData(cacheItem); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRewardData(IDefinition definition) { IConfiguration configuration = definition.Configuration; RewardData data = definition.Data; string key = definition.Key; CardPoolRewardData val = (CardPoolRewardData)(object)((data is CardPoolRewardData) ? data : null); if (val == null) { return; } IConfiguration configuration2 = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("card_pool").Exists() select xs.GetSection("card_pool")).First(); if (configuration2 == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing Card Pool Reward Data " + definition.Key + " " + definition.Id + " path: " + configuration2.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration2.GetSection("card_pool").ParseReference(); if (referencedObject != null && cardPoolRegister.TryLookupId(referencedObject.ToId(key, "CardPool"), out CardPool lookup, out bool? _, referencedObject.context)) { AccessTools.Field(typeof(CardPoolRewardData), "cardPool").SetValue(val, lookup); } List value = configuration2.GetSection("cost_overrides").GetChildren().Select((Func)((IConfigurationSection xs) => new CardCosts { rarity = xs.GetSection("rarity").ParseRarity().GetValueOrDefault(), costs = (from configurationSection in xs.GetSection("costs").GetChildren() select ParseExtensions.ParseInt(configurationSection).GetValueOrDefault()).ToArray() })) .ToList(); AccessTools.Field(typeof(CardPoolRewardData), "cardCostsOverride").SetValue(val, value); } } public class DraftRewardDataFactory : IFactory { public string FactoryKey => "draft"; public RewardData? GetValue() { return (RewardData?)(object)ScriptableObject.CreateInstance(); } } public class DraftRewardDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly CardPoolRegister cardPoolRegister; private readonly IRegister classRegister; private readonly IRegister relicRegister; private readonly IDataFinalizer decoratee; private readonly FieldInfo RelicDraftPoolSubstitutions = AccessTools.Field(typeof(DraftRewardData), "relicDraftPoolSubstitutions"); public DraftRewardDataFinalizerDecorator(IModLogger logger, ICache> cache, CardPoolRegister cardPoolRegister, IRegister classRegister, IRegister relicRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.cardPoolRegister = cardPoolRegister; this.classRegister = classRegister; this.relicRegister = relicRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRewardData(cacheItem); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRewardData(IDefinition definition) { //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Expected O, but got Unknown IConfiguration configuration = definition.Configuration; RewardData data = definition.Data; string key = definition.Key; DraftRewardData val = (DraftRewardData)(object)((data is DraftRewardData) ? data : null); if (val == null) { return; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("draft").Exists() select xs.GetSection("draft")).First(); if (configurationSection == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing Draft Reward Data " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configurationSection.GetSection("draft_pool").ParseReference(); if (referencedObject != null && ((IRegister)(object)cardPoolRegister).TryLookupId(referencedObject.ToId(key, "CardPool"), out CardPool lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(DraftRewardData), "draftPool").SetValue(val, lookup); } ClassType valueOrDefault = configurationSection.GetSection("class_type").ParseClassType().GetValueOrDefault(); AccessTools.Field(typeof(DraftRewardData), "classType").SetValue(val, valueOrDefault); int value = ParseExtensions.ParseInt(configurationSection.GetSection("draft_options_count")) ?? 2; AccessTools.Field(typeof(DraftRewardData), "draftOptionsCount").SetValue(val, (uint)Math.Abs(value)); int valueOrDefault2 = ParseExtensions.ParseInt(configurationSection.GetSection("extra_copies")).GetValueOrDefault(); AccessTools.Field(typeof(DraftRewardData), "extraCopies").SetValue(val, valueOrDefault2); bool valueOrDefault3 = ParseExtensions.ParseBool(configurationSection.GetSection("disable_skip")) == true; AccessTools.Field(typeof(DraftRewardData), "disableSkip").SetValue(val, valueOrDefault3); bool valueOrDefault4 = ParseExtensions.ParseBool(configurationSection.GetSection("ignore_relic_rarity_override")) == true; AccessTools.Field(typeof(DraftRewardData), "ignoreRelicRarityOverride").SetValue(val, valueOrDefault4); bool valueOrDefault5 = ParseExtensions.ParseBool(configurationSection.GetSection("use_run_rarity_floors")) == true; AccessTools.Field(typeof(DraftRewardData), "useRunRarityFloors").SetValue(val, valueOrDefault5); bool valueOrDefault6 = ParseExtensions.ParseBool(configurationSection.GetSection("flatten_rarity_for_draft_rate")) == true; AccessTools.Field(typeof(DraftRewardData), "flattenRarityForDraftRate").SetValue(val, valueOrDefault6); bool valueOrDefault7 = ParseExtensions.ParseBool(configurationSection.GetSection("grant_single_card")) == true; AccessTools.Field(typeof(DraftRewardData), "grantSingleCard").SetValue(val, valueOrDefault7); bool valueOrDefault8 = ParseExtensions.ParseBool(configurationSection.GetSection("class_type_override")) == true; AccessTools.Field(typeof(DraftRewardData), "classTypeOverride").SetValue(val, valueOrDefault8); IsModded = ParseExtensions.ParseBool(configurationSection.GetSection("use_draft_ticket_override_values")); bool valueOrDefault9 = IsModded == true; AccessTools.Field(typeof(DraftRewardData), "useDraftTicketOverrideValues").SetValue(val, valueOrDefault9); CollectableRarity valueOrDefault10 = configurationSection.GetSection("rarity_floor").ParseRarity().GetValueOrDefault(); AccessTools.Field(typeof(DraftRewardData), "rarityFloorOverride").SetValue(val, valueOrDefault10); CollectableRarity val2 = (CollectableRarity)(((??)configurationSection.GetSection("rarity_ceiling").ParseRarity()) ?? (-1)); AccessTools.Field(typeof(DraftRewardData), "rarityCeilingOverride").SetValue(val, val2); ParseReferenceExtensions.ReferencedObject referencedObject2 = configurationSection.GetSection("class_data_override").ParseReference(); if (referencedObject2 != null && classRegister.TryLookupName(referencedObject2.ToId(key, "Class"), out ClassData lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(DraftRewardData), "classDataOverride").SetValue(val, lookup2); } List value2 = configurationSection.GetSection("card_rarity_ticket_values").GetChildren().Select((Func)((IConfigurationSection xs) => new RarityTicket { rarityType = xs.GetSection("rarity").ParseRarity().GetValueOrDefault(), ticketValue = ParseExtensions.ParseInt(xs.GetSection("value")).GetValueOrDefault() })) .ToList(); AccessTools.Field(typeof(DraftRewardData), "cardRarityTicketValues").SetValue(val, value2); List value3 = configurationSection.GetSection("enhancer_rarity_ticket_values").GetChildren().Select((Func)((IConfigurationSection xs) => new RarityTicket { rarityType = xs.GetSection("rarity").ParseRarity().GetValueOrDefault(), ticketValue = ParseExtensions.ParseInt(xs.GetSection("value")).GetValueOrDefault() })) .ToList(); AccessTools.Field(typeof(DraftRewardData), "enhancerRarityTicketValues").SetValue(val, value3); List value4 = configurationSection.GetSection("relic_rarity_ticket_values").GetChildren().Select((Func)((IConfigurationSection xs) => new RarityTicket { rarityType = xs.GetSection("rarity").ParseRarity().GetValueOrDefault(), ticketValue = ParseExtensions.ParseInt(xs.GetSection("value")).GetValueOrDefault() })) .ToList(); AccessTools.Field(typeof(DraftRewardData), "relicRarityTicketValues").SetValue(val, value4); List list = RelicDraftPoolSubstitutions.GetValue(val) as List; if (!configuration.GetSection("relic_draft_pool_substitutions").Exists()) { return; } list.Clear(); foreach (IConfigurationSection child in configuration.GetSection("relic_draft_pool_substitutions").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject3 = child.GetSection("relic").ParseReference(); ParseReferenceExtensions.ReferencedObject referencedObject4 = child.GetSection("replacement_draft_pool").ParseReference(); if (referencedObject3 != null && referencedObject4 != null) { relicRegister.TryLookupName(referencedObject3.ToId(key, "RelicData"), out RelicData lookup3, out IsModded, referencedObject3.context); ((IRegister)(object)cardPoolRegister).TryLookupName(referencedObject4.ToId(key, "CardPool"), out CardPool lookup4, out bool? _, referencedObject4.context); if (!((Object)(object)lookup3 == (Object)null) && !((Object)(object)lookup4 == (Object)null)) { RelicDraftPoolSubstitution val3 = new RelicDraftPoolSubstitution(); AccessTools.Field(typeof(RelicDraftPoolSubstitution), "relicData").SetValue(val3, lookup3); AccessTools.Field(typeof(RelicDraftPoolSubstitution), "replacementDraftPool").SetValue(val3, lookup4); list.Add(val3); } } } } } public class GrantableRewardDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IDataFinalizer decoratee; public GrantableRewardDataFinalizerDecorator(IModLogger logger, ICache> cache, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRewardData(cacheItem); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRewardData(IDefinition definition) { IConfiguration configuration = definition.Configuration; RewardData data = definition.Data; _ = definition.Key; GrantableRewardData val = (GrantableRewardData)(object)((data is GrantableRewardData) ? data : null); if (val != null) { IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("grantable").Exists() select xs.GetSection("grantable")).FirstOrDefault(); if (configurationSection != null) { logger.Log((LogLevel)16, (object)("Finalizing Grantable Reward Data " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); bool valueOrDefault = ParseExtensions.ParseBool(configurationSection.GetSection("is_service_merchant_reward")) == true; AccessTools.Field(typeof(GrantableRewardData), "_isServiceMerchantReward").SetValue(val, valueOrDefault); int valueOrDefault2 = ParseExtensions.ParseInt(configurationSection.GetSection("merchant_service_index")).GetValueOrDefault(); AccessTools.Field(typeof(GrantableRewardData), "_merchantServiceIndex").SetValue(val, valueOrDefault2); bool valueOrDefault3 = ParseExtensions.ParseBool(configurationSection.GetSection("apply_trial_data_modifiers")) == true; AccessTools.Field(typeof(GrantableRewardData), "_applyTrialDataModifiers").SetValue(val, valueOrDefault3); } } } } public class RewardDataDefinition(string key, RewardData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public RewardData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class RewardDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister relicRegister; private readonly IRegister soundCueRegister; public RewardDataFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, IRegister relicRegister, IRegister soundCueRegister) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.relicRegister = relicRegister; this.soundCueRegister = soundCueRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRewardData(cacheItem); } cache.Clear(); } private void FinalizeRewardData(IDefinition definition) { IConfiguration configuration = definition.Configuration; RewardData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Reward Data " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("sprite").ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(RewardData), "_rewardSprite").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("requires_relic").ParseReference(); if (referencedObject2 != null) { relicRegister.TryLookupName(referencedObject2.ToId(key, "RelicData"), out RelicData lookup2, out IsModded, referencedObject2.context); AccessTools.Field(typeof(RewardData), "_requiresRelic").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetDeprecatedSection("collect_cue", "collect_sfx_cue").ParseReference(); string value = data.CollectSFXCueName ?? ""; if (referencedObject3 != null && soundCueRegister.TryLookupName(referencedObject3.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup3, out IsModded, referencedObject3.context)) { value = lookup3.Name; } AccessTools.Field(typeof(RewardData), "_collectSFXCueName").SetValue(data, value); } } public class RewardDataPipeline : IDataPipeline, RewardData> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; private readonly Dictionary> generators; public RewardDataPipeline(PluginAtlas atlas, IEnumerable> generators, IGuidProvider guidProvider, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; this.guidProvider = guidProvider; this.generators = generators.ToDictionary((IFactory xs) => xs.FactoryKey); } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadRewards(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadRewards(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("rewards").GetChildren()) { RewardDataDefinition rewardDataDefinition = LoadRewardConfiguration(service, key, child); if (rewardDataDefinition != null) { list.Add(rewardDataDefinition); } } return list; } public RewardDataDefinition? LoadRewardConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_02c2: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string text2 = ParseExtensions.ParseString(configuration.GetSection("type")); if (text2 == null || !generators.TryGetValue(text2, out IFactory value)) { return null; } RewardData value2 = value.GetValue(); if ((Object)(object)value2 == (Object)null) { return null; } string text3 = (((Object)value2).name = key.GetId("RewardData", text)); string value3 = guidProvider.GetGuidDeterministic(text3).ToString(); AccessTools.Field(typeof(RewardData), "id").SetValue(value2, value3); string text4 = "RewardData_titleKey-" + text3; string text5 = "RewardData_descriptionKey-" + text3; LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(RewardData), "_rewardTitleKey").SetValue(value2, text4); localizationTerm.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(RewardData), "_rewardDescriptionKey").SetValue(value2, text5); localizationTerm2.Key = text5; ((IRegisterableDictionary)(object)termRegister).Register(text5, localizationTerm2); } AccessTools.Field(typeof(RewardData), "_showRewardFlowInEvent").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("show_in_event", "show_reward_flow_in_event")) == true); AccessTools.Field(typeof(RewardData), "ShowRewardAnimationInEvent").SetValue(value2, ParseExtensions.ParseBool(configuration.GetSection("show_animation_in_event")) == true); AccessTools.Field(typeof(RewardData), "_showCancelOverride").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("show_cancel", "show_cancel_override")) == true); AccessTools.Field(typeof(RewardData), "isUniqueInEndlessMode").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("endless_mode_unique", "is_unique_in_endless_mode")) == true); List list = (from xs in configuration.GetSection("costs").GetChildren() select ParseExtensions.ParseInt(xs).GetValueOrDefault()).ToList(); AccessTools.Field(typeof(RewardData), "costs").SetValue(value2, list.ToArray()); AccessTools.Field(typeof(RewardData), "_filter").SetValue(value2, configuration.GetSection("filter").ParseRewardFilter().GetValueOrDefault()); ((IRegisterableDictionary)(object)service).Register(text3, value2); return new RewardDataDefinition(key, value2, configuration) { Id = text }; } } public class RewardDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy> Rewards; private readonly Dictionary VanillaRewards = new Dictionary(); public RewardDataRegister(GameDataClient client, IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaRewards, Resources.FindObjectsOfTypeAll().ToDictionary((RewardData x) => ((Object)x).name, (RewardData x) => x)); Extensions.AddRange((Dictionary)this, VanillaRewards); Rewards = new Lazy>(() => client.TryGetProvider(out SaveManager provider) ? ((AccessTools.Field(typeof(AllGameData), "rewardDatas").GetValue(provider.GetAllGameData()) as List) ?? new List()) : new List()); } public void Register(string key, RewardData item) { logger.Log((LogLevel)32, (object)("Register Reward " + key + "...")); GrantableRewardData val = (GrantableRewardData)(object)((item is GrantableRewardData) ? item : null); if (val != null) { Rewards.Value.Add(val); } Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RewardData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = false; if ((int)identifierType != 0) { if ((int)identifierType == 1) { if (TryGetValue(identifier, out lookup)) { IsModded = !VanillaRewards.ContainsKey(identifier); return true; } foreach (RewardData value in base.Values) { if (((GameData)value).GetID() == identifier) { IsModded = !VanillaRewards.ContainsKey(((Object)value).name); lookup = value; return true; } } return false; } return false; } IsModded = !VanillaRewards.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Relic { public class CollectableRelicDataFactory : IFactory { public string FactoryKey => "collectable"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class CollectableRelicDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister classRegister; private readonly IRegister relicPoolRegister; private readonly IRegister cardPoolRegister; private readonly IRegister subtypeRegister; private readonly IRegister localizationRegister; private readonly PluginAtlas atlas; private readonly IDataFinalizer decoratee; private readonly FieldInfo RelicPoolRelicDataListField = AccessTools.Field(typeof(RelicPool), "relicDataList"); private readonly FieldInfo LinkedClassField = AccessTools.Field(typeof(CollectableRelicData), "linkedClass"); public CollectableRelicDataFinalizerDecorator(IModLogger logger, ICache> cache, PluginAtlas atlas, IRegister classRegister, IRegister relicPoolRegister, IRegister subtypeRegister, IRegister cardPoolRegister, IRegister localizationRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.atlas = atlas; this.classRegister = classRegister; this.relicPoolRegister = relicPoolRegister; this.subtypeRegister = subtypeRegister; this.cardPoolRegister = cardPoolRegister; this.localizationRegister = localizationRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRelicData(cacheItem as RelicDataDefinition); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRelicData(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; OverrideMode overrideMode = definition.Override; string key = definition.Key; definition.Id.ToId(key, "RelicData"); CollectableRelicData val = (CollectableRelicData)(object)((data is CollectableRelicData) ? data : null); if (val == null) { return; } RelicData copyData = definition.CopyData; CollectableRelicData val2 = (CollectableRelicData)(object)((copyData is CollectableRelicData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("collectable").Exists() select xs.GetSection("collectable")).FirstOrDefault(); if (configurationSection == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing Collectable Relic Data " + definition.Key + " " + definition.Id + " path: " + configurationSection.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configurationSection.GetSection("class").ParseReference(); ClassData value = val2.GetLinkedClass(); if (referencedObject != null && classRegister.TryLookupName(referencedObject.ToId(key, "Class"), out ClassData lookup, out bool? IsModded, referencedObject.context)) { value = lookup; } LinkedClassField.SetValue(val, value); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configurationSection.GetSection("pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item.ToId(key, "RelicPool"); if (relicPoolRegister.TryLookupId(id, out RelicPool lookup2, out IsModded, item.context)) { (RelicPoolRelicDataListField.GetValue(lookup2) as ReorderableArray)?.Add(val); logger.Log((LogLevel)32, (object)string.Format("Added relic {0} to pool: {1}", definition.Id.ToId(key, "RelicData"), lookup2)); } } IConfigurationSection section = configurationSection.GetSection("description_modifiers"); ParseDescriptionModifiers(section, key, val, val2, overrideMode); } private void ParseDescriptionModifiers(IConfigurationSection configuration, string key, CollectableRelicData data, CollectableRelicData copyData, OverrideMode overrideMode) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 List list = copyData.GetDescriptionModifiers() ?? new List(); if ((Object)(object)copyData != (Object)(object)data) { list = list.ToList(); } if ((int)overrideMode == 1 && configuration.Exists()) { list.Clear(); } int num = 0; foreach (IConfigurationSection child in configuration.GetChildren()) { list.Add(ParseDescriptionModifier(child, key, ((Object)data).name, num)); num++; } AccessTools.Field(typeof(CollectableRelicData), "descriptionModifiers").SetValue(data, list); } private SerializableDescriptionModifier? ParseDescriptionModifier(IConfigurationSection config, string key, string relicId, int index) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) if (!config.Exists()) { return null; } SerializableDescriptionModifier val = new SerializableDescriptionModifier(); string text = $"CollectableRelicData_textFormatKey{index}-{relicId}"; string value = config.GetSection("name").Value; if (value == null) { return null; } string text2 = config.GetSection("mod_reference").Value ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text2, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!value.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load description modifier class " + value + " in " + relicId + " mod " + text2 + ", Make sure the class exists in " + text2 + " and that the class inherits from DescriptionModifier.")); return null; } AccessTools.Field(typeof(SerializableDescriptionModifier), "modifierClassName").SetValue(val, fullyQualifiedName); int valueOrDefault2 = ParseExtensions.ParseInt(config.GetSection("param_int")).GetValueOrDefault(); AccessTools.Field(typeof(SerializableDescriptionModifier), "paramInt").SetValue(val, valueOrDefault2); float valueOrDefault3 = ParseExtensions.ParseFloat(config.GetSection("param_float")).GetValueOrDefault(); AccessTools.Field(typeof(SerializableDescriptionModifier), "paramFloat").SetValue(val, valueOrDefault3); bool valueOrDefault4 = ParseExtensions.ParseBool(config.GetSection("param_bool")) == true; AccessTools.Field(typeof(SerializableDescriptionModifier), "paramBool").SetValue(val, valueOrDefault4); bool? IsModded = ParseExtensions.ParseBool(config.GetSection("param_bool_2")); bool valueOrDefault5 = IsModded == true; AccessTools.Field(typeof(SerializableDescriptionModifier), "paramBool2").SetValue(val, valueOrDefault5); CollectableRarity valueOrDefault6 = config.GetSection("param_card_rarity_type").ParseRarity().GetValueOrDefault(); AccessTools.Field(typeof(SerializableDescriptionModifier), "paramCardRarityType").SetValue(val, valueOrDefault6); CardType val2 = (CardType)(((??)config.GetSection("param_card_type").ParseCardType()) ?? 4); AccessTools.Field(typeof(SerializableDescriptionModifier), "paramCardType").SetValue(val, val2); string value2 = ParseExtensions.ParseString(config.GetSection("param_string")) ?? ""; AccessTools.Field(typeof(SerializableDescriptionModifier), "paramString").SetValue(val, value2); ParseReferenceExtensions.ReferencedObject referencedObject = config.GetSection("param_card_pool").ParseReference(); if (referencedObject != null && cardPoolRegister.TryLookupId(referencedObject.ToId(key, "CardPool"), out CardPool lookup, out IsModded, referencedObject.context)) { AccessTools.Field(typeof(SerializableDescriptionModifier), "paramCardPool").SetValue(val, lookup); } string value3 = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject2 = config.GetSection("param_subtype").ParseReference(); if (referencedObject2 != null && subtypeRegister.TryLookupId(referencedObject2.ToId(key, "Subtype"), out SubtypeData lookup2, out IsModded, referencedObject2.context)) { value3 = lookup2.Key; } AccessTools.Field(typeof(SerializableDescriptionModifier), "paramCharacterSubtype").SetValue(val, value3); LocalizationTerm localizationTerm = config.GetSection("text_formats").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(SerializableDescriptionModifier), "textFormatKey").SetValue(val, text); localizationTerm.Key = text; ((IRegisterableDictionary)(object)localizationRegister).Register(text, localizationTerm); } return val; } } public class CollectableRelicDataPipelineDecorator : IDataPipeline, RelicData> { private readonly IModLogger logger; private readonly IDataPipeline, RelicData> decoratee; public CollectableRelicDataPipelineDecorator(IModLogger logger, IDataPipeline, RelicData> decoratee) { this.logger = logger; this.decoratee = decoratee; } public List> Run(IRegister register) { List> list = decoratee.Run(register); foreach (IDefinition item in list) { ProcessCollectableRelicData(item as RelicDataDefinition); } return list; } private void ProcessCollectableRelicData(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; _ = definition.Override; StringExtensions.ToId(key: definition.Key, baseString: definition.Id, template: "RelicData"); CollectableRelicData val = (CollectableRelicData)(object)((data is CollectableRelicData) ? data : null); if (val != null) { RelicData copyData = definition.CopyData; CollectableRelicData val2 = (CollectableRelicData)(object)((copyData is CollectableRelicData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("collectable").Exists() select xs.GetSection("collectable")).FirstOrDefault(); if (configurationSection != null) { CollectableRarity val3 = (CollectableRarity)(((??)configurationSection.GetSection("rarity").ParseRarity()) ?? val2.GetRarity()); AccessTools.Field(typeof(CollectableRelicData), "rarity").SetValue(val, val3); int num = ParseExtensions.ParseInt(configurationSection.GetSection("unlock_level")) ?? val2.GetUnlockLevel(); AccessTools.Field(typeof(CollectableRelicData), "unlockLevel").SetValue(val, num); bool flag = ParseExtensions.ParseBool(configurationSection.GetSection("from_story_event")) ?? val2.GetFromStoryEvent(); AccessTools.Field(typeof(CollectableRelicData), "fromStoryEvent").SetValue(val, flag); bool flag2 = ParseExtensions.ParseBool(configurationSection.GetSection("is_boss_given")) ?? val2.IsBossGivenRelic(); AccessTools.Field(typeof(CollectableRelicData), "isBossGivenRelic").SetValue(val, flag2); bool flag3 = ParseExtensions.ParseBool(configurationSection.GetSection("is_dragons_hoard")) ?? val2.IsDragonsHoardRelic(); AccessTools.Field(typeof(CollectableRelicData), "isDragonsHoardRelic").SetValue(val, flag3); bool flag4 = ParseExtensions.ParseBool(configurationSection.GetSection("ignore_for_no_relic_achievement")) ?? val2.IgnoreForNoRelicAchievement(); AccessTools.Field(typeof(CollectableRelicData), "ignoreForNoRelicAchievement").SetValue(val, flag4); DLC val4 = (DLC)(((??)configurationSection.GetSection("required_dlc").ParseDLC()) ?? val2.GetRequiredDLC()); AccessTools.Field(typeof(CollectableRelicData), "requiredDLC").SetValue(val, val4); bool flag5 = ParseExtensions.ParseBool(configurationSection.GetSection("deprioritize_in_ftue_drafts")) ?? val2.GetIsDeprioritizedInFtueDrafts(); AccessTools.Field(typeof(CollectableRelicData), "deprioritizeInFtueDrafts").SetValue(val, flag5); bool flag6 = ParseExtensions.ParseBool(configurationSection.GetSection("force_update_count_label")) ?? val2.ShouldForceUpdateCountLabel(); AccessTools.Field(typeof(CollectableRelicData), "forceUpdateCountLabel").SetValue(val, flag6); } } } } public class CovenantDataFactory : IFactory { public string FactoryKey => "covenant"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class CovenantDataPipelineDecorator : IDataPipeline, RelicData> { private readonly IModLogger logger; private readonly IDataPipeline, RelicData> decoratee; public CovenantDataPipelineDecorator(IModLogger logger, IDataPipeline, RelicData> decoratee) { this.logger = logger; this.decoratee = decoratee; } public List> Run(IRegister register) { List> list = decoratee.Run(register); foreach (IDefinition item in list) { ProcessData(item as RelicDataDefinition); } return list; } private void ProcessData(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; _ = definition.Override; StringExtensions.ToId(key: definition.Key, baseString: definition.Id, template: "RelicData"); CovenantData val = (CovenantData)(object)((data is CovenantData) ? data : null); if (val != null) { RelicData copyData = definition.CopyData; CovenantData val2 = (CovenantData)(object)((copyData is CovenantData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("covenant").Exists() select xs.GetSection("covenant")).FirstOrDefault(); if (configurationSection != null) { int num = ParseExtensions.ParseInt(configurationSection.GetSection("unlock_level")) ?? val2.GetUnlockLevel(); AccessTools.Field(typeof(CovenantData), "unlockLevel").SetValue(val, num); int num2 = ParseExtensions.ParseInt(configurationSection.GetSection("ascension_level")) ?? val2.AscensionLevel; AccessTools.Field(typeof(CovenantData), "ascensionLevel").SetValue(val, num2); string value = configurationSection.GetSection("disables_covenant").Value ?? val2.DisablesCovenant; AccessTools.Field(typeof(CovenantData), "disablesCovenant").SetValue(val, value); } } } } public class EndlessMutatorDataFactory : IFactory { public string FactoryKey => "endless_mutator"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class EnhancerDataFactory : IFactory { public string FactoryKey => "enhancer"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class EnhancerDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister classRegister; private readonly IRegister enhancerPoolRegister; private readonly IDataFinalizer decoratee; private readonly FieldInfo EnhancerPoolRelicDataListField = AccessTools.Field(typeof(EnhancerPool), "relicDataList"); private readonly FieldInfo LinkedClassField = AccessTools.Field(typeof(EnhancerData), "linkedClass"); public EnhancerDataFinalizerDecorator(IModLogger logger, ICache> cache, IRegister classRegister, IRegister enhancerPoolRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.classRegister = classRegister; this.enhancerPoolRegister = enhancerPoolRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRelicData(cacheItem as RelicDataDefinition); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRelicData(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; _ = definition.Override; string key = definition.Key; definition.Id.ToId(key, "RelicData"); EnhancerData val = (EnhancerData)(object)((data is EnhancerData) ? data : null); if (val == null) { return; } RelicData copyData = definition.CopyData; EnhancerData val2 = (EnhancerData)(object)((copyData is EnhancerData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("enhancer").Exists() select xs.GetSection("enhancer")).FirstOrDefault(); if (configurationSection == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing Enhancer Data " + definition.Key + " " + definition.Id + " path: " + configurationSection.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configurationSection.GetSection("class").ParseReference(); ClassData value = val2.GetLinkedClass(); if (referencedObject != null && classRegister.TryLookupName(referencedObject.ToId(key, "Class"), out ClassData lookup, out bool? IsModded, referencedObject.context)) { value = lookup; } LinkedClassField.SetValue(val, value); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configurationSection.GetSection("pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item.ToId(key, "RelicPool"); if (enhancerPoolRegister.TryLookupId(id, out EnhancerPool lookup2, out IsModded, item.context)) { (EnhancerPoolRelicDataListField.GetValue(lookup2) as ReorderableArray)?.Add(val); logger.Log((LogLevel)32, (object)string.Format("Added enhancer {0} to pool: {1}", definition.Id.ToId(key, "RelicData"), lookup2)); } } } } public class EnhancerDataPipelineDecorator : IDataPipeline, RelicData> { private readonly IModLogger logger; private readonly IDataPipeline, RelicData> decoratee; public EnhancerDataPipelineDecorator(IModLogger logger, IDataPipeline, RelicData> decoratee) { this.logger = logger; this.decoratee = decoratee; } public List> Run(IRegister register) { List> list = decoratee.Run(register); foreach (IDefinition item in list) { ProcessEnhancerData(item as RelicDataDefinition); } return list; } private void ProcessEnhancerData(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; _ = definition.Override; StringExtensions.ToId(key: definition.Key, baseString: definition.Id, template: "RelicData"); EnhancerData val = (EnhancerData)(object)((data is EnhancerData) ? data : null); if (val != null) { RelicData copyData = definition.CopyData; EnhancerData val2 = (EnhancerData)(object)((copyData is EnhancerData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("enhancer").Exists() select xs.GetSection("enhancer")).FirstOrDefault(); if (configurationSection != null) { CollectableRarity val3 = (CollectableRarity)(((??)configurationSection.GetSection("rarity").ParseRarity()) ?? val2.GetRarity()); AccessTools.Field(typeof(EnhancerData), "rarity").SetValue(val, val3); int num = ParseExtensions.ParseInt(configurationSection.GetSection("unlock_level")) ?? val2.GetUnlockLevel(); AccessTools.Field(typeof(EnhancerData), "unlockLevel").SetValue(val, num); int num2 = ParseExtensions.ParseInt(configurationSection.GetSection("num_cards_to_show_in_upgrade_screen")) ?? val2.NumCardsToShowInUpgradeScreen; AccessTools.Field(typeof(EnhancerData), "numCardsToShowInUpgradeScreen").SetValue(val, num2); } } } } public class EnhancerPoolDefinition : IDefinition { public string Id { get; set; } = ""; public string Key { get; set; } public EnhancerPool Data { get; set; } public IConfiguration Configuration { get; set; } public bool IsModded => true; public EnhancerPoolDefinition(string key, EnhancerPool data, IConfiguration configuration) { Key = key; Data = data; Configuration = configuration; base..ctor(); } } public class EnhancerPoolFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister relicRegister; public EnhancerPoolFinalizer(IModLogger logger, ICache> cache, IRegister relicRegister) { this.logger = logger; this.cache = cache; this.relicRegister = relicRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizePoolData(cacheItem); } cache.Clear(); } private void FinalizePoolData(IDefinition definition) { IConfiguration configuration = definition.Configuration; EnhancerPool data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Enhancer Pool " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("enhancers").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string text = item.ToId(key, "RelicData"); if (relicRegister.TryLookupName(text, out RelicData lookup, out bool? _, item.context)) { EnhancerData val = (EnhancerData)(object)((lookup is EnhancerData) ? lookup : null); if (val != null) { list.Add(val); continue; } logger.Log((LogLevel)4, (object)("RelicData " + text + " attempted to be added to EnhancerPool " + ((Object)data).name + " but it is not a EnhancerData. Ignoring...")); } } if (list.Count == 0) { return; } ReorderableArray val2 = (ReorderableArray)AccessTools.Field(typeof(EnhancerPool), "relicDataList").GetValue(data); val2.Clear(); foreach (EnhancerData item2 in list) { val2.Add(item2); } AccessTools.Field(typeof(EnhancerPool), "relicDataList").SetValue(data, val2); } } public class EnhancerPoolPipeline : IDataPipeline, EnhancerPool> { private readonly PluginAtlas atlas; private readonly IInstanceGenerator generator; public EnhancerPoolPipeline(PluginAtlas atlas, IInstanceGenerator generator) { this.atlas = atlas; this.generator = generator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadPools(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadPools(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("enhancer_pools").GetChildren()) { EnhancerPoolDefinition enhancerPoolDefinition = LoadEnhancerPoolConfiguration(service, key, child); if (enhancerPoolDefinition != null) { list.Add(enhancerPoolDefinition); } } return list; } public EnhancerPoolDefinition? LoadEnhancerPoolConfiguration(IRegister service, string key, IConfiguration configuration) { string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("EnhancerPool", text); EnhancerPool val = generator.CreateInstance(); ((Object)val).name = id; ((IRegisterableDictionary)(object)service).Register(id, val); return new EnhancerPoolDefinition(key, val, configuration) { Id = text }; } } public class EnhancerPoolRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaEnhancerPools = new Dictionary(); public EnhancerPoolRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaEnhancerPools, Resources.FindObjectsOfTypeAll().ToDictionary((EnhancerPool x) => ((Object)x).name, (EnhancerPool x) => x)); Extensions.AddRange((Dictionary)this, VanillaEnhancerPools); } public void Register(string key, EnhancerPool item) { logger.Log((LogLevel)16, (object)("Register Enhancer Pool " + key + "...")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out EnhancerPool? lookup, [NotNullWhen(true)] out bool? IsModded) { IsModded = !VanillaEnhancerPools.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } public class MutatorDataFactory : IFactory { public string FactoryKey => "mutator"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class MutatorDataPipelineDecorator : IDataPipeline, RelicData> { private readonly IModLogger logger; private readonly IDataPipeline, RelicData> decoratee; private readonly FieldInfo BoonValueField = AccessTools.Field(typeof(MutatorData), "boonValue"); private readonly FieldInfo DisableInDailyChallengesField = AccessTools.Field(typeof(MutatorData), "disableInDailyChallenges"); private readonly FieldInfo IsSoulSaviorModeOnlyField = AccessTools.Field(typeof(MutatorData), "isSoulSaviorModeOnly"); private readonly FieldInfo RequiredDLCField = AccessTools.Field(typeof(MutatorData), "requiredDLC"); private readonly FieldInfo TagsField = AccessTools.Field(typeof(MutatorData), "tags"); public MutatorDataPipelineDecorator(IModLogger logger, IDataPipeline, RelicData> decoratee) { this.logger = logger; this.decoratee = decoratee; } public List> Run(IRegister register) { List> list = decoratee.Run(register); foreach (IDefinition item in list) { ProcessMutatorData(item as RelicDataDefinition); } return list; } private void ProcessMutatorData(RelicDataDefinition definition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; OverrideMode val = definition.Override; string key = definition.Key; definition.Id.ToId(key, "RelicData"); MutatorData val2 = (MutatorData)(object)((data is MutatorData) ? data : null); if (val2 == null) { return; } RelicData copyData = definition.CopyData; MutatorData val3 = (MutatorData)(object)((copyData is MutatorData) ? copyData : null); if (val3 == null) { val3 = val2; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("mutator").Exists() select xs.GetSection("mutator")).FirstOrDefault(); if (configurationSection != null) { logger.Log((LogLevel)32, (object)("Processing Mutator Data " + definition.Key + " " + definition.Id + " path: " + configurationSection.GetPath() + "...")); int num = ParseExtensions.ParseInt(configurationSection.GetSection("boon_value")) ?? val3.GetBoonValue(); BoonValueField.SetValue(val2, num); bool flag = ParseExtensions.ParseBool(configurationSection.GetSection("disable_in_daily_challenges")) ?? val3.GetDisableInDailyChallenges(); DisableInDailyChallengesField.SetValue(val2, flag); bool flag2 = ParseExtensions.ParseBool(configurationSection.GetSection("is_soul_savior_mode_only")) ?? val3.IsSoulSaviorModeOnly(); IsSoulSaviorModeOnlyField.SetValue(val2, flag2); DLC val4 = (DLC)(((??)configurationSection.GetSection("required_dlc").ParseDLC()) ?? val3.GetRequiredDLC()); RequiredDLCField.SetValue(val2, val4); List list = val3.GetTags() ?? new List(); if ((Object)(object)val3 != (Object)(object)data) { list = list.ToList(); } IConfigurationSection section = configurationSection.GetSection("tags"); if ((int)val == 1 && section.Exists()) { list.Clear(); } list.AddRange((from x in section.GetChildren() select ParseExtensions.ParseString(x) into x where x != null select x).Cast()); TagsField.SetValue(val2, list); } } } public class PyreArtifactDataFactory : IFactory { public string FactoryKey => "pyre_artifact"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class RelicDataDefinition(string key, RelicData data, RelicData copyData, OverrideMode overrideMode, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public RelicData Data { get; set; } = data; public RelicData CopyData { get; set; } = copyData; public OverrideMode Override { get; set; } = overrideMode; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class RelicDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister relicEffectRegister; public RelicDataFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, IRegister relicEffectRegister) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.relicEffectRegister = relicEffectRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRelicData(cacheItem as RelicDataDefinition); } cache.Clear(); } private void FinalizeRelicData(RelicDataDefinition definition) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Invalid comparison between Unknown and I4 //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Invalid comparison between Unknown and I4 //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; RelicData copyData = definition.CopyData; string key = definition.Key; OverrideMode val = definition.Override; logger.Log((LogLevel)16, (object)("Finalizing Relic " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); AccessTools.Field(typeof(RelicData), "icon").SetValue(data, copyData.GetIcon()); IConfigurationSection section = configuration.GetSection("icon"); ParseReferenceExtensions.ReferencedObject referencedObject = section.ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(RelicData), "icon").SetValue(data, lookup); } else if ((int)val == 1 && referencedObject == null && section.Exists()) { AccessTools.Field(typeof(RelicData), "icon").SetValue(data, null); } AccessTools.Field(typeof(RelicData), "iconSmall").SetValue(data, copyData.GetIconSmall()); ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("icon_small").ParseReference(); if (referencedObject2 != null && spriteRegister.TryLookupId(referencedObject2.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, referencedObject2?.context)) { AccessTools.Field(typeof(RelicData), "iconSmall").SetValue(data, lookup2); } else if ((int)val == 1 && referencedObject == null && section.Exists()) { AccessTools.Field(typeof(RelicData), "iconSmall").SetValue(data, null); } List list = copyData.GetEffects() ?? new List(); if ((Object)(object)copyData != (Object)(object)data) { list = list.ToList(); } IConfigurationSection section2 = configuration.GetSection("relic_effects"); if ((int)val == 1 && section2.Exists()) { list.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section2.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (relicEffectRegister.TryLookupId(item.ToId(key, "RelicEffectData"), out RelicEffectData lookup3, out IsModded, item.context)) { list.Add(lookup3); } } AccessTools.Field(typeof(RelicData), "effects").SetValue(data, list); } } public class RelicDataPipeline : IDataPipeline, RelicData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister localizationRegister; private readonly Dictionary> generators; private readonly IGuidProvider guidProvider; public RelicDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister localizationRegister, IEnumerable> generators, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.localizationRegister = localizationRegister; this.generators = generators.ToDictionary((IFactory xs) => xs.FactoryKey); this.guidProvider = guidProvider; } public List> Run(IRegister register) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadRelics(register, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadRelics(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("relics").GetChildren()) { RelicDataDefinition relicDataDefinition = LoadRelicConfiguration(service, key, child); if (relicDataDefinition != null) { list.Add(relicDataDefinition); } } return list; } private RelicDataDefinition? LoadRelicConfiguration(IRegister service, string key, IConfigurationSection config) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Invalid comparison between Unknown and I4 //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(config.GetSection("id")); if (string.IsNullOrEmpty(text)) { logger.Log((LogLevel)2, (object)"Relic configuration missing required 'id' field"); return null; } string id = key.GetId("RelicData", text); string text2 = "RelicData_titleKey-" + id; string text3 = "RelicData_descriptionKey-" + id; string text4 = "RelicData_activatedKey-" + id; OverrideMode val = config.GetSection("override").ParseOverrideMode(); string value = config.GetSection("clone_id").Value; string text5 = ParseExtensions.ParseString(config.GetSection("type")); if (text5 == null || !generators.TryGetValue(text5, out IFactory value2)) { logger.Log((LogLevel)2, (object)("Generator for relic type " + text5 + " missing")); return null; } bool? IsModded; RelicData lookup2; RelicData val2; if (value != null) { logger.Log((LogLevel)32, (object)("Cloning RelicData " + value + "...")); service.TryLookupName(value, out RelicData lookup, out IsModded); lookup2 = value2.GetValue(); if ((Object)(object)lookup2 == (Object)null) { logger.Log((LogLevel)2, (object)("Factory for relic type " + text5 + " missing")); return null; } ((Object)lookup2).name = id; string value3 = guidProvider.GetGuidDeterministic(id).ToString(); AccessTools.Field(typeof(RelicData), "id").SetValue(lookup2, value3); val2 = lookup ?? lookup2; } else if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out lookup2, out IsModded)) { logger.Log((LogLevel)16, (object)("Overriding RelicData " + text + "... ")); text3 = lookup2.GetDescriptionKey(); text4 = lookup2.GetRelicActivatedKey(); text2 = lookup2.GetNameKey(); val2 = lookup2; } else { lookup2 = value2.GetValue(); if ((Object)(object)lookup2 == (Object)null) { logger.Log((LogLevel)2, (object)("Factory for relic type " + text5 + " missing")); return null; } ((Object)lookup2).name = id; string value4 = guidProvider.GetGuidDeterministic(id).ToString(); AccessTools.Field(typeof(RelicData), "id").SetValue(lookup2, value4); val2 = lookup2; } AccessTools.Field(typeof(RelicData), "nameKey").SetValue(lookup2, val2.GetNameKey()); LocalizationTerm localizationTerm = config.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(RelicData), "nameKey").SetValue(lookup2, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)localizationRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = config.GetSection("descriptions").ParseLocalizationTerm(); AccessTools.Field(typeof(RelicData), "descriptionKey").SetValue(lookup2, val2.GetDescriptionKey()); if (localizationTerm2 != null) { AccessTools.Field(typeof(RelicData), "descriptionKey").SetValue(lookup2, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)localizationRegister).Register(text3, localizationTerm2); } LocalizationTerm localizationTerm3 = config.GetSection("relic_activated_texts").ParseLocalizationTerm(); AccessTools.Field(typeof(RelicData), "relicActivatedKey").SetValue(lookup2, val2.GetRelicActivatedKey()); if (localizationTerm3 != null) { AccessTools.Field(typeof(RelicData), "relicActivatedKey").SetValue(lookup2, text4); localizationTerm3.Key = text4; ((IRegisterableDictionary)(object)localizationRegister).Register(text4, localizationTerm3); } List list = val2.GetRelicLoreTooltipKeys() ?? new List(); if ((Object)(object)val2 != (Object)(object)lookup2) { list = list.ToList(); } AccessTools.Field(typeof(RelicData), "relicLoreTooltipKeys").SetValue(lookup2, list); IConfigurationSection section = config.GetSection("lore_tooltips"); if ((int)val == 1 && section.Exists()) { list.Clear(); } int num = list.Count; foreach (IConfigurationSection child in section.GetChildren()) { LocalizationTerm localizationTerm4 = child.ParseLocalizationTerm(); if (localizationTerm4 != null) { string text6 = $"RelicData_loreTooltipKey-{num}-{id}"; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm4.Key)) { localizationTerm4.Key = text6; } list.Add(text6); if (localizationTerm4.HasTranslation()) { ((IRegisterableDictionary)(object)localizationRegister).Register(text6, localizationTerm4); } num++; } } bool flag = ParseExtensions.ParseBool(config.GetSection("disallow_in_deployment")) ?? val2.DisallowInDeploymentPhase; AccessTools.Field(typeof(RelicData), "disallowInDeploymentPhase").SetValue(lookup2, flag); bool flag2 = ParseExtensions.ParseBool(config.GetSection("is_hidden")) ?? val2.IsHidden; AccessTools.Field(typeof(RelicData), "isHidden").SetValue(lookup2, flag2); RelicLoreTooltipStyle val3 = (RelicLoreTooltipStyle)(((??)config.GetSection("lore_style").ParseRelicLoreTooltipStyle()) ?? val2.GetRelicLoreTooltipStyle()); AccessTools.Field(typeof(RelicData), "relicLoreTooltipStyle").SetValue(lookup2, val3); ((IRegisterableDictionary)(object)service).Register(id, lookup2); return new RelicDataDefinition(key, lookup2, val2, val, config) { Id = text }; } } public class RelicDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly List collectables = new List(); private readonly List sins = new List(); private readonly List enhancers = new List(); private readonly List mutators = new List(); private readonly List covenants = new List(); private readonly List endless_mutators = new List(); private readonly List souls = new List(); private readonly Dictionary VanillaRelicData = new Dictionary(); private readonly HashSet DuplicatedIdentifiers = new HashSet { "UpgradedDrafts" }; public RelicDataRegister(GameDataClient client, IModLogger logger) { this.logger = logger; if (!client.TryGetProvider(out SaveManager provider)) { logger.Log((LogLevel)2, (object)"[CATASTROPHIC] Unable to get SaveManager instance"); return; } AllGameData allGameData = provider.GetAllGameData(); collectables = (List)AccessTools.Field(typeof(AllGameData), "collectableRelicDatas").GetValue(allGameData); sins = (List)AccessTools.Field(typeof(AllGameData), "sinsDatas").GetValue(allGameData); enhancers = (List)AccessTools.Field(typeof(AllGameData), "enhancerDatas").GetValue(allGameData); mutators = (List)AccessTools.Field(typeof(AllGameData), "mutatorDatas").GetValue(allGameData); endless_mutators = (List)AccessTools.Field(typeof(AllGameData), "endlessMutatorDatas").GetValue(allGameData); souls = (List)AccessTools.Field(typeof(AllGameData), "soulDatas").GetValue(allGameData); covenants = (List)AccessTools.Field(typeof(AllGameData), "covenantDatas").GetValue(allGameData); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)mutators.ToDictionary((MutatorData x) => ((Object)x).name, (MutatorData x) => x)); RelicData value = VanillaRelicData["UpgradedDrafts"]; VanillaRelicData.Remove("UpgradedDrafts"); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)collectables.ToDictionary((CollectableRelicData x) => ((Object)x).name, (CollectableRelicData x) => x)); RelicData value2 = VanillaRelicData["UpgradedDrafts"]; VanillaRelicData.Remove("UpgradedDrafts"); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)sins.ToDictionary((SinsData x) => ((Object)x).name, (SinsData x) => x)); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)enhancers.ToDictionary((EnhancerData x) => ((Object)x).name, (EnhancerData x) => x)); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)endless_mutators.ToDictionary((EndlessMutatorData x) => ((Object)x).name, (EndlessMutatorData x) => x)); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)souls.ToDictionary((SoulData x) => ((Object)x).name, (SoulData x) => x)); Extensions.AddRange((IDictionary)VanillaRelicData, (IDictionary)covenants.ToDictionary((CovenantData x) => ((Object)x).name, (CovenantData x) => x)); VanillaRelicData.Add("UpgradedDraftsMutator", value); VanillaRelicData.Add("UpgradedDraftsArtifact", value2); Extensions.AddRange((Dictionary)this, VanillaRelicData); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return this.Select, string>((KeyValuePair x) => ((GameData)x.Value).GetID()).ToList(); } return new List(); } return base.Keys.ToList(); } public void Register(string key, RelicData item) { logger.Log((LogLevel)16, (object)("Register Relic " + key + "... ")); CollectableRelicData val = (CollectableRelicData)(object)((item is CollectableRelicData) ? item : null); if (val != null) { collectables.Add(val); } else { EnhancerData val2 = (EnhancerData)(object)((item is EnhancerData) ? item : null); if (val2 != null) { enhancers.Add(val2); } else { SinsData val3 = (SinsData)(object)((item is SinsData) ? item : null); if (val3 != null) { sins.Add(val3); } else { MutatorData val4 = (MutatorData)(object)((item is MutatorData) ? item : null); if (val4 != null) { mutators.Add(val4); } else { EndlessMutatorData val5 = (EndlessMutatorData)(object)((item is EndlessMutatorData) ? item : null); if (val5 != null) { endless_mutators.Add(val5); } else { SoulData val6 = (SoulData)(object)((item is SoulData) ? item : null); if (val6 != null) { souls.Add(val6); } else { CovenantData val7 = (CovenantData)(object)((item is CovenantData) ? item : null); if (val7 != null) { covenants.Add(val7); } } } } } } } Add(key, item); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RelicData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if (DuplicatedIdentifiers.Contains(identifier)) { logger.Log((LogLevel)4, (object)(identifier + " is ambiguous. Multiple RelicData subclasses have an identifier with that name. Append one of (Artifact, Enhancer, Mutator, Sin, or EndlessMutator) to disambiguate.")); return false; } if ((int)identifierType != 0) { if ((int)identifierType == 1) { IsModded = !VanillaRelicData.ContainsKey(identifier); lookup = this.FirstOrDefault>((KeyValuePair x) => ((GameData)x.Value).GetID() == identifier).Value; return (Object)(object)lookup != (Object)null; } return false; } IsModded = !VanillaRelicData.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } public class RelicEffectConditionDefinition(string key, RelicEffectCondition data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public RelicEffectCondition Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class RelicEffectConditionFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister subtypeRegister; private readonly IRegister trackedValueTypeRegister; public RelicEffectConditionFinalizer(IModLogger logger, ICache> cache, IRegister register, IRegister trackedValueTypeRegister) { this.logger = logger; this.cache = cache; subtypeRegister = register; this.trackedValueTypeRegister = trackedValueTypeRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeItem(cacheItem); } cache.Clear(); } private void FinalizeItem(IDefinition definition) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicEffectCondition data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing RelicEffectCondition " + key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("param_subtype").ParseReference(); bool? IsModded; if (referencedObject != null) { string id = referencedObject.ToId(key, "Subtype"); subtypeRegister.TryLookupId(id, out SubtypeData lookup, out IsModded, referencedObject.context); AccessTools.Field(typeof(RelicEffectCondition), "paramSubtype").SetValue(data, (lookup != null) ? lookup.Key : null); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("param_tracked_value").ParseReference(); if (referencedObject2 != null) { string id2 = referencedObject2.ToId(key, "TrackedValueTypeEnum"); trackedValueTypeRegister.TryLookupId(id2, out var lookup2, out IsModded, referencedObject2.context); AccessTools.Field(typeof(RelicEffectCondition), "paramTrackedValue").SetValue(data, lookup2); } } } public class RelicEffectConditionPipeline : IDataPipeline, RelicEffectCondition> { private readonly PluginAtlas atlas; private readonly IModLogger logger; public RelicEffectConditionPipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister register) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadRelicEffectConditions(register, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadRelicEffectConditions(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("relic_effect_conditions").GetChildren()) { RelicEffectConditionDefinition relicEffectConditionDefinition = LoadRelicEffectCondition(service, key, child); if (relicEffectConditionDefinition != null) { list.Add(relicEffectConditionDefinition); } } return list; } private RelicEffectConditionDefinition? LoadRelicEffectCondition(IRegister service, string key, IConfigurationSection configuration) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_011d: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (string.IsNullOrEmpty(text)) { logger.Log((LogLevel)2, (object)"Relic effect condition configuration missing required 'id' field"); return null; } string id = key.GetId("RelicEffectCondition", text); RelicEffectCondition val = new RelicEffectCondition(); CardTypeTarget val2 = (CardTypeTarget)0; AccessTools.Field(typeof(RelicEffectCondition), "paramCardType").SetValue(val, configuration.GetSection("param_card_type").ParseCardTypeTarget() ?? val2); EntryDuration val3 = (EntryDuration)0; AccessTools.Field(typeof(RelicEffectCondition), "paramEntryDuration").SetValue(val, configuration.GetSection("param_entry_duration").ParseEntryDuration() ?? val3); AccessTools.Field(typeof(RelicEffectCondition), "paramTrackTriggerCount").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_track_trigger_count")) == true); Comparator val4 = (Comparator)6; AccessTools.Field(typeof(RelicEffectCondition), "paramComparator").SetValue(val, configuration.GetSection("param_comparator").ParseComparator() ?? val4); AccessTools.Field(typeof(RelicEffectCondition), "paramInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int")).GetValueOrDefault()); AccessTools.Field(typeof(RelicEffectCondition), "allowMultipleTriggersPerDuration").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("allow_multiple_triggers_per_duration")) ?? true); ((IRegisterableDictionary)(object)service).Register(id, val); return new RelicEffectConditionDefinition(key, val, configuration) { Id = text }; } } public class RelicEffectConditionRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public RelicEffectConditionRegister(GameDataClient client, IModLogger logger) { this.logger = logger; } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public void Register(string key, RelicEffectCondition item) { logger.Log((LogLevel)16, (object)("Register RelicEffectCondition " + key + "... ")); Add(key, item); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RelicEffectCondition? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class RelicEffectDataDefinition(string key, RelicEffectData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public RelicEffectData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class RelicEffectDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister tooltipRegister; private readonly IRegister cardEffectRegister; private readonly IRegister cardPoolRegister; private readonly IRegister characterRegister; private readonly IRegister statusEffectRegister; private readonly IRegister traitRegister; private readonly IRegister triggerRegister; private readonly IRegister cardRegister; private readonly IRegister upgradeRegister; private readonly IRegister rewardRegister; private readonly IRegister cardUpgradeMaskRegister; private readonly IRegister subtypeRegister; private readonly IRegister vfxRegister; private readonly IRegister relicRegister; private readonly IRegister triggerEnumRegister; private readonly IRegister enhancerPoolRegister; private readonly IRegister relicEffectConditionRegister; private readonly IRegister targetModeRegister; private readonly Lazy saveManager; public RelicEffectDataFinalizer(IModLogger logger, ICache> cache, IRegister tooltipRegister, IRegister cardEffectRegister, IRegister cardPoolRegister, IRegister characterRegister, IRegister traitRegister, IRegister triggerRegister, IRegister cardRegister, IRegister upgradeRegister, IRegister statusRegister, IRegister rewardRegister, IRegister subtypeRegister, IRegister cardUpgradeMaskRegister, IRegister vfxRegister, IRegister relicRegister, IRegister triggerEnumRegister, IRegister enhancerPoolRegister, IRegister relicEffectConditionRegister, IRegister targetModeRegister, GameDataClient client) { this.logger = logger; this.cache = cache; this.tooltipRegister = tooltipRegister; this.cardEffectRegister = cardEffectRegister; this.cardPoolRegister = cardPoolRegister; this.characterRegister = characterRegister; this.traitRegister = traitRegister; this.triggerRegister = triggerRegister; this.cardRegister = cardRegister; this.upgradeRegister = upgradeRegister; statusEffectRegister = statusRegister; this.rewardRegister = rewardRegister; this.cardUpgradeMaskRegister = cardUpgradeMaskRegister; this.subtypeRegister = subtypeRegister; this.vfxRegister = vfxRegister; this.relicRegister = relicRegister; this.triggerEnumRegister = triggerEnumRegister; this.enhancerPoolRegister = enhancerPoolRegister; this.relicEffectConditionRegister = relicEffectConditionRegister; this.targetModeRegister = targetModeRegister; saveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRelicEffectData(cacheItem); } cache.Clear(); } private void FinalizeRelicEffectData(IDefinition definition) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0dec: Unknown result type (might be due to invalid IL or missing references) //IL_0e42: Unknown result type (might be due to invalid IL or missing references) //IL_0e29: Unknown result type (might be due to invalid IL or missing references) //IL_0e2b: Unknown result type (might be due to invalid IL or missing references) //IL_0ef4: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicEffectData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing RelicEffect " + key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); bool? IsModded; foreach (IConfigurationSection child in configuration.GetSection("param_status_effects").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject = child.GetSection("status").ParseReference(); if (referencedObject == null) { continue; } string id = referencedObject.ToId(key, "StatusEffect"); if (statusEffectRegister.TryLookupId(id, out StatusEffectData lookup, out IsModded, referencedObject.context)) { StatusEffectStackData val = new StatusEffectStackData { statusId = lookup.GetStatusId(), count = ((child != null) ? ParseExtensions.ParseInt(child.GetSection("count")) : ((int?)null)).GetValueOrDefault() }; bool? flag; if (child == null) { IsModded = null; flag = IsModded; } else { flag = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); } IsModded = flag; val.fromPermanentUpgrade = IsModded == true; list.Add(val); } } AccessTools.Field(typeof(RelicEffectData), "paramStatusEffects").SetValue(data, list.ToArray()); List list2 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetDeprecatedSection("param_card_effects", "param_effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id2 = item.ToId(key, "Effect"); if (cardEffectRegister.TryLookupId(id2, out CardEffectData lookup2, out IsModded, item.context)) { list2.Add(lookup2); } } if (list2.Count != 0) { AccessTools.Field(typeof(RelicEffectData), "paramCardEffects").SetValue(data, list2); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("param_card_pool").ParseReference(); if (referencedObject2 != null && cardPoolRegister.TryLookupId(referencedObject2.ToId(key, "CardPool"), out CardPool lookup3, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardPool").SetValue(data, lookup3); } List list3 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("param_characters").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item2.ToId(key, "Character"); if (characterRegister.TryLookupName(name, out CharacterData lookup4, out IsModded, item2.context)) { list3.Add(lookup4); } } AccessTools.Field(typeof(RelicEffectData), "paramCharacters").SetValue(data, list3); List list4 = new List(); foreach (IConfigurationSection child2 in configuration.GetSection("param_character_substitution").GetChildren()) { Entry val2 = ParseCharacterSubstitutionEntry(key, child2); if (val2 != null) { list4.Add(val2); } } if (list4.Count > 0) { CharacterSubstitution val3 = ScriptableObject.CreateInstance(); AccessTools.Field(typeof(CharacterSubstitution), "entries").SetValue(val3, list4); AccessTools.Field(typeof(RelicEffectData), "paramCharacterSubstitution").SetValue(data, val3); } List list5 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in configuration.GetSection("traits").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id3 = item3.ToId(key, "Trait"); if (traitRegister.TryLookupId(id3, out CardTraitData lookup5, out IsModded, item3.context)) { list5.Add(lookup5); } } if (list5.Count > 0) { AccessTools.Field(typeof(RelicEffectData), "traits").SetValue(data, list5); } List list6 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in configuration.GetSection("excluded_traits").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id4 = item4.ToId(key, "Trait"); if (traitRegister.TryLookupId(id4, out CardTraitData lookup6, out IsModded, item4.context)) { list6.Add(lookup6); } } if (list6.Count > 0) { AccessTools.Field(typeof(RelicEffectData), "excludedTraits").SetValue(data, list6); } List list7 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in configuration.GetSection("triggers").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id5 = item5.ToId(key, "CTrigger"); if (triggerRegister.TryLookupId(id5, out CharacterTriggerData lookup7, out IsModded, item5.context)) { list7.Add(lookup7); } } if (list7.Count != 0) { AccessTools.Field(typeof(RelicEffectData), "triggers").SetValue(data, list7); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetDeprecatedSection("param_card_data", "param_card").ParseReference(); if (referencedObject3 != null && cardRegister.TryLookupId(referencedObject3.ToId(key, "Card"), out CardData lookup8, out IsModded, referencedObject3.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardData").SetValue(data, lookup8); } ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("param_upgrade").ParseReference(); if (referencedObject4 != null && upgradeRegister.TryLookupName(referencedObject4.ToId(key, "Upgrade"), out CardUpgradeData lookup9, out IsModded, referencedObject4.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardUpgradeData").SetValue(data, lookup9); } ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("param_reward").ParseReference(); if (referencedObject5 != null && rewardRegister.TryLookupName(referencedObject5.ToId(key, "RewardData"), out RewardData lookup10, out IsModded, referencedObject5.context)) { AccessTools.Field(typeof(RelicEffectData), "paramReward").SetValue(data, lookup10); } ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("param_reward_2").ParseReference(); if (referencedObject6 != null && rewardRegister.TryLookupName(referencedObject6.ToId(key, "RewardData"), out RewardData lookup11, out IsModded, referencedObject6.context)) { AccessTools.Field(typeof(RelicEffectData), "paramReward2").SetValue(data, lookup11); } ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("param_grantable_reward").ParseReference(); if (referencedObject7 != null && rewardRegister.TryLookupName(referencedObject7.ToId(key, "RewardData"), out RewardData lookup12, out IsModded, referencedObject7.context)) { GrantableRewardData val4 = (GrantableRewardData)(object)((lookup12 is GrantableRewardData) ? lookup12 : null); if (val4 == null) { logger.Log((LogLevel)4, (object)("RelicEffectData " + definition.Id + " Attempted to add a non-GrantableRewardData RewardData " + ((Object)lookup12).name + ". Ignoring...")); } else { AccessTools.Field(typeof(RelicEffectData), "paramGrantableReward").SetValue(data, val4); } } ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetSection("param_card_filter").ParseReference(); if (referencedObject8 != null && cardUpgradeMaskRegister.TryLookupId(referencedObject8.ToId(key, "UpgradeMask"), out CardUpgradeMaskData lookup13, out IsModded, referencedObject8.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardFilter").SetValue(data, lookup13); } ParseReferenceExtensions.ReferencedObject referencedObject9 = configuration.GetDeprecatedSection("param_card_filter_secondary", "param_card_filter_2").ParseReference(); if (referencedObject9 != null && cardUpgradeMaskRegister.TryLookupId(referencedObject9.ToId(key, "UpgradeMask"), out CardUpgradeMaskData lookup14, out IsModded, referencedObject9.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardFilterSecondary").SetValue(data, lookup14); } ParseReferenceExtensions.ReferencedObject referencedObject10 = configuration.GetSection("param_card_upgrade_mask_data").ParseReference(); if (referencedObject10 != null && cardUpgradeMaskRegister.TryLookupId(referencedObject10.ToId(key, "UpgradeMask"), out CardUpgradeMaskData lookup15, out IsModded, referencedObject10.context)) { AccessTools.Field(typeof(RelicEffectData), "paramCardUpgradeMaskData").SetValue(data, lookup15); } string value = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject11 = configuration.GetDeprecatedSection("character_subtype", "param_subtype").ParseReference(); if (referencedObject11 != null && subtypeRegister.TryLookupId(referencedObject11.ToId(key, "Subtype"), out SubtypeData lookup16, out IsModded, referencedObject11.context)) { value = lookup16.Key; } AccessTools.Field(typeof(RelicEffectData), "paramCharacterSubtype").SetValue(data, value); List list8 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item6 in (from x in configuration.GetDeprecatedSection("excluded_character_subtypes", "param_excluded_subtypes").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (subtypeRegister.TryLookupId(item6.ToId(key, "Subtype"), out SubtypeData lookup17, out IsModded, item6.context)) { list8.Add(lookup17.Key); } } AccessTools.Field(typeof(RelicEffectData), "paramExcludeCharacterSubtypes").SetValue(data, list8.ToArray()); IEnumerable enumerable = (from x in configuration.GetSection("param_card_upgrade_pool").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); if (!IEnumerableUtility.IsNullOrEmpty(enumerable)) { List list9 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item7 in enumerable) { if (item7 != null && upgradeRegister.TryLookupName(item7.ToId(key, "Upgrade"), out CardUpgradeData lookup18, out IsModded, item7.context)) { list9.Add(lookup18); } } CardUpgradePool val5 = ScriptableObject.CreateInstance(); AccessTools.Field(typeof(CardUpgradePool), "cardUpgradeDataList").SetValue(val5, list9); AccessTools.Field(typeof(RelicEffectData), "paramCardUpgradePool").SetValue(data, val5); } ParseReferenceExtensions.ReferencedObject referencedObject12 = configuration.GetSection("applied_vfx").ParseReference(); if (vfxRegister.TryLookupId(referencedObject12?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup19, out IsModded, referencedObject12?.context)) { AccessTools.Field(typeof(RelicEffectData), "appliedVfx").SetValue(data, lookup19); } ParseReferenceExtensions.ReferencedObject referencedObject13 = configuration.GetSection("param_relic").ParseReference(); if (referencedObject13 != null && relicRegister.TryLookupName(referencedObject13.ToId(key, "RelicData"), out RelicData lookup20, out IsModded, referencedObject13.context)) { if (!(lookup20 is CollectableRelicData)) { logger.Log((LogLevel)4, (object)("Relic data name: " + ((lookup20 != null) ? ((Object)lookup20).name : null) + " given is not a CollectableRelicData ignoring.")); } AccessTools.Field(typeof(RelicEffectData), "paramRelic").SetValue(data, (lookup20 is CollectableRelicData) ? lookup20 : null); } ParseReferenceExtensions.ReferencedObject referencedObject14 = configuration.GetSection("param_mutator").ParseReference(); if (referencedObject14 != null && relicRegister.TryLookupName(referencedObject14.ToId(key, "RelicData"), out RelicData lookup21, out IsModded, referencedObject14.context)) { if (!(lookup21 is MutatorData)) { logger.Log((LogLevel)4, (object)("Relic data name: " + ((lookup21 != null) ? ((Object)lookup21).name : null) + " given is not a MutatorData ignoring.")); } AccessTools.Field(typeof(RelicEffectData), "paramMutatorData").SetValue(data, (lookup21 is MutatorData) ? lookup21 : null); } Trigger val6 = (Trigger)0; ParseReferenceExtensions.ReferencedObject referencedObject15 = configuration.GetSection("param_trigger").ParseReference(); if (referencedObject15 != null && triggerEnumRegister.TryLookupId(referencedObject15.ToId(key, "CTriggerEnum"), out var lookup22, out IsModded, referencedObject15.context)) { val6 = lookup22; } AccessTools.Field(typeof(RelicEffectData), "paramTrigger").SetValue(data, val6); ParseReferenceExtensions.ReferencedObject referencedObject16 = configuration.GetSection("param_enhancer_pool").ParseReference(); if (referencedObject16 != null && enhancerPoolRegister.TryLookupId(referencedObject16.ToId(key, "EnhancerPool"), out EnhancerPool lookup23, out IsModded, referencedObject16.context)) { AccessTools.Field(typeof(RelicEffectData), "paramEnhancerPool").SetValue(data, lookup23); } ParseReferenceExtensions.ReferencedObject referencedObject17 = configuration.GetSection("target_mode").ParseReference(); if (referencedObject17 != null) { targetModeRegister.TryLookupId(referencedObject17.ToId(key, "TargetModeEnum"), out var lookup24, out IsModded, referencedObject17.context); AccessTools.Field(typeof(RelicEffectData), "paramTargetMode").SetValue(data, lookup24); } List list10 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item8 in (from x in configuration.GetSection("additional_tooltips").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name2 = item8.ToId(key, "AdditionalTooltip"); if (tooltipRegister.TryLookupName(name2, out AdditionalTooltipData lookup25, out IsModded, item8.context)) { list10.Add(lookup25); } } AccessTools.Field(typeof(RelicEffectData), "additionalTooltips").SetValue(data, list10.ToArray()); int num = ParseExtensions.ParseInt(configuration.GetSection("param_covenant")) ?? (-1); if (num >= 0) { CovenantData ascensionCovenantForLevel = saveManager.Value.GetAllGameData().GetAscensionCovenantForLevel(num); AccessTools.Field(typeof(RelicEffectData), "paramCovenant").SetValue(data, ascensionCovenantForLevel); } List list11 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item9 in (from x in configuration.GetSection("conditions").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name3 = item9.ToId(key, "RelicEffectCondition"); if (relicEffectConditionRegister.TryLookupName(name3, out RelicEffectCondition lookup26, out IsModded, item9.context)) { list11.Add(lookup26); } } AccessTools.Field(typeof(RelicEffectData), "effectConditions").SetValue(data, list11); List list12 = new List(); foreach (IConfigurationSection child3 in configuration.GetSection("param_random_champion_pool").GetChildren()) { GrantedChampionInfo val7 = ParseGrantedChampionInfo(key, child3); if (val7 != null) { list12.Add(val7); } } if (list12.Count > 0) { RandomChampionPool val8 = ScriptableObject.CreateInstance(); (AccessTools.Field(typeof(RandomChampionPool), "championInfoList").GetValue(val8) as ReorderableArray).CopyFrom((IEnumerable)list12); AccessTools.Field(typeof(RelicEffectData), "paramRandomChampionPool").SetValue(data, val8); } List list13 = new List(); foreach (IConfigurationSection child4 in configuration.GetSection("param_card_set_builder").GetChildren()) { CardPull val9 = ParseCardPull(key, child4); if ((Object)(object)val9 != (Object)null) { list13.Add(val9); } } if (list13.Count > 0) { CardSetBuilder val10 = ScriptableObject.CreateInstance(); AccessTools.Field(typeof(CardSetBuilder), "paramCardPulls").SetValue(val10, list13); AccessTools.Field(typeof(RelicEffectData), "paramCardSetBuilder").SetValue(data, val10); } } private GrantedChampionInfo? ParseGrantedChampionInfo(string key, IConfigurationSection configuration) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown if (!configuration.Exists()) { return null; } ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("champion_card").ParseReference(); CardData val = null; if (referencedObject != null && cardRegister.TryLookupName(referencedObject.ToId(key, "Card"), out CardData lookup, out bool? IsModded, referencedObject.context)) { val = lookup; } if ((Object)(object)val == (Object)null) { return null; } List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("upgrades").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (upgradeRegister.TryLookupName(item.ToId(key, "Upgrade"), out CardUpgradeData lookup2, out IsModded, item.context)) { list.Add(lookup2); } } return new GrantedChampionInfo { championCard = val, upgrades = list }; } private Entry? ParseCharacterSubstitutionEntry(string key, IConfigurationSection configuration) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown if (!configuration.Exists()) { return null; } ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("unit_before").ParseReference(); CharacterData val = null; if (referencedObject != null && characterRegister.TryLookupName(referencedObject.ToId(key, "Character"), out CharacterData lookup, out bool? IsModded, referencedObject.context)) { val = lookup; } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("unit_after").ParseReference(); CharacterData val2 = null; if (referencedObject2 != null && characterRegister.TryLookupName(referencedObject2.ToId(key, "Character"), out lookup, out IsModded, referencedObject2.context)) { val2 = lookup; } if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return null; } return new Entry { UnitBefore = val, UnitAfter = val2 }; } private CardPull? ParseCardPull(string key, IConfigurationSection configuration) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) CardPull val = ScriptableObject.CreateInstance(); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("card_pool").ParseReference(); CardPool value = null; if (referencedObject != null && cardPoolRegister.TryLookupName(referencedObject.ToId(key, "CardPool"), out CardPool lookup, out bool? _, referencedObject.context)) { value = lookup; } AccessTools.Field(typeof(CardPull), "cardPool").SetValue(val, value); ClassType val2 = (ClassType)(((??)configuration.GetSection("class_type").ParseClassType()) ?? 1); AccessTools.Field(typeof(CardPull), "classType").SetValue(val, val2); int num = ParseExtensions.ParseInt(configuration.GetSection("num_copies")) ?? 1; if (num <= 0) { num = 1; } AccessTools.Field(typeof(CardPull), "numCopies").SetValue(val, (uint)num); bool valueOrDefault = ParseExtensions.ParseBool(configuration.GetSection("has_rarity_condition")) == true; AccessTools.Field(typeof(CardPull), "hasRarityCondition").SetValue(val, valueOrDefault); CollectableRarity valueOrDefault2 = configuration.GetSection("rarity").ParseRarity().GetValueOrDefault(); AccessTools.Field(typeof(CardPull), "cardRarity").SetValue(val, valueOrDefault2); bool valueOrDefault3 = ParseExtensions.ParseBool(configuration.GetSection("showcase_at_run_start")) == true; AccessTools.Field(typeof(CardPull), "showcaseAtRunStart").SetValue(val, valueOrDefault3); return val; } } public class RelicEffectDataPipeline : IDataPipeline, RelicEffectData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; public RelicEffectDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; } public List> Run(IRegister register) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadRelicEffects(register, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadRelicEffects(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("relic_effects").GetChildren()) { RelicEffectDataDefinition relicEffectDataDefinition = LoadRelicEffectConfiguration(service, key, child); if (relicEffectDataDefinition != null) { list.Add(relicEffectDataDefinition); } } return list; } private RelicEffectDataDefinition? LoadRelicEffectConfiguration(IRegister service, string key, IConfigurationSection config) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_069f: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06bb: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(config.GetSection("id")); if (string.IsNullOrEmpty(text)) { logger.Log((LogLevel)2, (object)"Relic effect configuration missing required 'id' field"); return null; } string id = key.GetId("RelicEffectData", text); RelicEffectData val = new RelicEffectData(); string value = config.GetSection("name").Value; if (value == null) { return null; } string text2 = config.GetSection("mod_reference").Value ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text2, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!value.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load relic effect state name " + value + " in " + text + " mod " + text2 + ", Make sure the class exists in " + text2 + " and that the class inherits from RelicEffectBase.")); return null; } AccessTools.Field(typeof(RelicEffectData), "relicEffectClassName").SetValue(val, fullyQualifiedName); string text3 = "RelicEffectData_tooltipTitleKey-" + id; string text4 = "RelicEffectData_tooltipBodyKey-" + id; LocalizationTerm localizationTerm = config.GetSection("tooltip_titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(RelicEffectData), "tooltipTitleKey").SetValue(val, text3); localizationTerm.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm); } LocalizationTerm localizationTerm2 = config.GetSection("tooltip_body").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(RelicEffectData), "tooltipBodyKey").SetValue(val, text4); localizationTerm2.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm2); } Type valueOrDefault2 = config.GetSection("source_team").ParseTeamType().GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramSourceTeam").SetValue(val, valueOrDefault2); int valueOrDefault3 = ParseExtensions.ParseInt(config.GetSection("param_int")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramInt").SetValue(val, valueOrDefault3); int valueOrDefault4 = ParseExtensions.ParseInt(config.GetSection("param_int_2")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramInt2").SetValue(val, valueOrDefault4); int valueOrDefault5 = ParseExtensions.ParseInt(config.GetSection("param_int_3")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramInt3").SetValue(val, valueOrDefault5); float valueOrDefault6 = ParseExtensions.ParseFloat(config.GetSection("param_float")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramFloat").SetValue(val, valueOrDefault6); bool valueOrDefault7 = ParseExtensions.ParseBool(config.GetSection("use_int_range")) == true; AccessTools.Field(typeof(RelicEffectData), "paramUseIntRange").SetValue(val, valueOrDefault7); int valueOrDefault8 = ParseExtensions.ParseInt(config.GetDeprecatedSection("min_int", "param_min_int")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramMinInt").SetValue(val, valueOrDefault8); int valueOrDefault9 = ParseExtensions.ParseInt(config.GetDeprecatedSection("max_int", "param_max_int")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramMaxInt").SetValue(val, valueOrDefault9); string value2 = ParseExtensions.ParseString(config.GetSection("param_string")) ?? ""; AccessTools.Field(typeof(RelicEffectData), "paramString").SetValue(val, value2); SpecialCharacterType valueOrDefault10 = config.GetDeprecatedSection("special_character_type", "param_special_character_type").ParseSpecialCharacterType().GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramSpecialCharacterType").SetValue(val, valueOrDefault10); bool valueOrDefault11 = ParseExtensions.ParseBool(config.GetSection("param_bool")) == true; AccessTools.Field(typeof(RelicEffectData), "paramBool").SetValue(val, valueOrDefault11); bool valueOrDefault12 = ParseExtensions.ParseBool(config.GetSection("param_bool_2")) == true; AccessTools.Field(typeof(RelicEffectData), "paramBool2").SetValue(val, valueOrDefault12); bool valueOrDefault13 = ParseExtensions.ParseBool(config.GetSection("param_bool_3")) == true; AccessTools.Field(typeof(RelicEffectData), "paramBool3").SetValue(val, valueOrDefault13); bool valueOrDefault14 = ParseExtensions.ParseBool(config.GetSection("param_bool_4")) == true; AccessTools.Field(typeof(RelicEffectData), "paramBool4").SetValue(val, valueOrDefault14); CardType valueOrDefault15 = config.GetDeprecatedSection("card_type", "param_card_type").ParseCardType().GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramCardType").SetValue(val, valueOrDefault15); bool valueOrDefault16 = ParseExtensions.ParseBool(config.GetSection("notification_suppressed")) == true; AccessTools.Field(typeof(RelicEffectData), "notificationSuppressed").SetValue(val, valueOrDefault16); bool valueOrDefault17 = ParseExtensions.ParseBool(config.GetSection("trigger_tooltips_suppressed")) == true; AccessTools.Field(typeof(RelicEffectData), "triggerTooltipsSuppressed").SetValue(val, valueOrDefault17); int valueOrDefault18 = ParseExtensions.ParseInt(config.GetSection("relic_scaling_count")).GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "relicScalingCount").SetValue(val, valueOrDefault18); IConfigurationSection section = config.GetSection("source_card_trait"); string text5 = ParseEffectType(section, key, atlas, text); AccessTools.Field(typeof(RelicEffectData), "sourceCardTraitParam").SetValue(val, text5 ?? ""); IConfigurationSection section2 = config.GetSection("target_card_trait"); string text6 = ParseEffectType(section2, key, atlas, text); AccessTools.Field(typeof(RelicEffectData), "targetCardTraitParam").SetValue(val, text6 ?? ""); RarityTicketType valueOrDefault19 = config.GetDeprecatedSection("rarity_ticket_type", "param_rarity_ticket_type").ParseRarityTicketType().GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramRarityTicketType").SetValue(val, valueOrDefault19); CollectableRarity valueOrDefault20 = config.GetDeprecatedSection("card_rarity_type", "param_card_rarity_type").ParseRarity().GetValueOrDefault(); AccessTools.Field(typeof(RelicEffectData), "paramCardRarityType").SetValue(val, valueOrDefault20); List value3 = config.GetSection("param_rarity_multipliers").GetChildren().Select((Func)((IConfigurationSection x) => new RarityTicketMultiplier { rarityType = x.GetSection("rarity").ParseRarity().GetValueOrDefault(), ticketValueMultiplier = (ParseExtensions.ParseFloat(x.GetSection("multiplier")) ?? 1f) })) .ToList(); AccessTools.Field(typeof(RelicEffectData), "paramRarityMultipliers").SetValue(val, value3); List list = (from x in config.GetSection("card_triggers").GetChildren() select x.ParseCardTriggerType() into x where x.HasValue select x.Value).ToList(); if (list.Count != 0) { AccessTools.Field(typeof(RelicEffectData), "cardTriggers").SetValue(val, list); } ((IRegisterableDictionary)(object)service).Register(id, val); return new RelicEffectDataDefinition(key, val, config) { Id = text }; } private string? ParseEffectType(IConfigurationSection configuration, string key, PluginAtlas atlas, string id) { ParseReferenceExtensions.ReferencedObject referencedObject = configuration.ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { return fullyQualifiedName; } logger.Log((LogLevel)4, (object)("Failed to load class name " + id2 + " in relic_effect " + id + " with mod reference " + text + ", Note that this isn't a reference to a CardTraitData, but a class that inherits from " + typeof(T).Name + ".")); return null; } } public class RelicEffectDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public RelicEffectDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, RelicEffectData item) { logger.Log((LogLevel)32, (object)("Register RelicEffect " + key + "... ")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RelicEffectData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class RelicPoolDefinition : IDefinition { public string Id { get; set; } = ""; public string Key { get; set; } public RelicPool Data { get; set; } public IConfiguration Configuration { get; set; } public bool IsModded => true; public RelicPoolDefinition(string key, RelicPool data, IConfiguration configuration) { Key = key; Data = data; Configuration = configuration; base..ctor(); } } public class RelicPoolFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister relicRegister; public RelicPoolFinalizer(IModLogger logger, ICache> cache, IRegister relicRegister) { this.logger = logger; this.cache = cache; this.relicRegister = relicRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizePoolData(cacheItem); } cache.Clear(); } private void FinalizePoolData(IDefinition definition) { IConfiguration configuration = definition.Configuration; RelicPool data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Relic Pool " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("relics").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string text = item.ToId(key, "RelicData"); if (relicRegister.TryLookupName(text, out RelicData lookup, out bool? _, item.context)) { CollectableRelicData val = (CollectableRelicData)(object)((lookup is CollectableRelicData) ? lookup : null); if (val != null) { list.Add(val); continue; } logger.Log((LogLevel)4, (object)("RelicData " + text + " attempted to be added to RelicPool " + ((Object)data).name + " but it is not a CollectableRelic. Ignoring...")); } } if (list.Count == 0) { return; } ReorderableArray val2 = (ReorderableArray)AccessTools.Field(typeof(RelicPool), "relicDataList").GetValue(data); val2.Clear(); foreach (CollectableRelicData item2 in list) { val2.Add(item2); } AccessTools.Field(typeof(RelicPool), "relicDataList").SetValue(data, val2); } } public class RelicPoolPipeline : IDataPipeline, RelicPool> { private readonly PluginAtlas atlas; private readonly IInstanceGenerator generator; public RelicPoolPipeline(PluginAtlas atlas, IInstanceGenerator generator) { this.atlas = atlas; this.generator = generator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadPools(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadPools(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("relic_pools").GetChildren()) { RelicPoolDefinition relicPoolDefinition = LoadRelicPoolConfiguration(service, key, child); if (relicPoolDefinition != null) { list.Add(relicPoolDefinition); } } return list; } public RelicPoolDefinition? LoadRelicPoolConfiguration(IRegister service, string key, IConfiguration configuration) { string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("RelicPool", text); RelicPool val = generator.CreateInstance(); ((Object)val).name = id; bool flag = false; AccessTools.Field(typeof(RelicPool), "allowRollingDuplicates").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("allow_rolling_duplicates")) ?? flag); ((IRegisterableDictionary)(object)service).Register(id, val); return new RelicPoolDefinition(key, val, configuration) { Id = text }; } } public class RelicPoolRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaRelicPools = new Dictionary(); public RelicPoolRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaRelicPools, Resources.FindObjectsOfTypeAll().ToDictionary((RelicPool x) => ((Object)x).name, (RelicPool x) => x)); Extensions.AddRange((Dictionary)this, VanillaRelicPools); } public void Register(string key, RelicPool item) { logger.Log((LogLevel)16, (object)("Register Relic Pool " + key + "... ")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out RelicPool? lookup, [NotNullWhen(true)] out bool? IsModded) { IsModded = !VanillaRelicPools.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } public class SinsDataFactory : IFactory { public string FactoryKey => "sin"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class SoulDataFactory : IFactory { public string FactoryKey => "soul"; public RelicData? GetValue() { return (RelicData?)(object)ScriptableObject.CreateInstance(); } } public class SoulDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister classRegister; private readonly IRegister soulPoolRegister; private readonly IRegister spriteRegister; private readonly IDataFinalizer decoratee; private readonly FieldInfo SoulPoolRelicDataListField = AccessTools.Field(typeof(SoulPool), "relicDataList"); private readonly FieldInfo LinkedClassField = AccessTools.Field(typeof(SoulData), "linkedClass"); public SoulDataFinalizerDecorator(IModLogger logger, ICache> cache, IRegister classRegister, IRegister soulPoolRegister, IRegister spriteRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.classRegister = classRegister; this.soulPoolRegister = soulPoolRegister; this.spriteRegister = spriteRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRelicData(cacheItem as RelicDataDefinition); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRelicData(RelicDataDefinition definition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; OverrideMode val = definition.Override; string key = definition.Key; definition.Id.ToId(key, "RelicData"); SoulData val2 = (SoulData)(object)((data is SoulData) ? data : null); if (val2 == null) { return; } RelicData copyData = definition.CopyData; SoulData val3 = (SoulData)(object)((copyData is SoulData) ? copyData : null); if (val3 == null) { val3 = val2; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("soul").Exists() select xs.GetSection("soul")).FirstOrDefault(); if (configurationSection == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing SoulData " + definition.Key + " " + definition.Id + " path: " + configurationSection.GetPath() + "...")); AccessTools.Field(typeof(SoulData), "soulTypeIcon").SetValue(data, val3.GetSoulTypeIcon() ?? ((RelicData)val3).GetIcon()); IConfigurationSection section = configurationSection.GetSection("icon"); ParseReferenceExtensions.ReferencedObject referencedObject = section.ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(SoulData), "soulTypeIcon").SetValue(data, lookup); } else if ((int)val == 1 && referencedObject == null && section.Exists()) { AccessTools.Field(typeof(SoulData), "soulTypeIcon").SetValue(data, null); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configurationSection.GetSection("class").ParseReference(); ClassData value = val3.GetLinkedClass(); if (referencedObject2 != null && classRegister.TryLookupName(referencedObject2.ToId(key, "Class"), out ClassData lookup2, out IsModded, referencedObject2.context)) { value = lookup2; } LinkedClassField.SetValue(val2, value); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configurationSection.GetSection("pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item.ToId(key, "SoulPool"); if (soulPoolRegister.TryLookupId(id, out SoulPool lookup3, out IsModded, item.context)) { (SoulPoolRelicDataListField.GetValue(lookup3) as ReorderableArray)?.Add(val2); logger.Log((LogLevel)32, (object)string.Format("Added soul {0} to pool: {1}", definition.Id.ToId(key, "RelicData"), lookup3)); } } } } public class SoulDataPipelineDecorator : IDataPipeline, RelicData> { private readonly IModLogger logger; private readonly IDataPipeline, RelicData> decoratee; private readonly IRegister localizationRegister; private FieldInfo DraftMinDistanceAllowedField = AccessTools.Field(typeof(SoulData), "draftMinDistanceAllowed"); private FieldInfo DraftMaxDistanceAllowedField = AccessTools.Field(typeof(SoulData), "draftMaxDistanceAllowed"); private FieldInfo DraftMinBattlesCompletedField = AccessTools.Field(typeof(SoulData), "draftMinBattlesCompleted"); private FieldInfo DraftMaxBattlesCompletedField = AccessTools.Field(typeof(SoulData), "draftMaxBattlesCompleted"); public SoulDataPipelineDecorator(IModLogger logger, IRegister localizationRegister, IDataPipeline, RelicData> decoratee) { this.logger = logger; this.localizationRegister = localizationRegister; this.decoratee = decoratee; } public List> Run(IRegister register) { List> list = decoratee.Run(register); foreach (IDefinition item in list) { ProcessItem(item as RelicDataDefinition); } return list; } private void ProcessItem(RelicDataDefinition definition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; RelicData data = definition.Data; _ = definition.Override; StringExtensions.ToId(key: definition.Key, baseString: definition.Id, template: "RelicData"); SoulData val = (SoulData)(object)((data is SoulData) ? data : null); if (val == null) { return; } RelicData copyData = definition.CopyData; SoulData val2 = (SoulData)(object)((copyData is SoulData) ? copyData : null); if (val2 == null) { val2 = val; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("soul").Exists() select xs.GetSection("soul")).FirstOrDefault(); if (configurationSection == null) { return; } int num = ParseExtensions.ParseInt(configurationSection.GetSection("tier_level")) ?? val2.GetTierLevel(); AccessTools.Field(typeof(SoulData), "tierLevel").SetValue(val, num); DLC val3 = (DLC)(((??)configurationSection.GetSection("required_dlc").ParseDLC()) ?? val2.GetRequiredDLC()); AccessTools.Field(typeof(SoulData), "requiredDLC").SetValue(val, val3); int num2 = ParseExtensions.ParseInt(configurationSection.GetSection("unlock_level")) ?? val2.GetUnlockLevel(); AccessTools.Field(typeof(SoulData), "unlockLevel").SetValue(val, num2); IConfigurationSection section = configurationSection.GetSection("unlock_criteria"); UnlockCriteria unlockCriteria = val2.GetUnlockCriteria(); if (section.Exists()) { UnlockCriteria unlockCriteria2 = val.GetUnlockCriteria(); LocalizationTerm localizationTerm = section.GetSection("descriptions").ParseLocalizationTerm(); string text = unlockCriteria.GetDescriptionKey(); if (localizationTerm != null) { text = (localizationTerm.Key = "SoulData_descriptionKey-" + ((RelicData)val).GetAssetKey()); ((IRegisterableDictionary)(object)localizationRegister).Register(text, localizationTerm); } AccessTools.Field(typeof(UnlockCriteria), "descriptionKey").SetValue(unlockCriteria2, text); TrackedValue val4 = (TrackedValue)(((??)section.GetSection("unlock_condition").ParseTrackedValue()) ?? unlockCriteria.GetUnlockCondition()); AccessTools.Field(typeof(UnlockCriteria), "unlockCondition").SetValue(unlockCriteria2, val4); int num3 = ParseExtensions.ParseInt(section.GetSection("param_int")) ?? unlockCriteria.GetParamInt(); AccessTools.Field(typeof(UnlockCriteria), "paramInt").SetValue(unlockCriteria2, num3); } else { AccessTools.Field(typeof(SoulData), "unlockData").SetValue(val, unlockCriteria); } int? num4 = ParseExtensions.ParseInt(configurationSection.GetSection("draft_min_distance_allowed")); object value = (num4.HasValue ? ((object)num4.GetValueOrDefault()) : DraftMinDistanceAllowedField.GetValue(val2)); DraftMinDistanceAllowedField.SetValue(val, value); num4 = ParseExtensions.ParseInt(configurationSection.GetSection("draft_max_distance_allowed")); object value2 = (num4.HasValue ? ((object)num4.GetValueOrDefault()) : DraftMaxDistanceAllowedField.GetValue(val2)); DraftMaxDistanceAllowedField.SetValue(val, value2); num4 = ParseExtensions.ParseInt(configurationSection.GetSection("draft_min_battles_completed")); object value3 = (num4.HasValue ? ((object)num4.GetValueOrDefault()) : DraftMinBattlesCompletedField.GetValue(val2)); DraftMinBattlesCompletedField.SetValue(val, value3); num4 = ParseExtensions.ParseInt(configurationSection.GetSection("draft_max_battles_completed")); object value4 = (num4.HasValue ? ((object)num4.GetValueOrDefault()) : DraftMaxBattlesCompletedField.GetValue(val2)); DraftMaxBattlesCompletedField.SetValue(val, value4); } } public class SoulPoolDefinition : IDefinition { public string Id { get; set; } = ""; public string Key { get; set; } public SoulPool Data { get; set; } public IConfiguration Configuration { get; set; } public bool IsModded => true; public SoulPoolDefinition(string key, SoulPool data, IConfiguration configuration) { Key = key; Data = data; Configuration = configuration; base..ctor(); } } public class SoulPoolFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister relicRegister; public SoulPoolFinalizer(IModLogger logger, ICache> cache, IRegister relicRegister) { this.logger = logger; this.cache = cache; this.relicRegister = relicRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizePoolData(cacheItem); } cache.Clear(); } private void FinalizePoolData(IDefinition definition) { IConfiguration configuration = definition.Configuration; SoulPool data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Soul Pool " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("souls").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string text = item.ToId(key, "RelicData"); if (relicRegister.TryLookupName(text, out RelicData lookup, out bool? _, item.context)) { SoulData val = (SoulData)(object)((lookup is SoulData) ? lookup : null); if (val != null) { list.Add(val); continue; } logger.Log((LogLevel)4, (object)("RelicData " + text + " attempted to be added to SoulPool " + ((Object)data).name + " but it is not a SoulData. Ignoring...")); } } if (list.Count == 0) { return; } ReorderableArray val2 = (ReorderableArray)AccessTools.Field(typeof(SoulPool), "relicDataList").GetValue(data); val2.Clear(); foreach (SoulData item2 in list) { val2.Add(item2); } AccessTools.Field(typeof(EnhancerPool), "relicDataList").SetValue(data, val2); } } public class SoulPoolPipeline : IDataPipeline, SoulPool> { private readonly PluginAtlas atlas; private readonly IInstanceGenerator generator; public SoulPoolPipeline(PluginAtlas atlas, IInstanceGenerator generator) { this.atlas = atlas; this.generator = generator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadPools(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadPools(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("soul_pools").GetChildren()) { SoulPoolDefinition soulPoolDefinition = LoadSoulPoolConfiguration(service, key, child); if (soulPoolDefinition != null) { list.Add(soulPoolDefinition); } } return list; } public SoulPoolDefinition? LoadSoulPoolConfiguration(IRegister service, string key, IConfiguration configuration) { string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("SoulPool", text); SoulPool val = generator.CreateInstance(); ((Object)val).name = id; ((IRegisterableDictionary)(object)service).Register(id, val); return new SoulPoolDefinition(key, val, configuration) { Id = text }; } } public class SoulPoolRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaSoulPools = new Dictionary(); public SoulPoolRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaSoulPools, Resources.FindObjectsOfTypeAll().ToDictionary((SoulPool x) => ((Object)x).name, (SoulPool x) => x)); Extensions.AddRange((Dictionary)this, VanillaSoulPools); } public void Register(string key, SoulPool item) { logger.Log((LogLevel)16, (object)("Register SoulPool " + key + "...")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out SoulPool? lookup, [NotNullWhen(true)] out bool? IsModded) { IsModded = !VanillaSoulPools.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Pyre { public class PyreHeartDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister relicRegister; private readonly IRegister gameObjectRegister; private readonly IRegister spriteRegister; public PyreHeartDataFinalizer(IModLogger logger, ICache> cache, IRegister gameObjectRegister, IRegister relicRegister, IRegister spriteRegister) { this.logger = logger; this.cache = cache; this.gameObjectRegister = gameObjectRegister; this.relicRegister = relicRegister; this.spriteRegister = spriteRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeItem(cacheItem); } cache.Clear(); } private void FinalizeItem(IDefinition definition) { IConfiguration configuration = definition.Configuration; PyreHeartData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Pyre Heart " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("pyre_artifact").ParseReference(); if (referencedObject != null && relicRegister.TryLookupName(referencedObject.ToId(key, "RelicData"), out RelicData lookup, out bool? IsModded, referencedObject.context)) { if (lookup is PyreArtifactData) { AccessTools.Field(typeof(PyreHeartData), "pyreArtifact").SetValue(data, lookup); } else { logger.Log((LogLevel)4, (object)("PyreHeartData " + definition.Id + " Attempted to add a non-PyreArtifactData RelicData " + ((Object)lookup).name + ". Ignoring...")); } } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("icon").ParseReference(); if (referencedObject2 != null && spriteRegister.TryLookupName(referencedObject2.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(PyreHeartData), "icon").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("icon_win").ParseReference(); if (referencedObject3 != null && spriteRegister.TryLookupName(referencedObject3.ToId(key, "Sprite"), out Sprite lookup3, out IsModded, referencedObject3.context)) { AccessTools.Field(typeof(PyreHeartData), "iconWin").SetValue(data, lookup3); } ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("icon_boss_win").ParseReference(); if (referencedObject4 != null && spriteRegister.TryLookupName(referencedObject4.ToId(key, "Sprite"), out Sprite lookup4, out IsModded, referencedObject4.context)) { AccessTools.Field(typeof(PyreHeartData), "iconBossWin").SetValue(data, lookup4); } ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("icon_defeat").ParseReference(); if (referencedObject5 != null && spriteRegister.TryLookupName(referencedObject5.ToId(key, "Sprite"), out Sprite lookup5, out IsModded, referencedObject5.context)) { AccessTools.Field(typeof(PyreHeartData), "iconDefeat").SetValue(data, lookup5); } ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("vfx_activated_popup").ParseReference(); if (referencedObject6 != null && gameObjectRegister.TryLookupName(referencedObject6.ToId(key, "GameObject"), out GameObject lookup6, out IsModded, referencedObject6.context)) { AccessTools.Field(typeof(PyreHeartData), "vfxActivatedPopupPrefab").SetValue(data, lookup6); } ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("vfx_activated_hud").ParseReference(); if (referencedObject7 != null && gameObjectRegister.TryLookupName(referencedObject7.ToId(key, "GameObject"), out GameObject lookup7, out IsModded, referencedObject7.context)) { AccessTools.Field(typeof(PyreHeartData), "vfxActivatedHudPrefab").SetValue(data, lookup7); } } } public class PyreHeartDataPipeline : IDataPipeline, PyreHeartData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister localizationService; public PyreHeartDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister localizationService) { this.atlas = atlas; this.logger = logger; this.localizationService = localizationService; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadItems(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadItems(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("pyre_hearts").GetChildren()) { PyreHeartDefinition pyreHeartDefinition = LoadConfiguration(service, key, child); if (pyreHeartDefinition != null) { list.Add(pyreHeartDefinition); } } return list; } private PyreHeartDefinition? LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("PyreHeart", text); PyreHeartData val = new PyreHeartData(); LocalizationTerm localizationTerm = configuration.GetSection("activated_texts").ParseLocalizationTerm(); if (localizationTerm != null) { string value = (localizationTerm.Key = "PyreHeartData_activatedText-" + id); ((IRegisterableDictionary)(object)localizationService).Register(localizationTerm.Key, localizationTerm); AccessTools.Field(typeof(PyreHeartData), "activatedKey").SetValue(val, value); } int num = ParseExtensions.ParseInt(configuration.GetSection("hp")) ?? val.GetStartingHP(); AccessTools.Field(typeof(PyreHeartData), "startingHP").SetValue(val, num); int num2 = ParseExtensions.ParseInt(configuration.GetSection("attack")) ?? val.GetAttack(); AccessTools.Field(typeof(PyreHeartData), "attack").SetValue(val, num2); int[] value2 = (from x in configuration.GetSection("upgrade_hp").GetChildren() select ParseExtensions.ParseInt(x) into x where x.HasValue select x).Cast().ToArray(); AccessTools.Field(typeof(PyreHeartData), "upgradeHP").SetValue(val, value2); int[] value3 = (from x in configuration.GetSection("upgrade_attack").GetChildren() select ParseExtensions.ParseInt(x) into x where x.HasValue select x).Cast().ToArray(); AccessTools.Field(typeof(PyreHeartData), "upgradeAttack").SetValue(val, value3); Color val2 = (Color)(((??)configuration.GetSection("body_color").ParseColor()) ?? val.GetBodyColor()); AccessTools.Field(typeof(PyreHeartData), "bodyColor").SetValue(val, val2); IConfigurationSection section = configuration.GetSection("unlock_criteria"); if (section.Exists()) { UnlockCriteria unlockData = val.GetUnlockData(); ParseCriteria(id, unlockData, section); } ((IRegisterableDictionary)(object)service).Register(id, val); return new PyreHeartDefinition(key, val, configuration) { Id = text }; } private void ParseCriteria(string name, UnlockCriteria data, IConfigurationSection configuration) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) int valueOrDefault = ParseExtensions.ParseInt(configuration.GetSection("param_int")).GetValueOrDefault(); AccessTools.Field(typeof(UnlockCriteria), "paramInt").SetValue(data, valueOrDefault); TrackedValue valueOrDefault2 = configuration.GetSection("condition").ParseTrackedValue().GetValueOrDefault(); AccessTools.Field(typeof(UnlockCriteria), "unlockCondition").SetValue(data, valueOrDefault2); LocalizationTerm localizationTerm = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm != null) { string value = (localizationTerm.Key = "PyreHeartData_unlockDescription-" + name); ((IRegisterableDictionary)(object)localizationService).Register(localizationTerm.Key, localizationTerm); AccessTools.Field(typeof(UnlockCriteria), "descriptionKey").SetValue(data, value); } } } public class PyreHeartDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public PyreHeartDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, PyreHeartData item) { logger.Log((LogLevel)32, (object)("Register Pyre Heart " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out PyreHeartData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class PyreHeartDefinition(string key, PyreHeartData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public PyreHeartData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } } namespace TrainworksReloaded.Base.Prefab { public class AssetReferenceGameObjectRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IRegister objectRegister; public AssetReferenceGameObjectRegister(IRegister objectRegister) { this.objectRegister = objectRegister; } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return objectRegister.GetAllIdentifiers(identifierType); } public void Register(string key, AssetReferenceGameObject item) { } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out AssetReferenceGameObject? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) lookup = null; IsModded = false; if ((int)identifierType != 0) { if ((int)identifierType == 1) { if (objectRegister.TryLookupId(identifier, out GameObject lookup2, out bool? IsModded2)) { lookup = new AssetReferenceGameObject(); IsModded = IsModded2; ((AssetReference)(object)lookup).SetAssetAndId(((object)Hash128.Compute(identifier)/*cast due to .constrained prefix*/).ToString(), (Object)(object)lookup2); return true; } lookup = new AssetReferenceGameObject(); ((AssetReference)(object)lookup).SetId(identifier); return true; } return false; } if (objectRegister.TryLookupName(identifier, out GameObject lookup3, out bool? IsModded3)) { lookup = new AssetReferenceGameObject(); IsModded = IsModded3; ((AssetReference)(object)lookup).SetAssetAndId(((object)Hash128.Compute(identifier)/*cast due to .constrained prefix*/).ToString(), (Object)(object)lookup3); return true; } lookup = new AssetReferenceGameObject(); ((AssetReference)(object)lookup).SetId(identifier); return true; } } public class AtlasIconDefinition(string key, Texture2D data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public Texture2D Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class AtlasIconFinalizer(ICache> cache) : IDataFinalizer { private readonly ICache> cache = cache; public void FinalizeData() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown List list = new List(); foreach (IDefinition cacheItem in cache.GetCacheItems()) { list.Add(cacheItem.Data); } cache.Clear(); Texture2D val = new Texture2D(2, 2); Rect[] array = val.PackTextures(list.ToArray(), 6); TMP_SpriteAsset val2 = ScriptableObject.CreateInstance(); ((Object)val2).name = "Trainworks Sprite Atlas"; ((TMP_Asset)val2).hashCode = TMP_TextUtilities.GetSimpleHashCode(((Object)val2).name); val2.spriteSheet = (Texture)(object)val; val2.spriteInfoList = new List(); ((TMP_Asset)val2).material = new Material(Shader.Find("TextMeshPro/Sprite")) { mainTexture = (Texture)(object)val }; List spriteGlyphTable = val2.spriteGlyphTable; List spriteCharacterTable = val2.spriteCharacterTable; GlyphMetrics metrics = default(GlyphMetrics); ((GlyphMetrics)(ref metrics))..ctor(24f, 24f, 0f, 20f, 24f); for (int i = 0; i < array.Length; i++) { Texture2D val3 = list[i]; Rect val4 = array[i]; int num = (int)(((Rect)(ref val4)).x * (float)((Texture)val).width); int num2 = (int)(((Rect)(ref val4)).y * (float)((Texture)val).height); Sprite val5 = Sprite.Create(val, new Rect((float)num, (float)num2, (float)((Texture)val3).width, (float)((Texture)val3).height), new Vector2(0.5f, 0.5f), 128f); ((Object)val5).name = ((Object)val3).name; TMP_SpriteGlyph val6 = new TMP_SpriteGlyph { index = (uint)i, sprite = val5, metrics = metrics, glyphRect = new GlyphRect(num, num2, ((Texture)val3).width, ((Texture)val3).height), scale = 1f, atlasIndex = 0 }; spriteGlyphTable.Add(val6); TMP_SpriteCharacter item = new TMP_SpriteCharacter { glyph = (Glyph)(object)val6, glyphIndex = (uint)i, unicode = 65534u, name = ((Object)val5).name, scale = 1f }; spriteCharacterTable.Add(item); } val2.UpdateLookupTables(); TMP_Settings.defaultSpriteAsset.fallbackSpriteAssets.Add(val2); } } public class AtlasIconPipeline : IDataPipeline, Texture2D> { private readonly PluginAtlas atlas; private readonly IModLogger logger; public AtlasIconPipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("atlas_icons").GetChildren()) { string value = child.GetSection("id").Value; string value2 = child.GetSection("path").Value; if (value2 == null || value == null) { continue; } string id = key.GetId("Sprite", value); foreach (string assetDirectory in pluginDefinition.Value.AssetDirectories) { string text = Path.Combine(assetDirectory, value2); if (!File.Exists(text)) { logger.Log((LogLevel)4, (object)("Could not find asset at path: " + text + ". Atlas icon will not exist.")); continue; } byte[] array = File.ReadAllBytes(text); Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, array)) { logger.Log((LogLevel)4, (object)("Could not load image at path: " + text + ". Atlas icon will not exist.")); continue; } ((Object)val).name = id; ((IRegisterableDictionary)(object)service).Register(id, val); AtlasIconDefinition item = new AtlasIconDefinition(key, val, child) { Id = value }; list.Add((IDefinition)(object)item); break; } } } return list; } } public struct EffectLayer { public EffectType type; public Texture2D? texture; public Texture2D? motion_texture; public Texture2D? mask_texture; public Color tint; public Vector2 linear_offset; public Vector2 linear_speed; public Vector3 tilt; public Vector3 rotation_speed; public Vector2 scale; public Vector2 position_offset; public bool stretch; public bool additive; public bool enabled; public EffectLayer() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) type = (EffectType)0; texture = null; motion_texture = null; mask_texture = null; tint = Color.white; linear_offset = Vector2.zero; linear_speed = Vector2.zero; tilt = Vector3.zero; rotation_speed = Vector3.zero; scale = Vector2.one; position_offset = Vector2.zero; stretch = true; additive = true; enabled = true; } } public struct EffectTransform { public string name; public int[] layers; public Vector3 position; public Vector3 rotation; public Vector3 scale; public EffectTransform() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) name = string.Empty; layers = Array.Empty(); position = Vector3.zero; rotation = Vector3.zero; scale = Vector3.one; } } public class FallbackDataProvider { private readonly Lazy SaveManager; public FallbackData FallbackData => (FallbackData)AccessTools.Field(typeof(CardData), "fallbackData").GetValue(SaveManager.Value.GetAllGameData().GetAllCardData().First()); public FallbackDataProvider(GameDataClient client) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); } } public class GameObjectBattleIconDecorator : IDataPipeline, GameObject> { private readonly IModLogger logger; private readonly IDataPipeline, GameObject> decoratee; private readonly IRegister spriteRegister; private readonly Lazy indicatorSprite; private readonly Lazy highlightSprite; public GameObjectBattleIconDecorator(IModLogger logger, IDataPipeline, GameObject> decoratee, GameDataClient client, IRegister spriteRegister) { this.logger = logger; this.decoratee = decoratee; this.spriteRegister = spriteRegister; indicatorSprite = new Lazy((Func)delegate { Image? obj = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Image xs) => ((Object)xs).name == "Selected indicator")); return (obj == null) ? null : obj.sprite; }); highlightSprite = new Lazy((Func)delegate { client.TryGetProvider(out SaveManager provider); ScenarioData obj = ((provider != null) ? provider.GetAllGameData().FindScenarioDataByName("Level3BattleHeavyHitter_PushAttack") : null); if (obj == null) { return (Sprite?)null; } GameObject mapNodePrefab = obj.GetMapNodePrefab(); if (mapNodePrefab == null) { return (Sprite?)null; } Transform obj2 = mapNodePrefab.transform.Find("Art root/Highlight"); if (obj2 == null) { return (Sprite?)null; } Image component = ((Component)obj2).GetComponent(); return (component == null) ? null : component.sprite; }); } public List> Run(IRegister service) { List> list = decoratee.Run(service); foreach (IDefinition item in list) { Setup(item); } return list; } public void Setup(IDefinition definition) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_040c: 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_0438: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) if (definition.Configuration.GetSection("type").Value != "battle_node_icon") { return; } IConfigurationSection section = definition.Configuration.GetSection("extensions").GetSection("battle_node_icon"); GameObject data = definition.Data; data.SetActive(true); RectTransform obj = data.AddComponent(); BattleNodeIcon obj2 = data.AddComponent(); data.AddComponent(); data.AddComponent(); obj.sizeDelta = new Vector2(120f, 120f); GameObject val = new GameObject { name = "Art root" }; RectTransform obj3 = val.AddComponent(); val.transform.SetParent(data.transform); obj3.sizeDelta = new Vector2(0f, 0f); obj3.anchoredPosition = new Vector2(0f, -5f); GameObject val2 = new GameObject { name = "Selected Indicator" }; RectTransform obj4 = val2.AddComponent(); val2.AddComponent(); obj4.sizeDelta = new Vector2(155f, 140f); obj4.anchoredPosition = new Vector2(-1f, 0f); val2.transform.SetParent(data.transform); val2.AddComponent().sprite = indicatorSprite.Value; AccessTools.Field(typeof(BattleNodeIcon), "selectionIndicator").SetValue(obj2, val2); GameObject val3 = new GameObject { name = "Highlight" }; RectTransform obj5 = val3.AddComponent(); val3.AddComponent(); obj5.sizeDelta = new Vector2(136f, 127f); obj5.anchoredPosition = new Vector2(0f, 5.7f); val3.transform.SetParent(val.transform); val3.AddComponent().sprite = highlightSprite.Value; AccessTools.Field(typeof(BattleNodeIcon), "highlight").SetValue(obj2, val3); GameObject val4 = GetIconSprite(spriteRef: section.GetSection("completed_sprite").ParseReference(), key: definition.Key, name: "Completed"); if ((Object)(object)val4 != (Object)null) { val4.transform.SetParent(val.transform); RectTransform component = val4.GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.offsetMin = new Vector2(-77f, -82f); component.offsetMax = new Vector2(77f, 64f); component.pivot = new Vector2(0.5f, 0.5f); } AccessTools.Field(typeof(BattleNodeIcon), "completedIcon").SetValue(obj2, val4); } GameObject val5 = GetIconSprite(spriteRef: section.GetSection("active_sprite").ParseReference(), key: definition.Key, name: "Active"); if ((Object)(object)val5 != (Object)null) { val5.transform.SetParent(val.transform); RectTransform component2 = val5.GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.offsetMin = new Vector2(-72.5f, -67.5f); component2.offsetMax = new Vector2(72.5f, 67.5f); component2.pivot = new Vector2(0.5f, 0.5f); } AccessTools.Field(typeof(BattleNodeIcon), "activeIcon").SetValue(obj2, val5); } ParseReferenceExtensions.ReferencedObject spriteRef = section.GetSection("inactive_sprite").ParseReference(); GameObject iconSprite = GetIconSprite(definition.Key, spriteRef, "Inactive"); if ((Object)(object)iconSprite != (Object)null) { iconSprite.transform.SetParent(val.transform); RectTransform component3 = iconSprite.GetComponent(); if ((Object)(object)component3 != (Object)null) { component3.anchorMin = new Vector2(0.5f, 0.5f); component3.anchorMax = new Vector2(0.5f, 0.5f); component3.offsetMin = new Vector2(-72.5f, -67.5f); component3.offsetMax = new Vector2(72.5f, 67.5f); component3.pivot = new Vector2(0.5f, 0.5f); } AccessTools.Field(typeof(BattleNodeIcon), "inactiveIcon").SetValue(obj2, iconSprite); } } public GameObject? GetIconSprite(string key, ParseReferenceExtensions.ReferencedObject? spriteRef, string name) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown if (spriteRef == null) { return null; } if (!spriteRegister.TryLookupId(spriteRef.ToId(key, "Sprite"), out Sprite lookup, out bool? _, spriteRef.context)) { return null; } GameObject val = new GameObject { name = name }; val.AddComponent(); val.AddComponent(); Image obj = val.AddComponent(); obj.sprite = lookup; obj.preserveAspect = true; ((Graphic)obj).SetNativeSize(); return val; } } public class GameObjectCardArtDecorator : IDataPipeline, GameObject> { private readonly IDataPipeline, GameObject> decoratee; private readonly IRegister textureRegister; private readonly IRegister spriteRegister; private readonly IModLogger logger; private static readonly Lazy DefaultCardArtMaterial = new Lazy((Func)(() => ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Material m) => ((Object)m).name == "CardMaterial_PunkrockReveler")))); private static readonly FieldInfo LayerTransformsField = AccessTools.Field(typeof(AnimateCardEffects), "_layerTransforms"); private static readonly FieldInfo TransformPositionField = AccessTools.Field(typeof(CardEffectTransform), "position"); private static readonly FieldInfo TransformRotationField = AccessTools.Field(typeof(CardEffectTransform), "rotation"); private static readonly FieldInfo TransformScaleField = AccessTools.Field(typeof(CardEffectTransform), "scale"); public GameObjectCardArtDecorator(IDataPipeline, GameObject> decoratee, IModLogger logger, IRegister textureRegister, IRegister spriteRegister) { this.decoratee = decoratee; this.logger = logger; this.textureRegister = textureRegister; this.spriteRegister = spriteRegister; } public List> Run(IRegister service) { List> list = decoratee.Run(service); foreach (IDefinition item in list) { Setup(item); } return list; } public void Setup(IDefinition definition) { if (!(definition.Configuration.GetSection("type").Value != "card_art")) { IConfigurationSection section = definition.Configuration.GetSection("extensions").GetSection("card_art"); if (section.GetSection("base_layer").Exists()) { SetupAnimatedCardArt(definition, section); } else { SetupStaticCardArt(definition, section); } } } private void SetupAnimatedCardArt(IDefinition definition, IConfiguration config) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) EffectLayer[] array = new EffectLayer[9]; EffectLayer effectLayer = ParseEffectLayer(definition.Key, config.GetSection("base_layer")); if ((Object)(object)effectLayer.texture == (Object)null) { logger.Log((LogLevel)2, (object)("Base layer does not have a texture set, mod: " + definition.Key + " id: " + definition.Id + " path: " + config.GetPath())); return; } int num = 1; array[0] = effectLayer; foreach (IConfigurationSection child in config.GetSection("layers").GetChildren()) { EffectLayer effectLayer2 = ParseEffectLayer(definition.Key, child); array[num] = effectLayer2; num++; } List list = new List(); foreach (IConfigurationSection child2 in config.GetSection("transforms").GetChildren()) { EffectTransform item = ParseEffectTransform(child2); list.Add(item); } GameObject data = definition.Data; data.layer = 5; data.AddComponent(); data.AddComponent(); GameObject val = new GameObject { name = "CardSprite" }; val.transform.SetParent(data.transform); CanvasRenderer val2 = val.AddComponent(); Image val3 = val.AddComponent(); Texture2D texture = effectLayer.texture; val3.sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f)); RectTransform component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; component.pivot = new Vector2(0.5f, 0.5f); } AnimateCardEffects obj = val.AddComponent(); CardEffectTransform[] array2 = LayerTransformsField.GetValue(obj) as CardEffectTransform[]; Material val4 = new Material(Shader.Find(config.GetSection("shader").Value ?? "Shiny Shoe/CardEffects")) { name = "CardMaterial_" + ((Object)data).name }; val4.CopyPropertiesFromMaterial(DefaultCardArtMaterial.Value); for (int i = 0; i < array.Length; i++) { SetMaterialLayerProperties(val4, i + 1, array[i]); } ((Graphic)val3).material = val4; val2.materialCount = 1; val2.SetMaterial(val4, 0); GameObject val5 = new GameObject { name = "CardEffectTransforms" }; val5.transform.SetParent(data.transform); foreach (EffectTransform item2 in list) { GameObject val6 = new GameObject(item2.name); val6.transform.SetParent(val5.transform); CardEffectTransform val7 = val6.AddComponent(); TransformPositionField.SetValue(val7, item2.position); TransformRotationField.SetValue(val7, item2.rotation); TransformScaleField.SetValue(val7, item2.scale); int[] layers = item2.layers; foreach (int num2 in layers) { array2[num2] = val7; } } } private void SetMaterialLayerProperties(Material material, int index, EffectLayer layer) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) string text = $"_Layer{index}"; material.SetFloat(text + "Enabled", (float)(layer.enabled ? 1 : 0)); material.SetFloat(text + "Type", (float)layer.type); material.SetFloat(text + "Stretch", (float)(layer.stretch ? 1 : 0)); material.SetFloat(text + "Additive", (float)(layer.additive ? 1 : 0)); material.SetTexture(text + "Tex", (Texture)(object)layer.texture); material.SetTexture(text + "Motion", (Texture)(object)layer.motion_texture); material.SetTexture(text + "Mask", (Texture)(object)layer.mask_texture); material.SetColor(text + "ColorTint", layer.tint); material.SetVector(text + "LinearOffset", Vector4.op_Implicit(layer.linear_offset)); material.SetVector(text + "LinearSpeed", Vector4.op_Implicit(layer.linear_speed)); material.SetVector(text + "Tilt", Vector4.op_Implicit(layer.tilt)); material.SetVector(text + "RotationSpeed", Vector4.op_Implicit(layer.rotation_speed)); material.SetVector(text + "Scale", Vector4.op_Implicit(layer.scale)); material.SetVector(text + "PosOffset", Vector4.op_Implicit(layer.position_offset)); } private EffectLayer ParseEffectLayer(string key, IConfiguration layerConfig) { //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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) EffectLayer result = new EffectLayer(); result.type = ParseType(layerConfig.GetSection("type").Value); result.texture = ParseTexture(key, layerConfig.GetSection("texture").ParseReference()); result.motion_texture = ParseTexture(key, layerConfig.GetSection("motion_texture").ParseReference()); result.mask_texture = ParseTexture(key, layerConfig.GetSection("mask_texture").ParseReference()); result.tint = (Color)(((??)layerConfig.GetSection("tint").ParseColor()) ?? Color.white); result.linear_offset = layerConfig.GetSection("linear_offset").ParseVec2(); result.linear_speed = layerConfig.GetSection("linear_speed").ParseVec2(); result.tilt = layerConfig.GetSection("tilt").ParseVec3(); result.rotation_speed = layerConfig.GetSection("rotation_speed").ParseVec3(); result.scale = layerConfig.GetSection("scale").ParseVec2(1f, 1f); result.position_offset = layerConfig.GetSection("position_offset").ParseVec2(); result.stretch = ParseExtensions.ParseBool(layerConfig.GetSection("stretch")) ?? true; result.additive = ParseExtensions.ParseBool(layerConfig.GetSection("additive")) ?? true; result.enabled = ParseExtensions.ParseBool(layerConfig.GetSection("enabled")) ?? true; return result; } private EffectTransform ParseEffectTransform(IConfigurationSection transformConfig) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) EffectTransform result = new EffectTransform(); result.name = transformConfig.GetSection("id").Value ?? ""; result.layers = (from x in transformConfig.GetSection("layers").GetChildren() select ParseExtensions.ParseInt(x) into x where x.HasValue select x).Cast().ToArray(); result.position = transformConfig.GetSection("position").ParseVec3(); result.rotation = transformConfig.GetSection("rotation").ParseVec3(); result.scale = transformConfig.GetSection("scale").ParseVec3(1f, 1f, 1f); return result; } private Texture2D? ParseTexture(string key, ParseReferenceExtensions.ReferencedObject? reference) { if (reference == null) { return null; } textureRegister.TryLookupId(reference.ToId(key, "Sprite"), out Texture2D lookup, out bool? _, reference.context); return lookup; } private EffectType ParseType(string? type) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) if (type == null) { return (EffectType)0; } return (EffectType)(type.ToLower() switch { "none" => 0, "texture" => 1, "distortion" => 2, "flowing_texture" => 3, "moving_texture" => 4, "dissolve" => 5, "glow" => 6, _ => 0, }); } private void SetupStaticCardArt(IDefinition definition, IConfiguration config) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) ParseReferenceExtensions.ReferencedObject referencedObject = config.GetSection("sprite").ParseReference(); if (referencedObject == null) { return; } string id = referencedObject.ToId(definition.Key, "Sprite"); if (spriteRegister.TryLookupId(id, out Sprite lookup, out bool? _, referencedObject.context)) { GameObject data = definition.Data; data.layer = 5; data.AddComponent(); data.AddComponent(); GameObject val = new GameObject { name = "CardSprite" }; val.transform.SetParent(data.transform); CanvasRenderer val2 = val.AddComponent(); Image val3 = val.AddComponent(); val3.sprite = lookup; val3.preserveAspect = true; ((Graphic)val3).SetNativeSize(); RectTransform component = val.GetComponent(); if ((Object)(object)component != (Object)null) { component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; component.pivot = new Vector2(0.5f, 0.5f); } Material val4 = new Material(Shader.Find("Shiny Shoe/CardEffects")) { mainTexture = (Texture)(object)lookup.texture }; val4.SetTexture("_Layer1Tex", (Texture)(object)lookup.texture); ((Graphic)val3).material = val4; val2.materialCount = 1; val2.SetMaterial(val4, 0); new GameObject { name = "CardEffectTransforms" }.transform.SetParent(data.transform); } } } public class GameObjectCharacterArtFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly FallbackDataProvider fallbackDataProvider; private readonly IRegister spriteRegister; private readonly IRegister skeletonRegister; private readonly IDataFinalizer decoratee; private static Material? defaultQuadMaterial; private static readonly Dictionary ANIM_NAMES = new Dictionary { { (Anim)1, "Idle" }, { (Anim)2, "Attack" }, { (Anim)3, "HitReact" }, { (Anim)4, "Idle_Relentless" }, { (Anim)5, "Spell" }, { (Anim)6, "Death" }, { (Anim)7, "Talk" }, { (Anim)8, "Hover" } }; public GameObjectCharacterArtFinalizer(IModLogger logger, ICache> cache, FallbackDataProvider fallbackDataProvider, IRegister spriteRegister, IRegister skeletonRegister, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.fallbackDataProvider = fallbackDataProvider; this.spriteRegister = spriteRegister; this.skeletonRegister = skeletonRegister; this.decoratee = decoratee; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeGameObject(cacheItem); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeGameObject(IDefinition definition) { //IL_0175: Unknown result type (might be due to invalid IL or missing references) if (definition.Configuration.GetSection("type").Value != "character_art") { return; } IConfigurationSection section = definition.Configuration.GetSection("extensions").GetSection("character_art"); ParseReferenceExtensions.ReferencedObject referencedObject = section.GetSection("sprite").ParseReference(); if (referencedObject == null) { logger.Log((LogLevel)4, (object)("For GameObject with Id: " + definition.Id + " did not find a required field sprite for it.")); return; } string id = referencedObject.ToId(definition.Key, "Sprite"); if (!spriteRegister.TryLookupId(id, out Sprite lookup, out bool? IsModded, referencedObject.context)) { return; } Dictionary dictionary = new Dictionary(); foreach (IConfigurationSection child in section.GetSection("skeleton_animations").GetChildren()) { Anim? val = child.GetSection("animation").ParseAnim(); ParseReferenceExtensions.ReferencedObject referencedObject2 = child.GetSection("skeleton").ParseReference(); if (!val.HasValue || referencedObject2 == null) { logger.Log((LogLevel)4, (object)$"Skipping {definition.Key} {definition.Id} skeleton data animation: {val} skeleton: {referencedObject2?.id}"); } else { string id2 = referencedObject2.ToId(definition.Key, "SkeletonData"); if (skeletonRegister.TryLookupId(id2, out SkeletonDataAsset lookup2, out IsModded, referencedObject2.context)) { dictionary.Add(val.Value, lookup2); } } } bool flag = dictionary.Count > 0; GameObject data = definition.Data; GameObject defaultCharacterPrefab = fallbackDataProvider.FallbackData.GetDefaultCharacterPrefab(); data.CopyPrefabToObject(defaultCharacterPrefab); if (flag) { CreateCharacterWithSkeletonAnimations(data, definition.Id, lookup, dictionary, section); } else { CreateCharacterWithStaticSprite(data, definition.Id, lookup, section); } PostCharacterAdjustments(data, lookup, section, flag); } private void CreateCharacterWithStaticSprite(GameObject original, string name, Sprite sprite, IConfiguration configuration) { //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) Transform obj = original.transform.Find("CharacterScale/CharacterUI"); SpriteRenderer val = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform obj2 = original.transform.Find("CharacterScale/CharacterUI/Quad_Default"); MeshRenderer val2 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); CharacterUIMesh val3 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); Transform val4 = original.transform.Find("CharacterScale/CharacterUI/SpineMeshes"); CharacterUIMeshSpine val5 = ((val4 != null) ? ((Component)val4).GetComponent() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val4 == (Object)null) { logger.Log((LogLevel)2, (object)("Missing required components on prefab for " + name)); return; } Object.Destroy((Object)(object)val5); ((Component)val4).gameObject.SetActive(false); Bounds val6 = default(Bounds); ((CharacterUIMeshBase)val3).Setup(sprite, -1f, name, ref val6); IConfigurationSection section = configuration.GetSection("shader"); string text = section.GetSection("name").Value ?? "Shiny Shoe/Character Shader"; Shader val7 = Shader.Find(text); if ((Object)(object)val7 == (Object)null) { logger.Log((LogLevel)2, (object)("Failed to find shader " + text + " for " + name)); return; } if ((Object)(object)defaultQuadMaterial == (Object)null) { defaultQuadMaterial = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Material m) => ((Object)m).name == "CharacterMaterial_Default")); } Material val8 = new Material(val7); CopyMaterialProperties(defaultQuadMaterial, val8); Color colorFromSection = GetColorFromSection(section.GetSection("color")); TrySetMaterialColor(val8, "_Color", colorFromSection); Color colorFromSection2 = GetColorFromSection(section.GetSection("tint")); TrySetMaterialColor(val8, "_Tint", colorFromSection2); ((Renderer)val2).material = val8; val.sprite = sprite; ((Renderer)val).enabled = true; } private static void CopyMaterialProperties(Material srcmat, Material dstmat) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected I4, but got Unknown //IL_0044: 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) Shader shader = srcmat.shader; int propertyCount = shader.GetPropertyCount(); for (int i = 0; i < propertyCount; i++) { string propertyName = shader.GetPropertyName(i); ShaderPropertyType propertyType = shader.GetPropertyType(i); switch ((int)propertyType) { case 0: dstmat.SetColor(propertyName, srcmat.GetColor(propertyName)); break; case 1: dstmat.SetVector(propertyName, srcmat.GetVector(propertyName)); break; case 2: case 3: dstmat.SetFloat(propertyName, srcmat.GetFloat(propertyName)); break; case 4: dstmat.SetTexture(propertyName, srcmat.GetTexture(propertyName)); break; } } dstmat.renderQueue = srcmat.renderQueue; } public static void PrintMaterialProperties(Material mat) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mat == (Object)null) { Debug.Log((object)"Material is null"); return; } Shader shader = mat.shader; int propertyCount = shader.GetPropertyCount(); Debug.Log((object)("--- Material: " + ((Object)mat).name + ", Shader: " + ((Object)shader).name + " ---")); for (int i = 0; i < propertyCount; i++) { string propertyName = shader.GetPropertyName(i); ShaderPropertyType propertyType = shader.GetPropertyType(i); string materialValueString = GetMaterialValueString(mat, i, propertyType, propertyName); Debug.Log((object)$"{propertyName} ({propertyType}) = {materialValueString}"); } } private static string GetMaterialValueString(Material mat, int index, ShaderPropertyType type, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) switch ((int)type) { case 0: return ((object)mat.GetColor(name)/*cast due to .constrained prefix*/).ToString(); case 1: return ((object)mat.GetVector(name)/*cast due to .constrained prefix*/).ToString(); case 2: case 3: return mat.GetFloat(name).ToString(); case 4: { Texture texture = mat.GetTexture(name); if (!((Object)(object)texture != (Object)null)) { return "null"; } return ((Object)texture).name; } default: return "(unknown type)"; } } private unsafe void CreateCharacterWithSkeletonAnimations(GameObject original, string name, Sprite sprite, Dictionary animations, IConfiguration configuration) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) Transform obj = original.transform.Find("CharacterScale/CharacterUI"); SpriteRenderer val = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform val2 = original.transform.Find("CharacterScale/CharacterUI/Quad_Default"); Transform val3 = original.transform.Find("CharacterScale/CharacterUI/SpineMeshes"); CharacterUIMeshSpine val4 = ((val3 != null) ? ((Component)val3).GetComponent() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val3 == (Object)null) { logger.Log((LogLevel)2, (object)("Missing required components on prefab for " + name)); return; } foreach (KeyValuePair animation in animations) { Anim key = animation.Key; SkeletonDataAsset value = animation.Value; SkeletonAnimation val5 = SkeletonAnimation.NewSkeletonAnimationGameObject(value, false); ((Object)val5).name = "Spine GameObject (" + ((Object)value).name + " " + ((object)(*(Anim*)(&key))/*cast due to .constrained prefix*/).ToString() + ")"; ((Component)val5).transform.SetParent(val3); ((Component)val5).gameObject.layer = LayerMask.NameToLayer("Character_Lights"); ((Component)val5).transform.localPosition = Vector3.zero; val5.AnimationState.SetAnimation(0, ANIM_NAMES[key], true); ((SkeletonRenderer)val5).addNormals = true; ((SkeletonRenderer)val5).calculateTangents = true; } val.sprite = sprite; ((Renderer)val).enabled = true; ((Component)val2).gameObject.SetActive(false); ((Component)val4).gameObject.SetActive(true); Bounds val6 = default(Bounds); ((CharacterUIMeshBase)val4).Setup(sprite, -1f, name, ref val6); } private void PostCharacterAdjustments(GameObject original, Sprite sprite, IConfiguration configuration, bool isAnimated) { //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) CharacterState component = original.GetComponent(); Transform val = original.transform.Find("CharacterScale/CharacterUI"); Transform obj = original.transform.Find("CharacterScale/CharacterUI"); CharacterUI value = ((obj != null) ? ((Component)obj).GetComponent() : null); Transform obj2 = original.transform.Find("DetailsUIRoot/BottomAnchor/Stats/AbilityAndTriggersGroup/UnitAbilityUI"); UnitAbilityIconUI obj3 = ((obj2 != null) ? ((Component)obj2).GetComponent() : null); AccessTools.Field(typeof(CharacterState), "sprite").SetValue(component, sprite); AccessTools.Field(typeof(CharacterState), "charUI").SetValue(component, value); AccessTools.Field(typeof(UnitAbilityIconUI), "characterState").SetValue(obj3, component); if (!isAnimated) { int layer = ParseExtensions.ParseInt(configuration.GetSection("layer")) ?? 20; ((Component)val).gameObject.layer = layer; ((Component)((Component)val).transform.Find("Quad_Default")).gameObject.layer = layer; } IConfigurationSection section = configuration.GetSection("transform"); if (section != null) { IConfigurationSection section2 = section.GetSection("position"); float? num = ParseExtensions.ParseFloat(section2.GetSection("x")); float? num2 = ParseExtensions.ParseFloat(section2.GetSection("y")); float? num3 = ParseExtensions.ParseFloat(section2.GetSection("z")); if (num.HasValue || num2.HasValue || num3.HasValue) { Vector3 localPosition = ((Component)val).transform.localPosition; ((Component)val).transform.localPosition = new Vector3(num ?? localPosition.x, num2 ?? localPosition.y, num3 ?? localPosition.z); } float? num4 = ParseExtensions.ParseFloat(section.GetSection("scale").GetSection("x")); float? num5 = ParseExtensions.ParseFloat(section.GetSection("scale").GetSection("y")); float? num6 = ParseExtensions.ParseFloat(section.GetSection("scale").GetSection("z")); if (num4.HasValue || num5.HasValue || num6.HasValue) { Vector3 localScale = ((Component)val).transform.localScale; ((Component)val).transform.localScale = new Vector3(num4 ?? localScale.x, num5 ?? localScale.y, num6 ?? localScale.z); } } } private Color GetColorFromSection(IConfigurationSection section) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) return new Color(ParseExtensions.ParseFloat(section.GetSection("r")) ?? 1f, ParseExtensions.ParseFloat(section.GetSection("g")) ?? 1f, ParseExtensions.ParseFloat(section.GetSection("b")) ?? 1f, ParseExtensions.ParseFloat(section.GetSection("a")) ?? 1f); } private void TrySetMaterialColor(Material material, string propertyName, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(propertyName)) { material.SetColor(propertyName, color); } } } public class GameObjectDefinition(string key, GameObject data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public GameObject Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } } public class GameObjectFinalizer : IDataFinalizer { private readonly ICache> cache; private readonly IRegister gameObjectRegister; public GameObjectFinalizer(IRegister gameObjectRegister, ICache> cache) { this.cache = cache; this.gameObjectRegister = gameObjectRegister; base..ctor(); } public void FinalizeData() { cache.Clear(); } } public class GameObjectImportPipeline : IDataPipeline, GameObject> { private readonly PluginAtlas atlas; public GameObjectImportPipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("game_objects").GetChildren()) { string value = child.GetSection("id").Value; if (value != null) { string id = key.GetId("GameObject", value); GameObject val = new GameObject { name = id, layer = 0 }; Object.DontDestroyOnLoad((Object)(object)val); ((IRegisterableDictionary)(object)service).Register(id, val); GameObjectDefinition item = new GameObjectDefinition(key, val, child) { Id = value, IsModded = true }; list.Add((IDefinition)(object)item); } } } return list; } } public class GameObjectMapIconDecorator : IDataPipeline, GameObject> { private readonly IDataPipeline, GameObject> decoratee; private readonly IRegister spriteRegister; private readonly Lazy baseMapNode; public GameObjectMapIconDecorator(IDataPipeline, GameObject> decoratee, IModLogger logger, GameDataClient gameDataClient, IRegister spriteRenderer) { this.decoratee = decoratee; spriteRegister = spriteRenderer; baseMapNode = new Lazy((Func)delegate { if (gameDataClient.TryGetProvider(out SaveManager provider)) { MapNodeData obj = provider.GetAllGameData().FindMapNodeData("904c4de0-5e5a-45c2-af71-dcbebf7bb69a"); return (RewardNodeData?)(object)((obj is RewardNodeData) ? obj : null); } return (RewardNodeData?)null; }); } public List> Run(IRegister service) { List> list = decoratee.Run(service); foreach (IDefinition item in list) { Setup(item); } return list; } public void Setup(IDefinition definition) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!(definition.Configuration.GetSection("type").Value != "map_node_icon")) { IConfigurationSection section = definition.Configuration.GetSection("extensions").GetSection("map_node_icon"); GameObject data = definition.Data; data.SetActive(true); RewardNodeData? value = baseMapNode.Value; MapNodeIcon val = ((value != null) ? ((MapNodeData)value).GetMapIconPrefab() : null); data.CopyPrefabToObject(((Component)val).gameObject); data.GetComponent().sizeDelta = new Vector2(120f, 120f); MapNodeIcon component = data.GetComponent(); ((MonoBehaviour)component).useGUILayout = true; GameObject gameObject = ((Component)data.transform.Find("Enabled FX")).gameObject; GameObject gameObject2 = ((Component)data.transform.Find("Selected indicator")).gameObject; GameObject gameObject3 = ((Component)data.transform.Find("Art root/IconSprite_Enabled")).gameObject; GameObject gameObject4 = ((Component)data.transform.Find("Art root/IconSprite_Visited_Disabled")).gameObject; GameObject gameObject5 = ((Component)data.transform.Find("Art root/IconSprite_Disabled")).gameObject; GameObject gameObject6 = ((Component)data.transform.Find("Art root/IconSprite_Frozen")).gameObject; Animator component2 = gameObject6.GetComponent(); AccessTools.Field(typeof(MapNodeIcon), "enabledFxRoot").SetValue(component, gameObject); AccessTools.Field(typeof(MapNodeIcon), "iconSprite_Enabled").SetValue(component, gameObject3); AccessTools.Field(typeof(MapNodeIcon), "iconSprite_Visited_Enabled").SetValue(component, null); AccessTools.Field(typeof(MapNodeIcon), "iconSprite_Visited_Disabled").SetValue(component, gameObject4); AccessTools.Field(typeof(MapNodeIcon), "iconSprite_Disabled").SetValue(component, gameObject5); AccessTools.Field(typeof(MapNodeIcon), "selectedIndicator").SetValue(component, gameObject2); AccessTools.Field(typeof(MapNodeIcon), "frozenAnimator").SetValue(component, component2); AccessTools.Field(typeof(MapNodeIcon), "enabledEmittingParticles").SetValue(component, new ParticleSystem[0]); string key = definition.Key; ParseReferenceExtensions.ReferencedObject spriteRef = section.GetSection("enabled_sprite").ParseReference(); ParseReferenceExtensions.ReferencedObject additionalSprite = section.GetSection("enabled_mask_sprite").ParseReference(); ParseReferenceExtensions.ReferencedObject spriteRef2 = section.GetSection("visited_sprite_disabled").ParseReference(); ParseReferenceExtensions.ReferencedObject spriteRef3 = section.GetSection("disabled_sprite").ParseReference(); ParseReferenceExtensions.ReferencedObject referencedObject = section.GetSection("frozen_sprite").ParseReference(); SetupIconSprite(gameObject3, key, spriteRef, "_Layer1Tex", additionalSprite, "_Layer4Mask"); SetupIconSprite(gameObject4, key, spriteRef2, "_Layer1Tex"); SetupIconSprite(gameObject5, key, spriteRef3, "_Layer1Tex"); SetupIconSprite(gameObject6, key, referencedObject, "_Layer2Tex", referencedObject, "_Layer2Motion"); } } public void SetupIconSprite(GameObject iconSprite, string key, ParseReferenceExtensions.ReferencedObject? spriteRef, string materialPropertyName, ParseReferenceExtensions.ReferencedObject? additionalSprite = null, string? additionalPropertyName = null) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown if (spriteRef != null && spriteRegister.TryLookupId(spriteRef.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, spriteRef.context)) { Texture2D val = Texture2D.blackTexture; if (additionalSprite != null && spriteRegister.TryLookupId(additionalSprite.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, additionalSprite.context)) { val = lookup2.texture; } Image component = iconSprite.GetComponent(); Material material = new Material(((Graphic)component).material); ((Graphic)component).material = material; ((Graphic)component).material.SetTexture(materialPropertyName, (Texture)(object)lookup.texture); if (additionalPropertyName != null) { ((Graphic)component).material.SetTexture(additionalPropertyName, (Texture)(object)val); } } } } public class TransformOnStart : MonoBehaviour { private void Start() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = new Vector3(10000f, 10000f, 0f); } } internal class DeferredCompletedOperation : AsyncOperationBase { public IAsyncOperation Start(object context, object key, T val, Exception? error = null) { base.Context = context; base.OperationException = error; ((AsyncOperationBase)this).Key = key; DelayedActionManager.AddAction((Delegate)(Action)delegate { FakeCompletion(val); }, 0f, Array.Empty()); return (IAsyncOperation)(object)this; } public void FakeCompletion(T val) { ((AsyncOperationBase)this).SetResult(val); base.InvokeCompletionEvent(); } } public class GameObjectRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable, IResourceLocator, IResourceProvider, IInitializableObject { private string? m_ProviderId; private readonly IModLogger logger; public readonly GameObject hiddenRoot; public Dictionary HashToObjectMap { get; set; } = new Dictionary(); public virtual string ProviderId { get { if (string.IsNullOrEmpty(m_ProviderId)) { m_ProviderId = typeof(GameObjectRegister).FullName; } return m_ProviderId; } } public ProviderBehaviourFlags BehaviourFlags => (ProviderBehaviourFlags)0; IEnumerable IResourceLocator.Keys => HashToObjectMap.Keys.Cast(); public GameObjectRegister(IModLogger logger) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown hiddenRoot = new GameObject { name = "Prefabs" }; Object.DontDestroyOnLoad((Object)(object)hiddenRoot); hiddenRoot.AddComponent(); this.logger = logger; } public bool CanProvide(IResourceLocation location) where TObject : class { if (location == null) { throw new ArgumentException("IResourceLocation location cannot be null."); } return ProviderId.Equals(location.ProviderId, StringComparison.Ordinal); } public bool Initialize(string id, string data) { m_ProviderId = id; return !string.IsNullOrEmpty(m_ProviderId); } public bool Locate(object key, out IList locations) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown locations = new List(); if (key is Hash128 key2 && HashToObjectMap.TryGetValue(key2, out (string, GameObject) value)) { ResourceLocationBase item = new ResourceLocationBase(value.Item1, value.Item1, typeof(GameObjectRegister).FullName, Array.Empty()) { Data = value.Item2 }; locations.Add((IResourceLocation)(object)item); return true; } return false; } public IAsyncOperation Provide(IResourceLocation location, IList dependencies) where TObject : class { if (location == null) { throw new ArgumentNullException("location"); } if (!typeof(TObject).IsAssignableFrom(typeof(GameObject))) { throw new ArgumentNullException("gameobject"); } logger.Log((LogLevel)32, (object)("Providing for " + location.InternalId)); if (base[location.InternalId] is TObject val) { return new DeferredCompletedOperation().Start(location, location.InternalId, val); } logger.Log((LogLevel)32, (object)("Did not Find for " + location.InternalId)); return new DeferredCompletedOperation().Start(location, location.InternalId, null); } public bool Release(IResourceLocation location, object asset) { if (location == null) { throw new ArgumentNullException("location"); } return true; } public void Register(string key, GameObject item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) Hash128 val = Hash128.Compute(key); logger.Log((LogLevel)32, (object)$"Register GameObject ({key}) -- ({val})"); ((Object)item).name = key; HashToObjectMap.Add(val, (key, item)); item.transform.SetParent(hiddenRoot.transform, false); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return this.Select, string>((KeyValuePair gameobject) => gameobject.Key).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out GameObject? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (GameObject value in base.Values) { if (((Object)value).name == identifier) { lookup = value; IsModded = true; return true; } } return false; } } public class SkeletonDataDefinition(string key, SkeletonDataAsset data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public SkeletonDataAsset Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class SkeletonDataPipeline : IDataPipeline, SkeletonDataAsset> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private static Lazy skeletonDefaultMaterial = new Lazy((Func)(() => ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Material m) => ((Object)m).name == "UI_Daedalus_Idle_Material")))); public SkeletonDataPipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("skeletons").GetChildren()) { IDefinition val = LoadSkeletonAsset(service, key, child); if (val != null) { list.Add(val); } } } return list; } private IDefinition? LoadSkeletonAsset(IRegister service, string key, IConfigurationSection configuration) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown string value = configuration.GetSection("id").Value; string text = FindPath(key, configuration.GetSection("atlas_path").Value); string text2 = FindPath(key, configuration.GetSection("data_path").Value); if (text == null || value == null || text2 == null) { logger.Log((LogLevel)2, (object)("Unable to load skeleton " + value + " atlas: " + text + " data: " + text2)); return null; } string text3 = configuration.GetSection("shader").Value ?? "Shader Graphs/CharacterShader2.0 Graph"; string id = key.GetId("SkeletonData", value); TextAsset val = new TextAsset(File.ReadAllText(text)); List list = new List(); foreach (string item in from x in configuration.GetSection("texture_paths").GetChildren() select ParseExtensions.ParseString(x) into x where x != null select x) { string text4 = FindPath(key, item); byte[] array = File.ReadAllBytes(text4); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, -1, false); if (!ImageConversion.LoadImage(val2, array)) { logger.Log((LogLevel)2, (object)("Could not load file as texture " + text4)); return null; } ((Object)val2).name = Path.GetFileNameWithoutExtension(text4); list.Add(val2); } TextAsset val3; if (text2.EndsWith("json")) { val3 = new TextAsset(File.ReadAllText(text2)) { name = Path.GetFileName(text2) }; } else { if (!text2.EndsWith("skel")) { logger.Log((LogLevel)2, (object)("File " + text2 + " not readable. The extension must be .json, .skel")); return null; } byte[] inArray = File.ReadAllBytes(text2); val3 = new TextAsset("SPINE64|" + Convert.ToBase64String(inArray)) { name = Path.GetFileName(text2 + ".base64") }; } Material val4 = new Material(Shader.Find(text3)) { name = value + "_Material" }; val4.CopyPropertiesFromMaterial(skeletonDefaultMaterial.Value); SpineAtlasAsset val5 = SpineAtlasAsset.CreateRuntimeInstance(val, list.ToArray(), val4, true, (Func)null); SkeletonDataAsset val6 = SkeletonDataAsset.CreateRuntimeInstance(val3, (AtlasAssetBase)(object)val5, true, 0.01f); ((Object)val6).name = value; ((IRegisterableDictionary)(object)service).Register(id, val6); return (IDefinition?)(object)new SkeletonDataDefinition(key, val6, configuration) { Id = value }; } private string? FindPath(string key, string? path) { if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)path)) { return null; } foreach (string assetDirectory in atlas.PluginDefinitions[key].AssetDirectories) { string text = Path.Combine(assetDirectory, path); if (File.Exists(text)) { return text; } } return null; } } public class SkeletonDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public SkeletonDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, SkeletonDataAsset item) { logger.Log((LogLevel)32, (object)("Register SkeletonDataAsset " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out SkeletonDataAsset? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class SpriteDefinition(string key, Sprite data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public Sprite Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } } public class SpritePipeline : IDataPipeline, Sprite> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private static readonly HashSet OLDER_MODS = new HashSet { "StewardClan.Plugin", "SweetkinBackOnTrack.Plugin" }; private static readonly Dictionary StringToWrapMode = new Dictionary { ["clamp"] = (TextureWrapMode)1, ["repeat"] = (TextureWrapMode)0, ["mirror"] = (TextureWrapMode)2, ["mirror_once"] = (TextureWrapMode)3 }; private static readonly Dictionary StringToMeshType = new Dictionary { ["full_rect"] = (SpriteMeshType)0, ["tight"] = (SpriteMeshType)1 }; public SpritePipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("sprites").GetChildren()) { string value = child.GetSection("id").Value; string value2 = child.GetSection("path").Value; if (value2 == null || value == null) { continue; } string id = key.GetId("Sprite", value); float num = ParseExtensions.ParseFloat(child.GetSection("pixels_per_unit")) ?? GetPixelsPerUnit(key); Vector2 val = child.GetSection("pivot").ParseVec2(0.5f, 0.5f); uint valueOrDefault = (uint)ParseExtensions.ParseInt(child.GetSection("extrude")).GetValueOrDefault(); SpriteMeshType valueOrDefault2 = IEnumerableUtility.GetValueOrDefault((IDictionary)StringToMeshType, child.GetSection("mesh_type").Value?.ToLower() ?? "", (SpriteMeshType)0); TextureWrapMode valueOrDefault3 = IEnumerableUtility.GetValueOrDefault((IDictionary)StringToWrapMode, child.GetSection("wrap_mode").Value?.ToLower() ?? "", (TextureWrapMode)1); foreach (string assetDirectory in pluginDefinition.Value.AssetDirectories) { string text = Path.Combine(assetDirectory, value2); if (!File.Exists(text)) { logger.Log((LogLevel)4, (object)("Could not find asset at path: " + text + ". Sprite will not exist.")); continue; } byte[] array = File.ReadAllBytes(text); Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val2, array)) { logger.Log((LogLevel)4, (object)("Could not load image at path: " + text + ". Sprite will not exist.")); continue; } ((Object)val2).name = id; ((Texture)val2).wrapMode = valueOrDefault3; Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), val, num, valueOrDefault, valueOrDefault2); ((Object)val3).name = id; ((IRegisterableDictionary)(object)service).Register(id, val3); SpriteDefinition item = new SpriteDefinition(key, val3, child) { Id = value, IsModded = true }; list.Add((IDefinition)(object)item); break; } } } return list; } private float GetPixelsPerUnit(string mod_guid) { if (OLDER_MODS.Contains(mod_guid)) { return 128f; } return 100f; } } public class SpriteRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public SpriteRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, Sprite item) { logger.Log((LogLevel)32, (object)("Register Sprite (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((Sprite sprite) => ((Object)sprite).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out Sprite? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (Sprite value in base.Values) { if (((Object)value).name == identifier) { lookup = value; IsModded = true; return true; } } return false; } } public class TextureRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly IRegister spriteRegister; public TextureRegister(IModLogger logger, IRegister spriteRegister) { this.logger = logger; this.spriteRegister = spriteRegister; } public void Register(string key, Texture2D item) { logger.Log((LogLevel)32, (object)("Register Texture " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((Texture2D icon) => ((Object)icon).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out Texture2D? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0007: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 Sprite val = default(Sprite); if (spriteRegister.TryLookupIdentifier(identifier, identifierType, ref val, ref IsModded)) { lookup = val.texture; return true; } lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1 && TryGetValue(identifier, out lookup)) { return true; } } else { foreach (Texture2D value in base.Values) { if (((Object)value).name == identifier) { lookup = value; return true; } } } IsModded = false; return false; } } public class VfxDefinition(string key, VfxAtLoc data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public VfxAtLoc Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } } public class VfxFinalizer : IDataFinalizer { private readonly ICache> cache; private readonly IRegister assetReferenceRegister; public VfxFinalizer(IRegister assetReferenceRegister, ICache> cache) { this.assetReferenceRegister = assetReferenceRegister; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeVfxAtLoc(cacheItem); } cache.Clear(); } private void FinalizeVfxAtLoc(IDefinition definition) { IConfiguration configuration = definition.Configuration; string key = definition.Key; VfxAtLoc data = definition.Data; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("vfx_left").ParseAssetReference(); if (referencedObject != null && assetReferenceRegister.TryLookupId(referencedObject.ToId(key, "GameObject"), out AssetReferenceGameObject lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefLeft").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("vfx_right").ParseAssetReference(); if (referencedObject2 != null && assetReferenceRegister.TryLookupId(referencedObject2.ToId(key, "GameObject"), out AssetReferenceGameObject lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefRight").SetValue(data, lookup2); } } } public class VfxPipeline : IDataPipeline, VfxAtLoc> { private readonly PluginAtlas atlas; public VfxPipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { string key = pluginDefinition.Key; foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("vfxs").GetChildren()) { string value = child.GetSection("id").Value; if (value != null) { string id = key.GetId("Vfx", value); VfxAtLoc val = (VfxAtLoc)FormatterServices.GetUninitializedObject(typeof(VfxAtLoc)); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabLeft").SetValue(val, null); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefLeft").SetValue(val, (object?)new AssetReferenceGameObject()); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRight").SetValue(val, null); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefRight").SetValue(val, (object?)new AssetReferenceGameObject()); AccessTools.Field(typeof(VfxAtLoc), "spawnLocation").SetValue(val, child.GetSection("spawn_location").ParseLocation().GetValueOrDefault()); AccessTools.Field(typeof(VfxAtLoc), "facing").SetValue(val, child.GetSection("spawn_location").ParseFacing().GetValueOrDefault()); ((IRegisterableDictionary)(object)service).Register(id, val); VfxDefinition item = new VfxDefinition(key, val, child) { Id = value, IsModded = true }; list.Add((IDefinition)(object)item); } } } return list; } } public class VfxRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public static VfxAtLoc Default { get; set; } static VfxRegister() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown Default = (VfxAtLoc)FormatterServices.GetUninitializedObject(typeof(VfxAtLoc)); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabLeft").SetValue(Default, null); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefLeft").SetValue(Default, (object?)new AssetReferenceGameObject()); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRight").SetValue(Default, null); AccessTools.Field(typeof(VfxAtLoc), "vfxPrefabRefRight").SetValue(Default, (object?)new AssetReferenceGameObject()); AccessTools.Field(typeof(VfxAtLoc), "spawnLocation").SetValue(Default, (object)(Location)0); AccessTools.Field(typeof(VfxAtLoc), "facing").SetValue(Default, (object)(Facing)0); } public VfxRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, VfxAtLoc item) { logger.Log((LogLevel)16, (object)("Register VFX " + key)); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out VfxAtLoc? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { bool flag = TryGetValue(identifier, out lookup); if (!flag) { lookup = Default; flag = true; } return flag; } return false; } bool flag2 = TryGetValue(identifier, out lookup); if (!flag2) { lookup = Default; flag2 = true; } return flag2; } } public class AdditionalTooltipFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister statusRegister; private readonly IRegister triggerEnumRegister; public AdditionalTooltipFinalizer(IModLogger logger, ICache> cache, IRegister statusRegister, IRegister triggerEnumRegister) { this.logger = logger; this.cache = cache; this.statusRegister = statusRegister; this.triggerEnumRegister = triggerEnumRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeItem(cacheItem); } cache.Clear(); } public void FinalizeItem(IDefinition definition) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; AdditionalTooltipData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing AdditionalTooltipData " + key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); data.isTriggerTooltip = false; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("trigger").ParseReference(); bool? IsModded; if (referencedObject != null) { string id = referencedObject.ToId(key, "CTriggerEnum"); if (triggerEnumRegister.TryLookupId(id, out var lookup, out IsModded, referencedObject.context)) { data.isTriggerTooltip = true; data.trigger = lookup; } } data.isStatusTooltip = false; ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("status").ParseReference(); if (referencedObject2 != null) { string id2 = referencedObject2.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup2, out IsModded, referencedObject2.context)) { data.isStatusTooltip = true; data.statusId = lookup2.GetStatusId(); } } } } } namespace TrainworksReloaded.Base.Map { public class BucketMapNodePipelineDecorator : IDataPipeline, MapNodeData> { private readonly IDataPipeline, MapNodeData> decoratee; private readonly MapNodeDelegator delegator; public BucketMapNodePipelineDecorator(IDataPipeline, MapNodeData> decoratee, MapNodeDelegator delegator) { this.decoratee = decoratee; this.delegator = delegator; } public List> Run(IRegister service) { List> list = decoratee.Run(service); foreach (IDefinition item in list) { MapNodeData data = item.Data; foreach (MapNodeKey item2 in (from xs in item.Configuration.GetSection("buckets").GetChildren() where xs.Exists() select new MapNodeKey { BucketKey = (ParseExtensions.ParseString(xs.GetSection("bucket")) ?? "Merchant Ring 1"), RunKey = (ParseExtensions.ParseString(xs.GetSection("run_type")) ?? "primary") }).ToList()) { if (delegator.MapBucketToData.ContainsKey(item2)) { delegator.MapBucketToData[item2].Add(data); continue; } delegator.MapBucketToData.Add(item2, new List(1) { data }); } } return list; } } public class MapNodeDefinition(string key, MapNodeData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public MapNodeData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public record MapNodeKey { public string RunKey { get; set; } = ""; public string BucketKey { get; set; } = ""; public MapNodeKey() { } public MapNodeKey(string runKey, string bucketKey) { RunKey = runKey; BucketKey = bucketKey; } } public class MapNodeDelegator { public Dictionary> MapBucketToData = new Dictionary>(); } public class MapNodeFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister gameObjectRegister; private readonly IRegister mapNodeRegister; private readonly IRegister soundCueRegister; public MapNodeFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, IRegister gameObjectRegister, IRegister mapNodeRegister, IRegister soundCueRegister) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.gameObjectRegister = gameObjectRegister; this.mapNodeRegister = mapNodeRegister; this.soundCueRegister = soundCueRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeMapData(cacheItem); } cache.Clear(); } private void FinalizeMapData(IDefinition definition) { IConfiguration configuration = definition.Configuration; MapNodeData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Map Node Data " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("map_icon").ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(MapNodeData), "mapIcon").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("minimap_icon").ParseReference(); if (referencedObject2 != null && spriteRegister.TryLookupId(referencedObject2.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(MapNodeData), "minimapIcon").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("prefab").ParseReference(); if (referencedObject3 != null && gameObjectRegister.TryLookupId(referencedObject3.ToId(key, "GameObject"), out GameObject lookup3, out IsModded, referencedObject3.context)) { MapNodeIcon component = lookup3.GetComponent(); AccessTools.Field(typeof(MapNodeData), "mapIconPrefab").SetValue(data, component); } List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetDeprecatedSection("ignore_if_present", "ignore_if_nodes_present").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (mapNodeRegister.TryLookupId(item.ToId(key, "MapNode"), out MapNodeData lookup4, out IsModded, item.context)) { list.Add(lookup4); } } AccessTools.Field(typeof(MapNodeData), "ignoreIfNodesPresent").SetValue(data, list); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetDeprecatedSection("map_pools", "pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (mapNodeRegister.TryLookupName(item2.ToId(key, "MapNode"), out MapNodeData lookup5, out IsModded, item2.context)) { RandomMapDataContainer val = (RandomMapDataContainer)(object)((lookup5 is RandomMapDataContainer) ? lookup5 : null); if (val != null) { ((ReorderableArray)AccessTools.Field(typeof(RandomMapDataContainer), "mapNodeDataList").GetValue(val))?.Add(data); } } } string value = data.GetNodeSelectedSfxCue() ?? ""; ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetDeprecatedSection("node_selection_cue", "node_selected_sfx_cue").ParseReference(); if (referencedObject4 != null && soundCueRegister.TryLookupName(referencedObject4.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup6, out IsModded, referencedObject4.context)) { value = lookup6.Name; } AccessTools.Field(typeof(MapNodeData), "nodeSelectedSfxCue").SetValue(data, value); } } public class MapNodePipeline : IDataPipeline, MapNodeData> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; private readonly Dictionary> generators; private readonly IGuidProvider guidProvider; public MapNodePipeline(PluginAtlas atlas, IEnumerable> generators, IRegister termRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.termRegister = termRegister; this.generators = generators.ToDictionary((IFactory xs) => xs.FactoryKey); this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadMapNodes(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadMapNodes(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("map_nodes").GetChildren()) { MapNodeDefinition mapNodeDefinition = LoadMapNodeConfiguration(service, key, child); if (mapNodeDefinition != null) { list.Add(mapNodeDefinition); } } return list; } public MapNodeDefinition? LoadMapNodeConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string text2 = ParseExtensions.ParseString(configuration.GetSection("type")); if (text2 == null || !generators.TryGetValue(text2, out IFactory value)) { return null; } MapNodeData value2 = value.GetValue(); if ((Object)(object)value2 == (Object)null) { return null; } string text3 = (((Object)value2).name = key.GetId("MapNode", text)); string value3 = guidProvider.GetGuidDeterministic(text3).ToString(); AccessTools.Field(typeof(MapNodeData), "id").SetValue(value2, value3); string text4 = "MapNode_titleKey-" + text3; string text5 = "MapNode_descriptionKey-" + text3; LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(MapNodeData), "tooltipTitleKey").SetValue(value2, text4); localizationTerm.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(MapNodeData), "tooltipBodyKey").SetValue(value2, text5); localizationTerm2.Key = text5; ((IRegisterableDictionary)(object)termRegister).Register(text5, localizationTerm2); } AccessTools.Field(typeof(MapNodeData), "isBannerNode").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("is_banner", "is_banner_node")) == true); AccessTools.Field(typeof(MapNodeData), "isSoulSaviorUpgradedNode").SetValue(value2, ParseExtensions.ParseBool(configuration.GetSection("is_soul_savior_upgraded_node")) == true); AccessTools.Field(typeof(MapNodeData), "usePyreHeartHpTooltipKey").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("use_hp_tooltip", "use_pyre_hp_tooltip")) == true); AccessTools.Field(typeof(MapNodeData), "updateMapIconImmediatelyOnClick").SetValue(value2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("updated_map_icon_on_click", "update_map_icon_immediately_on_click")) == true); AccessTools.Field(typeof(MapNodeData), "requiredDlc").SetValue(value2, configuration.GetDeprecatedSection("dlc", "required_dlc").ParseDLC().GetValueOrDefault()); AccessTools.Field(typeof(MapNodeData), "skipCheckSettings").SetValue(value2, configuration.GetDeprecatedSection("skip_settings", "skip_check_settings").ParseSkipSettings().GetValueOrDefault()); ((IRegisterableDictionary)(object)service).Register(text3, value2); return new MapNodeDefinition(key, value2, configuration) { Id = text }; } } public class MapNodeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Lazy SaveManager; public MapNodeRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.logger = logger; } public void Register(string key, MapNodeData item) { logger.Log((LogLevel)16, (object)("Register Map Node " + key + "...")); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "mapNodeDatas").GetValue(allGameData)).Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 AllGameData allGameData = SaveManager.Value.GetAllGameData(); List source = (List)AccessTools.Field(typeof(AllGameData), "mapNodeDatas").GetValue(allGameData); if ((int)identifierType != 0) { if ((int)identifierType == 1) { if ((Object)(object)allGameData != (Object)null) { return source.Select((MapNodeData map) => ((GameData)map).GetID()).ToList(); } return this.Select, string>((KeyValuePair map) => ((GameData)map.Value).GetID()).ToList(); } return new List(); } if ((Object)(object)allGameData != (Object)null) { return source.Select((MapNodeData map) => ((Object)map).name).ToList(); } return this.Select, string>((KeyValuePair map) => map.Key).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out MapNodeData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { MapNodeData val = SaveManager.Value.GetAllGameData().FindMapNodeData(identifier); if ((Object)(object)val != (Object)null) { lookup = val; IsModded = ContainsKey(((Object)val).name); return true; } return TryGetValue(identifier, out lookup); } return false; } AllGameData allGameData = SaveManager.Value.GetAllGameData(); List list = (List)AccessTools.Field(typeof(AllGameData), "mapNodeDatas").GetValue(allGameData); if ((Object)(object)allGameData != (Object)null) { foreach (MapNodeData item in list) { if (((Object)item).name == identifier) { lookup = item; IsModded = ContainsKey(((Object)allGameData).name); return true; } } } return TryGetValue(identifier, out lookup); } } public class RewardNodeDataFactory : IFactory { public string FactoryKey => "reward"; public MapNodeData? GetValue() { return (MapNodeData?)(object)ScriptableObject.CreateInstance(); } } public class RewardNodeDataFinalizerDecorator : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister classDataRegister; private readonly IRegister rewardDataRegister; private readonly CardPoolRegister cardPoolRegister; private readonly IDataFinalizer decoratee; private readonly Lazy SaveManager; private readonly FieldInfo RelicDraftPoolSubstitutionsField = AccessTools.Field(typeof(DraftRewardData), "relicDraftPoolSubstitutions"); private readonly FieldInfo ReplacementDraftPoolField = AccessTools.Field(typeof(RelicDraftPoolSubstitution), "replacementDraftPool"); private readonly FieldInfo RelicDataField = AccessTools.Field(typeof(RelicDraftPoolSubstitution), "relicData"); private const string BANNERED_MUTATOR_ASSET_NAME = "Echoes_ReplaceBannerRewardsWithBannerSpellRewards"; private const string UNIT_BANNER_REWARD_ASSET_NAME = "CardDraftLevelUpUnitUmbra"; public RewardNodeDataFinalizerDecorator(IModLogger logger, ICache> cache, IRegister classDataRegister, IRegister rewardDataRegister, CardPoolRegister cardPoolRegister, GameDataClient client, IDataFinalizer decoratee) { this.logger = logger; this.cache = cache; this.classDataRegister = classDataRegister; this.rewardDataRegister = rewardDataRegister; this.cardPoolRegister = cardPoolRegister; this.decoratee = decoratee; SaveManager = new Lazy((Func)(() => (!client.TryGetValue(typeof(SaveManager), out ProviderDetails value)) ? new SaveManager() : ((SaveManager)value.Provider))); } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeRewardNodeData(cacheItem); } decoratee.FinalizeData(); cache.Clear(); } private void FinalizeRewardNodeData(IDefinition definition) { IConfiguration configuration = definition.Configuration; MapNodeData data = definition.Data; string key = definition.Key; RewardNodeData val = (RewardNodeData)(object)((data is RewardNodeData) ? data : null); if (val == null) { return; } IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("reward").Exists() select xs.GetSection("reward")).First(); if (configurationSection == null) { return; } logger.Log((LogLevel)16, (object)("Finalizing Reward Node Data " + definition.Key + " " + definition.Id + " path: " + configurationSection.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configurationSection.GetDeprecatedSection("required_class", "class").ParseReference(); ClassData lookup = null; if (referencedObject != null && classDataRegister.TryLookupName(referencedObject.ToId(key, "Class"), out lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(RewardNodeData), "requiredClass").SetValue(val, lookup); } List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configurationSection.GetSection("rewards").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (rewardDataRegister.TryLookupId(item.ToId(key, "RewardData"), out RewardData lookup2, out IsModded, item.context)) { list.Add(lookup2); DraftRewardData val2 = (DraftRewardData)(object)((lookup2 is DraftRewardData) ? lookup2 : null); if (val2 != null && ((MapNodeData)val).GetIsBannerNode()) { AddRelicDraftSubstitutions(val2, lookup); } } } AccessTools.Field(typeof(RewardNodeData), "rewards").SetValue(val, list); } private void AddRelicDraftSubstitutions(DraftRewardData draftRewardData, ClassData? classData) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if ((Object)(object)classData == (Object)null) { return; } GrantableRewardData obj = SaveManager.Value.GetAllGameData().FindRewardDataByName("CardDraftLevelUpUnitUmbra"); DraftRewardData obj2 = (DraftRewardData)(object)((obj is DraftRewardData) ? obj : null); if (!(RelicDraftPoolSubstitutionsField.GetValue(obj2) is List collection)) { return; } List list = new List(collection); for (int i = 0; i < list.Count; i++) { RelicDraftPoolSubstitution val = list[i]; if (((Object)val.RelicData).name == "Echoes_ReplaceBannerRewardsWithBannerSpellRewards") { RelicDraftPoolSubstitution val2 = new RelicDraftPoolSubstitution(); CardPool bannerReplacementPool = cardPoolRegister.GetBannerReplacementPool(((Object)classData).name); RelicDataField.SetValue(val2, val.RelicData); ReplacementDraftPoolField.SetValue(val2, bannerReplacementPool); list[i] = val2; } } RelicDraftPoolSubstitutionsField.SetValue(draftRewardData, list); } } public class RewardNodeDataPipelineDecorator : IDataPipeline, MapNodeData> { private readonly IDataPipeline, MapNodeData> decoratee; public RewardNodeDataPipelineDecorator(IDataPipeline, MapNodeData> decoratee) { this.decoratee = decoratee; } public List> Run(IRegister service) { List> list = decoratee.Run(service); foreach (IDefinition item in list) { MapNodeData data = item.Data; IConfiguration configuration = item.Configuration; RewardNodeData val = (RewardNodeData)(object)((data is RewardNodeData) ? data : null); if (val != null) { IConfigurationSection configurationSection = (from xs in configuration.GetSection("extensions").GetChildren() where xs.GetSection("reward").Exists() select xs.GetSection("reward")).First(); if (configurationSection != null) { AccessTools.Field(typeof(RewardNodeData), "OverrideTooltipTitleBody").SetValue(val, ParseExtensions.ParseBool(configurationSection.GetDeprecatedSection("override_tooltip_with_reward", "override_tooltip_title_body")) == true); AccessTools.Field(typeof(RewardNodeData), "UseFormattedOverrideTooltipTitle").SetValue(val, ParseExtensions.ParseBool(configurationSection.GetDeprecatedSection("use_formatted_override_title", "use_formatted_override_tooltip_title")) == true); AccessTools.Field(typeof(RewardNodeData), "grantImmediately").SetValue(val, ParseExtensions.ParseBool(configurationSection.GetSection("grant_immediately")) == true); } } } return list; } } } namespace TrainworksReloaded.Base.Localization { public class CustomLocalizationTermRegistry : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public CustomLocalizationTermRegistry(IModLogger logger) { this.logger = logger; } public void Register(string key, LocalizationTerm item) { Add(key, item); } public void LoadData(List additionalLanguages) { StringBuilder stringBuilder = new StringBuilder(); string text = ""; if (additionalLanguages.Count > 0) { text = "," + string.Join(',', additionalLanguages); } stringBuilder.AppendLine("Key,Type,Desc,Group,Descriptions,English [en-US],French [fr-FR],German [de-DE],Russian,Portuguese (Brazil),Chinese,Spanish,Chinese (Traditional),Korean,Japanese" + text); foreach (LocalizationTerm term in base.Values) { logger.Log((LogLevel)32, (object)("Adding Term (" + term.Key + ") -- (" + term.English + ")")); string text2 = ""; if (additionalLanguages.Count > 0) { text2 = "," + string.Join(',', additionalLanguages.Select((string x) => IEnumerableUtility.GetValueOrDefault((IDictionary)term.OtherLanguages, x, term.English))); } stringBuilder.AppendLine(term.Key + "," + term.Type + "," + term.Desc + "," + term.Group + "," + term.Descriptions + "," + term.English + "," + term.French + "," + term.German + "," + term.Russian + "," + term.Portuguese + "," + term.Chinese + "," + term.Spanish + "," + term.ChineseTraditional + "," + term.Korean + "," + term.Japanese + text2); } LocalizationManager.InitializeIfNeeded(); foreach (string category in LocalizationManager.Sources[0].GetCategories(true, (List)null)) { LocalizationManager.Sources[0].Import_CSV(category, stringBuilder.ToString(), (eSpreadsheetUpdateMode)2, ',', 0, (DiffInfo)null); LocalizationManager.Sources[0].Import_CSV(category, stringBuilder.ToString(), (eSpreadsheetUpdateMode)3, ',', 0, (DiffInfo)null); } } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out LocalizationTerm? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class LanguageSource { private readonly string language; private readonly Dictionary[] translationSources; public string Language => language; public Dictionary[] TranslationSources => translationSources; public LanguageSource(string language, Dictionary[] translationSources) { this.language = language; this.translationSources = translationSources; } } public class LanguageSourcePipeline : IDataPipeline, LanguageSource> { private readonly PluginAtlas atlas; private readonly IModLogger logger; public LanguageSourcePipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { List> result = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("language_sources").GetChildren()) { List list = (from x in child.GetSection("csv_paths").GetChildren() select ParseExtensions.ParseString(x)).ToList(); string text = ParseExtensions.ParseString(child.GetSection("language")); if (!IEnumerableUtility.IsNullOrEmpty(list) && list.Count >= 2 && text != null) { Dictionary dictionary = ParseCSV(list[0], pluginDefinition.Value.AssetDirectories); Dictionary dictionary2 = ParseCSV(list[1], pluginDefinition.Value.AssetDirectories); if (dictionary == null || dictionary2 == null) { logger.Log((LogLevel)2, (object)("No translations found for language " + text + ". No csv files found or could not be read.")); continue; } ((IRegisterableDictionary)(object)service).Register(text, new LanguageSource(text, new Dictionary[2] { dictionary, dictionary2 })); } } } return result; } private Dictionary? ParseCSV(string path, List directories) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown string text = null; foreach (string directory in directories) { text = Path.Combine(directory, path); File.Exists(text); } if (text == null) { return null; } Dictionary dictionary = new Dictionary(); using StreamReader streamReader = new StreamReader(text); CsvReader val = new CsvReader((TextReader)streamReader, CultureInfo.InvariantCulture, false); try { val.Read(); val.ReadHeader(); while (val.Read()) { string field = val.GetField(0); string field2 = val.GetField(1); dictionary[field] = field2; } return dictionary; } finally { ((IDisposable)val)?.Dispose(); } } } public class LanguageSourceRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public LanguageSourceRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, LanguageSource item) { logger.Log((LogLevel)16, (object)("Adding Language " + key)); Add(key, item); } public void LoadData() { if (base.Count != 0) { LoadTranslations(0); LoadTranslations(1); } } private void LoadTranslations(int source_index) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Key,Type,Desc,Group,Descriptions," + string.Join(',', base.Keys)); List> list = base.Values.Select((LanguageSource x) => x.TranslationSources[source_index]).ToList(); HashSet hashSet = new HashSet(); foreach (Dictionary item in list) { hashSet.UnionWith(item.Keys); } foreach (string item2 in hashSet) { stringBuilder.Append(item2 + ",Text,,,"); foreach (Dictionary item3 in list) { stringBuilder.Append(",\"" + IEnumerableUtility.GetValueOrDefault((IDictionary)item3, item2, string.Empty) + "\""); } stringBuilder.AppendLine(); } foreach (string category in LocalizationManager.Sources[source_index].GetCategories(true, (List)null)) { LocalizationManager.Sources[source_index].Import_CSV(category, stringBuilder.ToString(), (eSpreadsheetUpdateMode)2, ',', 0, (DiffInfo)null); } LocalizationManager.LocalizeAll(true); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out LanguageSource? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class LocalizationTerm { public string Key { get; set; } = ""; public string Type { get; set; } = ""; public string Desc { get; set; } = ""; public string Group { get; set; } = ""; public string Descriptions { get; set; } = ""; public string English { get; set; } = ""; public string French { get; set; } = ""; public string German { get; set; } = ""; public string Russian { get; set; } = ""; public string Portuguese { get; set; } = ""; public string Chinese { get; set; } = ""; public string Spanish { get; set; } = ""; public string ChineseTraditional { get; set; } = ""; public string Korean { get; set; } = ""; public string Japanese { get; set; } = ""; public Dictionary OtherLanguages { get; set; } = new Dictionary(); public bool HasTranslation() { if (English == "" && French == "" && German == "" && Russian == "" && Portuguese == "" && Chinese == "" && Spanish == "" && ChineseTraditional == "" && Korean == "" && Japanese == "") { return OtherLanguages.Count != 0; } return true; } } public class LocalizationTermPipeline : IDataPipeline, LocalizationTerm> { private readonly PluginAtlas atlas; public LocalizationTermPipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { List> result = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { foreach (IConfigurationSection child in pluginDefinition.Value.Configuration.GetSection("localization_terms").GetChildren()) { string text = ParseExtensions.ParseString(child.GetSection("key")); if (text != null) { LocalizationTerm localizationTerm = child.GetSection("texts").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = text; ((IDictionary)service).Add(text, localizationTerm); } } } } return result; } } public class ReplacementStringPipeline : IDataPipeline, ReplacementStringData> { private readonly PluginAtlas atlas; private readonly IRegister locService; public ReplacementStringPipeline(PluginAtlas atlas, IRegister locService) { this.atlas = atlas; this.locService = locService; } public List> Run(IRegister service) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown List> result = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { IConfiguration configuration = pluginDefinition.Value.Configuration; string key = pluginDefinition.Key; foreach (IConfigurationSection child in configuration.GetSection("replacement_texts").GetChildren()) { string text = ParseExtensions.ParseString(child.GetSection("key")); if (text != null) { string text2 = key + "_" + text; string key2 = "ReplacementStringsData_replacement-" + text2; LocalizationTerm localizationTerm = child.GetSection("texts").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = key2; ((IRegisterableDictionary)(object)locService).Register(localizationTerm.Key, localizationTerm); ReplacementStringData val = new ReplacementStringData(); AccessTools.Field(typeof(ReplacementStringData), "_keyword").SetValue(val, text2); AccessTools.Field(typeof(ReplacementStringData), "_replacement").SetValue(val, localizationTerm.Key); ((IRegisterableDictionary)(object)service).Register(text2, val); } } } } return result; } } public class ReplacementStringRegistry : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly GameDataClient gameDataClient; public ReplacementStringRegistry(IModLogger logger, GameDataClient gameDataClient) { this.logger = logger; this.gameDataClient = gameDataClient; } public void Register(string key, ReplacementStringData item) { Add(key, item); } public void LoadData() { if (!gameDataClient.TryGetProvider(out LanguageManager provider)) { logger.Log((LogLevel)2, (object)"Unable to get replacement strings dictionary. LangaugeManager not available."); return; } object value = AccessTools.Field(typeof(LanguageManager), "_paramHandler").GetValue(provider); if (!(AccessTools.Field(typeof(LocalizationGlobalParameterHandler), "_replacements").GetValue(value) is Dictionary dictionary)) { logger.Log((LogLevel)2, (object)"Unable to get replacement strings dictionary from Language Manager."); return; } foreach (ReplacementStringData value2 in base.Values) { logger.Log((LogLevel)32, (object)("Adding Replacement (" + value2.Keyword + ") -- (" + LocalizationExtensions.LocalizeEnglish(value2.ReplacementTextKey, true, (ILocalizationParameterContext)null) + ")")); dictionary.Add(value2.Keyword, value2); } } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out ReplacementStringData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Extensions { public static class AssemblyExtensions { public static readonly Assembly MT2Assembly = typeof(CardEffectDamage).Assembly; public static Type? FindTypeByClassName(this Assembly assembly, string class_name) { return assembly.DefinedTypes.FirstOrDefault((TypeInfo t) => t.DeclaringType == null && t.Name == class_name); } public static bool GetFullyQualifiedName(this string className, Assembly? assembly, [NotNullWhen(true)] out string? fullyQualifiedName) { className = className.Replace("@", ""); Type type = null; bool flag = false; fullyQualifiedName = null; if (assembly != null) { type = assembly.FindTypeByClassName(className); } if (type == null) { flag = true; type = MT2Assembly.FindTypeByClassName(className); } if (type != null && typeof(T).IsAssignableFrom(type)) { fullyQualifiedName = (flag ? className : type.AssemblyQualifiedName); return true; } return false; } } public static class AssetReferenceExtensions { public static void SetAssetAndId(this AssetReference assetReference, string registeredGUID, Object @object) { assetReference.SetAsset(@object); AccessTools.Field(typeof(AssetReference), "m_AssetGUID").SetValue(assetReference, registeredGUID); AccessTools.Field(typeof(AssetReference), "m_debugName").SetValue(assetReference, "TR-" + registeredGUID); } public static void SetId(this AssetReference assetReference, string registeredGUID) { AccessTools.Field(typeof(AssetReference), "m_AssetGUID").SetValue(assetReference, registeredGUID); AccessTools.Field(typeof(AssetReference), "m_debugName").SetValue(assetReference, "TR-" + registeredGUID); } } public static class ConfigurationExtensions { internal static ManualLogSource Logger = Logger.CreateLogSource("ConfigurationExtensions"); public static IConfigurationSection GetDeprecatedSection(this IConfiguration configuration, string name, string newName) { IConfigurationSection section = configuration.GetSection(name); if (section.Exists()) { Logger.LogWarning((object)("[Deprecation] Field name \"" + name + "\" is deprecated, use \"" + newName + "\" instead")); return section; } return configuration.GetSection(newName); } public static string GetPath(this IConfiguration configuration) { return (configuration as IConfigurationSection)?.Path ?? ""; } } public static class GameObjectExtensions { public static void CopyPrefabToObject(this GameObject original, GameObject prefab) { GameObject val = Object.Instantiate(prefab); Component[] components = original.GetComponents(); foreach (Component val2 in components) { if (!(val2 is Transform)) { Object.Destroy((Object)(object)val2); } } GameObjectUtil.DestroyAllChildren(original.transform); original.layer = 0; for (int num = val.transform.childCount - 1; num >= 0; num--) { val.transform.GetChild(num).SetParent(original.transform); } components = val.GetComponents(); foreach (Component val3 in components) { if (val3 is Transform) { continue; } Component obj = original.AddComponent(((object)val3).GetType()); FieldInfo[] fields = ((object)val3).GetType().GetFields(); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.IsLiteral) { fieldInfo.SetValue(obj, fieldInfo.GetValue(val3)); } } } Object.Destroy((Object)(object)val); } } public static class ParseEnumExtensions { public static OverrideMode ParseOverrideMode(this IConfigurationSection section) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) string value = section.Value; if (string.IsNullOrEmpty(value)) { return (OverrideMode)0; } return (OverrideMode)(value.ToLower() switch { "false" => 0, "true" => 1, "replace" => 1, "append" => 2, _ => 0, }); } public static SkipCheckSettings? ParseSkipSettings(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (SkipCheckSettings)0, "always" => (SkipCheckSettings)1, "if_full_health" => (SkipCheckSettings)2, "if_no_champion" => (SkipCheckSettings)4, "both" => (SkipCheckSettings)3, _ => null, }; } public static Filter? ParseRewardFilter(this IConfigurationSection section) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); List list = (from v in value.Split('|', StringSplitOptions.RemoveEmptyEntries) select v.Trim()).ToList(); Filter val = (Filter)0; foreach (string item in list) { Filter? val2 = item switch { "none" => (Filter)0, "only_endless" => (Filter)2, "not_endless" => (Filter)1, "only_if_allied_champ" => (Filter)4, _ => null, }; if (!val2.HasValue) { return null; } val |= val2.Value; } return val; } public static CostType? ParseCostType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "default" => (CostType)0, "x" => (CostType)1, "unplayable" => (CostType)2, _ => null, }; } public static CardType? ParseCardType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "invalid" => (CardType)4, "spell" => (CardType)0, "monster" => (CardType)1, "blight" => (CardType)5, "junk" => (CardType)6, "equipment" => (CardType)7, "room" => (CardType)8, _ => null, }; } public static CollectableRarity? ParseRarity(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "common" => (CollectableRarity)0, "uncommon" => (CollectableRarity)1, "starter" => (CollectableRarity)4, "rare" => (CollectableRarity)2, "champion" => (CollectableRarity)3, "unset" => (CollectableRarity)(-1), _ => null, }; } public static DLC? ParseDLC(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } string text = value.ToLower(); if (!(text == "none")) { if (text == "railforged") { return (DLC)1; } return null; } return (DLC)0; } public static CardInitialKeyboardTarget? ParseKeyboardTarget(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "front_friendly" => (CardInitialKeyboardTarget)1, "front_enemy" => (CardInitialKeyboardTarget)2, "back_friendly" => (CardInitialKeyboardTarget)3, "back_enemy" => (CardInitialKeyboardTarget)4, _ => null, }; } public static Color? ParseColor(this IConfigurationSection section) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) float? num = ParseExtensions.ParseFloat(section.GetSection("r")); float? num2 = ParseExtensions.ParseFloat(section.GetSection("g")); float? num3 = ParseExtensions.ParseFloat(section.GetSection("b")); float? num4 = ParseExtensions.ParseFloat(section.GetSection("a")); if (!num.HasValue && !num2.HasValue && !num3.HasValue && !num4.HasValue) { return null; } return new Color(num.GetValueOrDefault(), num2.GetValueOrDefault(), num3.GetValueOrDefault(), num4 ?? 1f); } public static string? ParseLocalization(this IConfigurationSection section) { string text = section.Value; if (string.IsNullOrEmpty(text)) { return null; } if (text.Contains(',')) { text = $"\"{text}\""; } return text; } public static LocalizationTerm? ParseLocalizationTerm(this IConfigurationSection section) { string value = section.GetSection("id").Value; string value2 = section.GetSection("type").Value; string value3 = section.GetSection("description").Value; string value4 = section.GetSection("group").Value; string value5 = section.GetSection("speaker_descriptions").Value; string text = section.GetSection("english").ParseLocalization(); string text2 = section.GetSection("french").ParseLocalization(); string text3 = section.GetSection("german").ParseLocalization(); string text4 = section.GetSection("russian").ParseLocalization(); string text5 = section.GetSection("portuguese").ParseLocalization(); string text6 = section.GetSection("chinese").ParseLocalization(); string text7 = section.GetSection("spanish").ParseLocalization(); string text8 = section.GetSection("chinese_traditional").ParseLocalization(); string text9 = section.GetSection("korean").ParseLocalization(); string text10 = section.GetSection("japanese").ParseLocalization(); if (value == null && value2 == null && value3 == null && value4 == null && value5 == null && text == null && text2 == null && text3 == null && text4 == null && text5 == null && text6 == null && text7 == null && text8 == null && text9 == null && text10 == null) { return null; } string def = text ?? ""; Dictionary otherLanguages = (from x in section.GetSection("other_languages").GetChildren() where x.GetSection("language").Value != null select x).ToDictionary((IConfigurationSection x) => ParseExtensions.ParseString(x.GetSection("language")) ?? "", (IConfigurationSection x) => x.GetSection("translation").ParseLocalization() ?? def); return new LocalizationTerm { Key = (value ?? ""), Type = (value2 ?? "Text"), Desc = (value3 ?? ""), Group = (value4 ?? ""), Descriptions = (value5 ?? ""), English = def, French = (text2 ?? def), German = (text3 ?? def), Russian = (text4 ?? def), Portuguese = (text5 ?? def), Chinese = (text6 ?? def), Spanish = (text7 ?? def), ChineseTraditional = (text8 ?? def), Korean = (text9 ?? def), Japanese = (text10 ?? def), OtherLanguages = otherLanguages }; } private static CardTargetMode? DoParseCardTargetMode(string? val) { if (val == null) { return null; } return val.ToLower() switch { "none" => (CardTargetMode)8, "all" => (CardTargetMode)0, "single" => (CardTargetMode)1, "targetless" => (CardTargetMode)2, "other" => (CardTargetMode)4, _ => null, }; } public static CardTargetMode? ParseCardTargetMode(this IConfigurationSection section) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) string value = section.Value; if (string.IsNullOrEmpty(value)) { if (!section.GetChildren().Any()) { return null; } CardTargetMode val = (CardTargetMode)0; foreach (IConfigurationSection child in section.GetChildren()) { CardTargetMode? val2 = DoParseCardTargetMode(child.Value); if (!val2.HasValue) { return null; } val |= val2.Value; } return val; } List list = (from v in value.Split('|', StringSplitOptions.RemoveEmptyEntries) select v.Trim()).ToList(); CardTargetMode val3 = (CardTargetMode)0; foreach (string item in list) { CardTargetMode? val4 = DoParseCardTargetMode(item); if (!val4.HasValue) { return null; } val3 |= val4.Value; } return val3; } public static object ParseCompareOperator(this IConfigurationSection section, string defaultVal = "and") { Type enumType = AccessTools.Inner(typeof(CardUpgradeMaskData), "CompareOperator"); string value = section.Value?.ToLower() ?? defaultVal; if (!Enum.TryParse(enumType, value, ignoreCase: true, out object result)) { Enum.TryParse(enumType, defaultVal, ignoreCase: true, out result); } return result; } public static TrackedValue? ParseTrackedValue(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value switch { "none" => (TrackedValue)0, "kill_enemies" => (TrackedValue)1, "play_spells" => (TrackedValue)2, "play_units" => (TrackedValue)3, "started_runs" => (TrackedValue)4, "covenant_level" => (TrackedValue)5, "unlocked_pyre_hearts" => (TrackedValue)6, "equipment_used" => (TrackedValue)7, "defeated_true_final_boss" => (TrackedValue)8, "cards_discarded" => (TrackedValue)9, "cards_consumed" => (TrackedValue)10, "healing_done_after_crew_unlocked" => (TrackedValue)11, "units_resurrected_after_crew_unlocked" => (TrackedValue)12, "consume_spells_returned_after_crew_unlocked" => (TrackedValue)13, "units_moved" => (TrackedValue)14, "pyre_damage" => (TrackedValue)15, "debuffs_applied" => (TrackedValue)16, "enemies_defeated_with_spells" => (TrackedValue)17, "battles_won_with_trial" => (TrackedValue)19, "magic_power_bonus_damage" => (TrackedValue)22, "play_five_spells_in_turn_after_crew_unlocked" => (TrackedValue)23, "play_dragon_or_demon_units" => (TrackedValue)24, "damage_done_by_train_stewards" => (TrackedValue)25, "num_challenges_won" => (TrackedValue)26, "defeated_all_seraph_variants" => (TrackedValue)27, "defeated_all_seraph_variants_at_max_covenant" => (TrackedValue)28, "win_with_all_class_combos" => (TrackedValue)29, "win_with_all_class_combos_at_max_covenant" => (TrackedValue)30, "all_classes_at_max_level" => (TrackedValue)31, "win_with_all_classes_at_max_covenant" => (TrackedValue)32, "cards_frozen" => (TrackedValue)33, "coins_spents" => (TrackedValue)34, "room_capacity_increased_after_crew_unlocked" => (TrackedValue)35, "defeat_tfb_with_all_class_combos_at_max_covenant" => (TrackedValue)36, "kill_lifemother" => (TrackedValue)196, "kill_lifemother_tier1" => (TrackedValue)197, "kill_lifemother_tier2" => (TrackedValue)198, "kill_lifemother_tier3" => (TrackedValue)199, "soulBuffsApplied" => (TrackedValue)144, "soulCardsDrafted" => (TrackedValue)121, "soulCardsPurged" => (TrackedValue)120, "soulCoinsEarned" => (TrackedValue)140, "soulEnemyUnitsKilled" => (TrackedValue)180, "soulEnemyUnitsKilledUsingAwoken" => (TrackedValue)184, "soulEnemyUnitsKilledUsingBanished" => (TrackedValue)185, "soulEnemyUnitsKilledUsingHellhorned" => (TrackedValue)186, "soulEnemyUnitsKilledUsingLazarus" => (TrackedValue)187, "soulEnemyUnitsKilledUsingLunaCoven" => (TrackedValue)188, "soulEnemyUnitsKilledUsingPyreborne" => (TrackedValue)189, "soulEnemyUnitsKilledUsingRailforged" => (TrackedValue)190, "soulEnemyUnitsKilledUsingRemnant" => (TrackedValue)191, "soulEnemyUnitsKilledUsingStygian" => (TrackedValue)192, "soulEnemyUnitsKilledUsingUmbra" => (TrackedValue)193, "soulEnemyUnitsKilledUsingUnderlegion" => (TrackedValue)194, "soulEnemyUnitsKilledUsingWurm" => (TrackedValue)195, "soulEnemyUnitsKilledWithChampion" => (TrackedValue)183, "soulEnemyUnitsKilledWithPyre" => (TrackedValue)182, "soulEnemyUnitsKilledWithSpells" => (TrackedValue)181, "soulEnemyUnitsWithInfestedKilled" => (TrackedValue)179, "soulEquipmentPlayed" => (TrackedValue)142, "soulFriendlyUnitsKilled" => (TrackedValue)175, "soulKillAnyBoss" => (TrackedValue)119, "soulKillLifemotherUsingAwoken" => (TrackedValue)111, "soulKillLifemotherUsingBanished" => (TrackedValue)103, "soulKillLifemotherUsingHellhorned" => (TrackedValue)110, "soulKillLifemotherUsingLazarusLeague" => (TrackedValue)109, "soulKillLifemotherUsingLunaCoven" => (TrackedValue)105, "soulKillLifemotherUsingPyreborne" => (TrackedValue)102, "soulKillLifemotherUsingRailforged" => (TrackedValue)106, "soulKillLifemotherUsingRemnant" => (TrackedValue)108, "soulKillLifemotherUsingStygian" => (TrackedValue)104, "soulKillLifemotherUsingUmbra" => (TrackedValue)100, "soulKillLifemotherUsingUnderlegion" => (TrackedValue)101, "soulKillLifemotherUsingWurmkin" => (TrackedValue)107, "soulKillRegion1Boss" => (TrackedValue)115, "soulKillRegion2Boss" => (TrackedValue)117, "soulKillRegion3Boss" => (TrackedValue)116, "soulKillRegion4Boss" => (TrackedValue)118, "soulMagicPowerBonusDamage" => (TrackedValue)141, "soulMerchantPurchases" => (TrackedValue)145, "soulPyreDamageTaken" => (TrackedValue)143, "soulSpellsConsumed" => (TrackedValue)125, "soulSpellsPurged" => (TrackedValue)123, "soulSpellsUpgraded" => (TrackedValue)126, "soulStarterCardsPlayed" => (TrackedValue)122, "soulsUnlocked" => (TrackedValue)200, "soulTreasureCollectorsKilled" => (TrackedValue)176, "soulUnitDamageDealt" => (TrackedValue)160, "soulUnitDamageTaken" => (TrackedValue)161, "soulUnitsEaten" => (TrackedValue)166, "soulUnitsExtinguishTriggered" => (TrackedValue)163, "soulUnitsMoved" => (TrackedValue)162, "soulUnitsPurged" => (TrackedValue)165, "soulUnitsRevengeTriggered" => (TrackedValue)167, "soulUnitsSummoned" => (TrackedValue)168, "soulUnitsUpgraded" => (TrackedValue)164, _ => null, }; } public static CardTypeTarget? ParseCardTypeTarget(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "any" => (CardTypeTarget)0, "spell" => (CardTypeTarget)1, "monster" => (CardTypeTarget)2, "blight" => (CardTypeTarget)3, "junk" => (CardTypeTarget)4, "equipment" => (CardTypeTarget)5, "train_room_attachment" => (CardTypeTarget)6, "room" => (CardTypeTarget)6, _ => null, }; } public static EntryDuration? ParseEntryDuration(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "this_turn" => (EntryDuration)0, "this_battle" => (EntryDuration)2, "previous_turn" => (EntryDuration)1, _ => null, }; } public static Type? ParseTeamType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (Type)0, "heroes" => (Type)1, "monsters" => (Type)2, "both" => (Type)3, _ => null, }; } public static StackMode? ParseStackMode(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "cumulative" => (StackMode)3, "none" => (StackMode)0, "param_int" => (StackMode)1, "param_int_largest" => (StackMode)2, _ => null, }; } public static HealthFilter? ParseHealthFilter(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "both" => (HealthFilter)0, "undamaged" => (HealthFilter)1, "damaged" => (HealthFilter)2, _ => null, }; } public static CardSelectionMode? ParseCardSelectionMode(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "choose_to_hand" => (CardSelectionMode)0, "random_to_hand" => (CardSelectionMode)1, "choose_to_deck" => (CardSelectionMode)2, "random_to_deck" => (CardSelectionMode)3, "random_to_room" => (CardSelectionMode)4, "random_to_hand_with_upgrades" => (CardSelectionMode)5, "random_to_room_until_capacity_full" => (CardSelectionMode)6, _ => null, }; } public static Anim? ParseAnim(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (Anim)0, "idle" => (Anim)1, "attack" => (Anim)2, "hit_react" => (Anim)3, "idle_relentless" => (Anim)4, "spell" => (Anim)5, "death" => (Anim)6, "talk" => (Anim)7, "hover" => (Anim)8, _ => null, }; } public static AttackPhase? ParseAttackPhase(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (AttackPhase)0, "casting" => (AttackPhase)1, "relentless" => (AttackPhase)2, "both" => (AttackPhase)3, _ => null, }; } public static Type? ParseCharacterDeathType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (Type)3, "normal" => (Type)0, "large" => (Type)1, "boss" => (Type)2, _ => null, }; } public static TitanAffinity? ParseTitanAffinity(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (TitanAffinity)0, "entropy" => (TitanAffinity)1, "savagery" => (TitanAffinity)2, "dominion" => (TitanAffinity)3, "lifemother" => (TitanAffinity)4, _ => null, }; } public static CardTriggerType? ParseCardTriggerType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "on_cast" => (CardTriggerType)0, "on_kill" => (CardTriggerType)1, "on_discard" => (CardTriggerType)2, "on_monster_death" => (CardTriggerType)3, "on_any_monster_death_on_floor" => (CardTriggerType)4, "on_any_hero_death_on_floor" => (CardTriggerType)5, "on_healed" => (CardTriggerType)6, "on_player_damage_taken" => (CardTriggerType)7, "on_any_unit_death_on_floor" => (CardTriggerType)8, "on_treasure" => (CardTriggerType)9, "on_unplayed_negative" => (CardTriggerType)10, "on_feed" => (CardTriggerType)11, "on_exhausted" => (CardTriggerType)12, "on_unplayed_positive" => (CardTriggerType)13, _ => null, }; } public static PersistenceMode? ParsePersistenceMode(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); if (!(value == "single_run")) { if (value == "single_battle") { return (PersistenceMode)1; } return null; } return (PersistenceMode)0; } public static Location? ParseLocation(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (Location)0, "room_center" => (Location)1, "character_top" => (Location)2, "character_center" => (Location)3, "character_bottom" => (Location)4, "character_side_fwd_center" => (Location)5, "character_side_fwd_bottom" => (Location)10, "character_side_back_center" => (Location)11, "character_side_back_bottom" => (Location)12, "bone_status_effect_slot1" => (Location)6, "bone_status_effect_slot2" => (Location)7, "bone_status_effect_slot3" => (Location)8, "bone_status_effect_slot4" => (Location)9, "character_floor" => (Location)13, _ => null, }; } public static Facing? ParseFacing(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); if (!(value == "none")) { if (value == "forward") { return (Facing)1; } return null; } return (Facing)0; } public static TooltipDesignType? ParseTooltipDesignType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "default" => (TooltipDesignType)0, "lore_herzal" => (TooltipDesignType)1, "boss" => (TooltipDesignType)2, "default_wide" => (TooltipDesignType)3, "positive" => (TooltipDesignType)4, "negative" => (TooltipDesignType)5, "persistent" => (TooltipDesignType)6, "trigger" => (TooltipDesignType)7, "keyword" => (TooltipDesignType)8, "lore_malicka" => (TooltipDesignType)9, "lore_heph" => (TooltipDesignType)10, "default_mega_wide" => (TooltipDesignType)12, "state_modifier" => (TooltipDesignType)13, "title" => (TooltipDesignType)14, "equipment" => (TooltipDesignType)15, "ability" => (TooltipDesignType)16, "tip" => (TooltipDesignType)17, "boss_title" => (TooltipDesignType)18, "relic_title" => (TooltipDesignType)19, _ => null, }; } public static DisplayCategory? ParseDisplayCategory(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "positive" => (DisplayCategory)0, "negative" => (DisplayCategory)1, "persistent" => (DisplayCategory)2, "ability" => (DisplayCategory)3, _ => null, }; } public static VFXDisplayType? ParseVFXDisplayType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); if (!(value == "default")) { if (value == "last_stack") { return (VFXDisplayType)1; } return null; } return (VFXDisplayType)0; } public static UpgradeDisabledReason? ParseUpgradeDisabledReason(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (UpgradeDisabledReason)0, "card_type" => (UpgradeDisabledReason)1, "no_slots" => (UpgradeDisabledReason)2, "not_eligible" => (UpgradeDisabledReason)3, "animation_active" => (UpgradeDisabledReason)4, "does_not_apply_status_effects" => (UpgradeDisabledReason)5, _ => null, }; } public static RelicLoreTooltipStyle? ParseRelicLoreTooltipStyle(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "herzal" => (RelicLoreTooltipStyle)0, "malicka" => (RelicLoreTooltipStyle)1, "heph" => (RelicLoreTooltipStyle)2, _ => null, }; } public static SpecialCharacterType? ParseSpecialCharacterType(this IConfigurationSection section) { string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } return value.ToLower() switch { "none" => (SpecialCharacterType)0, "outer_train_boss" => (SpecialCharacterType)1, "treasure_and_traitor" => (SpecialCharacterType)2, _ => null, }; } public static RarityTicketType? ParseRarityTicketType(this IConfigurationSection section) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); List list = (from v in value.Split('|', StringSplitOptions.RemoveEmptyEntries) select v.Trim()).ToList(); RarityTicketType val = (RarityTicketType)0; foreach (string item in list) { RarityTicketType? val2 = item switch { "none" => (RarityTicketType)0, "card" => (RarityTicketType)1, "enhancer" => (RarityTicketType)2, "relic" => (RarityTicketType)4, _ => null, }; if (!val2.HasValue) { return null; } val |= val2.Value; } return val; } public static ClassType? ParseClassType(this IConfigurationSection section) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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) string value = section.Value; if (string.IsNullOrEmpty(value)) { return null; } value = value.ToLower(); List list = (from v in value.Split('|', StringSplitOptions.RemoveEmptyEntries) select v.Trim()).ToList(); ClassType val = (ClassType)0; foreach (string item in list) { ClassType? val2 = item switch { "none" => (ClassType)0, "main" => (ClassType)1, "subclass" => (ClassType)2, "nonclass" => (ClassType)4, _ => null, }; if (!val2.HasValue) { return null; } val |= val2.Value; } return val; } public static Gender ParseGender(this IConfigurationSection section, Gender defaultValue) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) string value = section.Value; if (string.IsNullOrEmpty(value)) { return defaultValue; } Gender? val = value.ToLower() switch { "male" => (Gender)1, "female" => (Gender)2, "neutral" => (Gender)0, _ => null, }; if (!val.HasValue) { return defaultValue; } return val.Value; } public static ScenarioDifficulty? ParseScenarioDifficulty(this IConfigurationSection section) { string text = section.Value?.ToLower(); if (string.IsNullOrEmpty(text)) { return null; } return text switch { "normal" => (ScenarioDifficulty)0, "hard" => (ScenarioDifficulty)1, "boss" => (ScenarioDifficulty)2, _ => null, }; } public static BossType? ParseBossType(this IConfigurationSection section) { string text = section.Value?.ToLower(); if (string.IsNullOrEmpty(text)) { return null; } return text switch { "none" => (BossType)0, "outer_train_boss" => (BossType)1, "true_final_boss" => (BossType)2, _ => null, }; } private static Comparator? DoParseComparator(string? val) { if (string.IsNullOrEmpty(val)) { return null; } return val.ToLower() switch { "less_than" => (Comparator)1, "greater_than" => (Comparator)4, "equal" => (Comparator)2, _ => null, }; } public static Comparator? ParseComparator(this IConfigurationSection section) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) string value = section.Value; if (string.IsNullOrEmpty(value)) { if (!section.GetChildren().Any()) { return null; } Comparator? val = (Comparator)0; { foreach (IConfigurationSection child in section.GetChildren()) { Comparator? val2 = DoParseComparator(child.Value); if (!val2.HasValue) { return null; } val = (Comparator?)((??)val | val2.Value); } return val; } } List list = (from v in value.Split('|', StringSplitOptions.RemoveEmptyEntries) select v.Trim()).ToList(); Comparator val3 = (Comparator)0; foreach (string item in list) { Comparator? val4 = DoParseComparator(item); if (!val4.HasValue) { return null; } val3 |= val4.Value; } return val3; } public static RoomTargetPos? ParseRoomTargetPos(this IConfigurationSection section) { string text = section.Value?.ToLower(); if (string.IsNullOrEmpty(text)) { return null; } return text switch { "center" => (RoomTargetPos)0, "low" => (RoomTargetPos)1, "left" => (RoomTargetPos)2, "right" => (RoomTargetPos)3, "unknown" => (RoomTargetPos)(-1), _ => null, }; } public static Vector2 ParseVec2(this IConfigurationSection section, float x = 0f, float y = 0f) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) float num = ParseExtensions.ParseFloat(section.GetSection("x")) ?? x; float num2 = ParseExtensions.ParseFloat(section.GetSection("y")) ?? y; return new Vector2(num, num2); } public static Vector3 ParseVec3(this IConfigurationSection section, float x = 0f, float y = 0f, float z = 0f) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) float num = ParseExtensions.ParseFloat(section.GetSection("x")) ?? x; float num2 = ParseExtensions.ParseFloat(section.GetSection("y")) ?? y; float num3 = ParseExtensions.ParseFloat(section.GetSection("z")) ?? z; return new Vector3(num, num2, num3); } } public static class ParseReferenceExtensions { public class ReferencedObject { public string id; public string? mod_reference; public IConfigurationSection context; public ReferencedObject(string id, string? mod_reference, IConfigurationSection context) { this.id = id; this.mod_reference = mod_reference; this.context = context; } public string ToId(string defaultKey, string template) { string key = mod_reference ?? defaultKey; return id.ToId(key, template); } } public static ReferencedObject? ParseReference(this IConfigurationSection section) { string text = section.Value ?? section.GetSection("id").Value; string value = section.GetSection("mod_reference").Value; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)text) || text == "null") { return null; } return new ReferencedObject(text, value, section); } public static ReferencedObject? ParseAssetReference(this IConfigurationSection section) { ReferencedObject referencedObject = section.ParseReference(); if (referencedObject != null) { return referencedObject; } string value = section.GetSection("asset_guid").Value; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)value) || value == "null") { return null; } return new ReferencedObject(value, null, section); } } public static class RegisterExtensions { internal static ManualLogSource Logger = Logger.CreateLogSource("RegisterExtensions"); public static bool TryLookupName(this IRegister register, string name, [NotNullWhen(true)] out T? lookup, [NotNullWhen(true)] out bool? IsModded, IConfigurationSection? context = null) { bool flag = register.TryLookupIdentifier(name, (RegisterIdentifierType)0, ref lookup, ref IsModded); if (!flag) { Logger.LogWarning((object)("Could not find identifier of type " + typeof(T).Name + " with id (name) " + name + ". Configuration Path: " + context?.Path)); Logger.LogDebug((object)(Environment.StackTrace ?? "")); } return flag; } public static bool TryLookupId(this IRegister register, string id, [NotNullWhen(true)] out T? lookup, [NotNullWhen(true)] out bool? IsModded, IConfigurationSection? context = null) { bool flag = register.TryLookupIdentifier(id, (RegisterIdentifierType)1, ref lookup, ref IsModded); if (!flag) { Logger.LogWarning((object)("Could not find identifier of type " + typeof(T).Name + " with id (guid) " + id + ". Configuration Path: " + context?.Path)); Logger.LogDebug((object)(Environment.StackTrace ?? "")); } return flag; } } public static class StringExtensions { internal static ManualLogSource Logger = Logger.CreateLogSource("StringExtensions"); public static string GetId(this string key, string template, string id) { if (id.StartsWith("@")) { Logger.LogWarning((object)("For mod_guid " + key + " type " + template + " we are attempting to create an id for " + template + " there should be no @ preceding this id " + id + ". @ is only needed when referencing this id in other places not when defining it.")); } return FormId(key, template, id); } public static string ToId(this string baseString, string key, string template) { if (baseString.StartsWith("@")) { return FormId(key, template, baseString.Substring(1)); } return baseString; } private static string FormId(string key, string template, string id) { if (template == "StatusEffect") { return (key + "_" + id).ToLowerInvariant(); } return key + "-" + template + "-" + id; } } } namespace TrainworksReloaded.Base.Enums { public class CardTriggerTypeDefinition(string key, CardTriggerType data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CardTriggerType Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class CardTriggerTypeFinalizer : IDataFinalizer { private readonly Lazy SaveManager; private readonly GameDataClient client; private readonly IModLogger logger; private readonly ICache> cache; public CardTriggerTypeFinalizer(IModLogger logger, GameDataClient client, ICache> cache) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.client = client; this.logger = logger; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeTrigger(cacheItem); } cache.Clear(); } private void FinalizeTrigger(IDefinition definition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; _ = definition.Key; CardTriggerType data = definition.Data; string id = definition.Id; logger.Log((LogLevel)16, (object)("Finalizing Card Trigger " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); string value = "CardTrigger_" + id; ((Dictionary)AccessTools.Field(typeof(CardTriggerTypeMethods), "TriggerToLocalizationExpression").GetValue(null))[data] = value; if (ParseExtensions.ParseBool(configuration.GetSection("disallow_in_deployment")) == true) { BalanceData balanceData = SaveManager.Value.GetAllGameData().GetBalanceData(); ((List)AccessTools.Field(typeof(BalanceData), "disallowedDeploymentPhaseCardTriggers").GetValue(balanceData)).Add(data); } } } public class CardTriggerTypePipeline : IDataPipeline, CardTriggerType> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; public CardTriggerTypePipeline(PluginAtlas atlas, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadTriggers(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List> LoadTriggers(IRegister service, string key, IConfiguration pluginConfig) { List> list = new List>(); foreach (IConfigurationSection child in pluginConfig.GetSection("card_trigger_types").GetChildren()) { CardTriggerTypeDefinition cardTriggerTypeDefinition = LoadTriggerConfiguration(service, key, child); if (cardTriggerTypeDefinition != null) { list.Add(cardTriggerTypeDefinition); } } return list; } private CardTriggerTypeDefinition? LoadTriggerConfiguration(IRegister service, string key, IConfiguration configuration) { //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_00b1: 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) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("TriggerEnum", text); CardTriggerType val = EnumAllocator.CreateEnum(key, text); string text2 = "CardTrigger_" + text; LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = text2 + "_CardText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { localizationTerm2.Key = text2 + "_TooltipText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm2.Key, localizationTerm2); } ((IRegisterableDictionary)(object)service).Register(id, val); return new CardTriggerTypeDefinition(key, val, configuration) { Id = text }; } } public class CardTriggerTypeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private static readonly Dictionary VanillaCardTriggerToEnum = new Dictionary { ["on_cast"] = (CardTriggerType)0, ["on_kill"] = (CardTriggerType)1, ["on_discard"] = (CardTriggerType)2, ["on_monster_death"] = (CardTriggerType)3, ["on_any_monster_death_on_floor"] = (CardTriggerType)4, ["on_any_hero_death_on_floor"] = (CardTriggerType)5, ["on_healed"] = (CardTriggerType)6, ["on_player_damage_taken"] = (CardTriggerType)7, ["on_any_unit_death_on_floor"] = (CardTriggerType)8, ["on_treasure"] = (CardTriggerType)9, ["on_unplayed_negative"] = (CardTriggerType)10, ["on_feed"] = (CardTriggerType)11, ["on_exhausted"] = (CardTriggerType)12, ["on_unplayed_positive"] = (CardTriggerType)13, ["on_forge"] = (CardTriggerType)14 }; public CardTriggerTypeRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaCardTriggerToEnum); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public void Register(string key, CardTriggerType item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register Card Trigger Enum (" + key + ")")); Add(key, item); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardTriggerType lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (CardTriggerType)0; IsModded = !VanillaCardTriggerToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class CharacterTriggerTypeDefinition(string key, Trigger data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public Trigger Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class CharacterTriggerTypeFinalizer : IDataFinalizer { private readonly Lazy SaveManager; private readonly GameDataClient client; private readonly IModLogger logger; private readonly IRegister spriteRegister; private readonly ICache> cache; public CharacterTriggerTypeFinalizer(IModLogger logger, GameDataClient client, IRegister spriteRegister, ICache> cache) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.client = client; this.logger = logger; this.spriteRegister = spriteRegister; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeTrigger(cacheItem); } cache.Clear(); } private void FinalizeTrigger(IDefinition definition) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_00a2: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01a0: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; string key = definition.Key; Trigger data = definition.Data; logger.Log((LogLevel)16, (object)("Finalizing Character Trigger " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); string text = "CharacterTrigger_" + definition.Id; StatusEffectManager instance = StatusEffectManager.Instance; StatusEffectsDisplayData obj = (StatusEffectsDisplayData)AccessTools.Field(typeof(StatusEffectManager), "displayData").GetValue(instance); CharacterTriggerData.TriggerToLocalizationExpression[data] = text; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("sprite").ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? _, referencedObject.context)) { ((SerializableDictionaryBase)(TriggerSpriteDict)AccessTools.Field(typeof(StatusEffectsDisplayData), "triggerIcons").GetValue(obj))[data] = lookup; } if (ParseExtensions.ParseBool(configuration.GetSection("is_state_modifier")) == true) { ((List)AccessTools.Field(typeof(StatusEffectsDisplayData), "stateModifierTriggers").GetValue(obj)).Add(data); } if (configuration.GetSection("notifications").Value != null) { ((SerializableDictionaryBase)(TriggersNotificationDict)AccessTools.Field(typeof(StatusEffectsDisplayData), "triggerNotificationList").GetValue(obj))[data] = new LocalizedString { key = text + "_NotificationText" }; } if (ParseExtensions.ParseBool(configuration.GetSection("hidden")) == true) { ((List)AccessTools.Field(typeof(CharacterTriggerData), "TriggersHiddenInUI").GetValue(null))?.Add(data); } if (ParseExtensions.ParseBool(configuration.GetSection("no_delay")) == true) { CharacterTriggerData.TriggersWithoutDelay.Add(data); } if (ParseExtensions.ParseBool(configuration.GetSection("disallow_in_deployment")) == true) { BalanceData balanceData = SaveManager.Value.GetAllGameData().GetBalanceData(); ((List)AccessTools.Field(typeof(BalanceData), "disallowedDeploymentPhaseCharacterTriggers").GetValue(balanceData)).Add(data); } } } public class CharacterTriggerTypePipeline : IDataPipeline, Trigger> { private readonly PluginAtlas atlas; private readonly IRegister termRegister; public CharacterTriggerTypePipeline(PluginAtlas atlas, IRegister termRegister) { this.atlas = atlas; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadTriggers(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List> LoadTriggers(IRegister service, string key, IConfiguration pluginConfig) { List> list = new List>(); foreach (IConfigurationSection child in pluginConfig.GetSection("character_trigger_types").GetChildren()) { CharacterTriggerTypeDefinition characterTriggerTypeDefinition = LoadTriggerConfiguration(service, key, child); if (characterTriggerTypeDefinition != null) { list.Add(characterTriggerTypeDefinition); } } return list; } private CharacterTriggerTypeDefinition? LoadTriggerConfiguration(IRegister service, string key, IConfiguration configuration) { //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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("CTriggerEnum", text); Trigger val = EnumAllocator.CreateEnum(key, text); string text2 = "CharacterTrigger_" + text; LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = text2 + "_CardText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm.Key, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { localizationTerm2.Key = text2 + "_TooltipText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm2.Key, localizationTerm2); } LocalizationTerm localizationTerm3 = configuration.GetSection("notifications").ParseLocalizationTerm(); if (localizationTerm3 != null) { localizationTerm3.Key = text2 + "_NotificationText"; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm3.Key, localizationTerm3); } ((IRegisterableDictionary)(object)service).Register(id, val); return new CharacterTriggerTypeDefinition(key, val, configuration) { Id = text }; } } public class CharacterTriggerTypeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private static readonly Dictionary VanillaCharacterTriggerToEnum = new Dictionary { ["on_death"] = (Trigger)0, ["post_combat"] = (Trigger)1, ["on_spawn"] = (Trigger)2, ["on_attacking"] = (Trigger)3, ["on_kill"] = (Trigger)4, ["on_any_hero_death_on_floor"] = (Trigger)5, ["on_any_monster_death_on_floor"] = (Trigger)6, ["on_heal"] = (Trigger)7, ["on_team_turn_begin"] = (Trigger)8, ["pre_combat"] = (Trigger)12, ["post_ascension"] = (Trigger)13, ["post_combat_healing"] = (Trigger)14, ["on_hit"] = (Trigger)15, ["after_spawn_enchant"] = (Trigger)16, ["post_descension"] = (Trigger)17, ["on_any_unit_death_on_floor"] = (Trigger)18, ["card_spell_played"] = (Trigger)19, ["card_monster_played"] = (Trigger)20, ["end_turn_pre_hand_discard"] = (Trigger)21, ["on_feed"] = (Trigger)22, ["on_eaten"] = (Trigger)23, ["on_turn_begin"] = (Trigger)24, ["on_burnout"] = (Trigger)25, ["on_spawn_not_from_card"] = (Trigger)26, ["on_unscaled_spawn"] = (Trigger)27, ["post_attempted_ascension"] = (Trigger)28, ["post_attempted_descension"] = (Trigger)29, ["on_hatched"] = (Trigger)30, ["card_corrupt_played"] = (Trigger)31, ["corruption_added"] = (Trigger)32, ["on_armor_added"] = (Trigger)33, ["on_food_spawn"] = (Trigger)34, ["card_exhausted"] = (Trigger)35, ["on_remove_hatch"] = (Trigger)37, ["on_own_ability_activated"] = (Trigger)38, ["on_sentry"] = (Trigger)39, ["regal_count_added"] = (Trigger)40, ["on_unit_ability_available"] = (Trigger)41, ["on_unit_ability_unavailable"] = (Trigger)42, ["on_shift"] = (Trigger)43, ["on_equipment_added"] = (Trigger)44, ["on_equipment_removed"] = (Trigger)45, ["on_deathwish"] = (Trigger)46, ["on_deathwish_lost"] = (Trigger)47, ["on_valiant"] = (Trigger)48, ["on_encounter_complete"] = (Trigger)49, ["on_pyregel_added"] = (Trigger)50, ["on_moon_phase_shift"] = (Trigger)51, ["on_equipment_added_to_ally"] = (Trigger)52, ["on_equipment_added_to_any"] = (Trigger)52, ["on_timebomb"] = (Trigger)53, ["on_reanimated"] = (Trigger)54, ["on_graft_equipment_added"] = (Trigger)55, ["on_new_status_effect_added"] = (Trigger)56, ["on_queued_status_effect_to_add"] = (Trigger)57, ["on_moon_lit"] = (Trigger)58, ["on_moon_shade"] = (Trigger)59, ["on_moonlit_lost"] = (Trigger)60, ["on_moonshade_lost"] = (Trigger)61, ["on_troop_added"] = (Trigger)62, ["on_troop_removed"] = (Trigger)63, ["on_train_room_loop"] = (Trigger)64, ["on_status_effect_changed"] = (Trigger)65, ["on_attacking_before_damage"] = (Trigger)66, ["on_silence"] = (Trigger)67, ["on_silence_lost"] = (Trigger)68, ["on_pre_own_ability_activated"] = (Trigger)69 }; public CharacterTriggerTypeRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaCharacterTriggerToEnum); } public void Register(string key, Trigger item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register Character Trigger Enum (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out Trigger lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (Trigger)0; IsModded = !VanillaCharacterTriggerToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } internal static class EnumAllocator where TEnum : Enum { private static IDictionary NameToEnum = new Dictionary(); private static long NextEnumId = Enum.GetValues(typeof(TEnum)).Cast().Select(Convert.ToInt64) .Max() + 1; internal static TEnum GetNext() { long nextEnumId = NextEnumId; NextEnumId++; return (TEnum)Enum.ToObject(typeof(TEnum), nextEnumId); } public static TEnum CreateEnum(string key, string id) { string id2 = key.GetId(typeof(TEnum).Name, id); TEnum next = GetNext(); NameToEnum.Add(id2, next); return next; } public static bool TryGetEnum(string key, string id, out TEnum val) { string id2 = key.GetId(typeof(TEnum).Name, id); return NameToEnum.TryGetValue(id2, out val); } } public static class EnumAllocator { public static Type CreateDamageType(string key, string id) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return EnumAllocator.CreateEnum(key, id); } public static bool TryGetDamageType(string key, string id, out Type val) { return EnumAllocator.TryGetEnum(key, id, out val); } } public class StatusEffectTriggerStagePipeline : IDataPipeline, TriggerStage> { private readonly PluginAtlas atlas; public StatusEffectTriggerStagePipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { LoadTriggerStages(service, pluginDefinition.Key, pluginDefinition.Value.Configuration); } return new List>(); } private void LoadTriggerStages(IRegister service, string key, IConfiguration pluginConfig) { foreach (IConfigurationSection child in pluginConfig.GetSection("status_effect_trigger_stages").GetChildren()) { LoadConfiguration(service, key, child); } } private void LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text != null) { string id = key.GetId("StatusEffectTriggerStage", text); TriggerStage val = EnumAllocator.CreateEnum(key, text); ((IRegisterableDictionary)(object)service).Register(id, val); } } } public class StatusEffectTriggerStageRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private static readonly Dictionary VanillaTriggerStageToEnum = new Dictionary { ["none"] = (TriggerStage)0, ["on_combat_turn_inert"] = (TriggerStage)1, ["on_pre_movement"] = (TriggerStage)2, ["on_pre_attacked"] = (TriggerStage)3, ["on_attacked"] = (TriggerStage)4, ["on_pre_attacking"] = (TriggerStage)5, ["on_post_combat_regen"] = (TriggerStage)6, ["on_post_combat_poison"] = (TriggerStage)7, ["on_ambush"] = (TriggerStage)8, ["on_relentless"] = (TriggerStage)9, ["on_multistrike"] = (TriggerStage)10, ["on_attract_damage"] = (TriggerStage)11, ["on_combat_turn_dazed"] = (TriggerStage)12, ["on_post_room_combat"] = (TriggerStage)13, ["on_attack_target_mode_requested"] = (TriggerStage)14, ["on_monster_team_turn_begin"] = (TriggerStage)15, ["on_death"] = (TriggerStage)16, ["on_post_attacking"] = (TriggerStage)17, ["on_pre_character_trigger"] = (TriggerStage)18, ["on_pre_attacked_spell_shield"] = (TriggerStage)19, ["on_pre_attacked_damage_shield"] = (TriggerStage)20, ["on_combat_turn_spark"] = (TriggerStage)21, ["on_pre_attacked_armor"] = (TriggerStage)22, ["on_pre_attacked_fragile"] = (TriggerStage)23, ["on_pre_eaten"] = (TriggerStage)24, ["on_post_eaten"] = (TriggerStage)25, ["on_almost_post_room_combat"] = (TriggerStage)26, ["on_healed"] = (TriggerStage)27, ["on_pre_flat_damage_increase"] = (TriggerStage)28, ["on_hit"] = (TriggerStage)29, ["on_post_spawn"] = (TriggerStage)30, ["on_pre_attacked_life_link"] = (TriggerStage)31, ["on_pre_attacked_titan_skin"] = (TriggerStage)32 }; public StatusEffectTriggerStageRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaTriggerStageToEnum); } List IRegister.GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } void IRegisterableDictionary.Register(string key, TriggerStage item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register StatusEffectTriggerStage Enum (" + key + ")")); Add(key, item); } bool IRegister.TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out TriggerStage lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (TriggerStage)0; IsModded = !VanillaTriggerStageToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class TargetModePipeline : IDataPipeline, TargetMode> { private readonly PluginAtlas atlas; public TargetModePipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { LoadTargetModes(service, pluginDefinition.Key, pluginDefinition.Value.Configuration); } return new List>(); } private void LoadTargetModes(IRegister service, string key, IConfiguration pluginConfig) { foreach (IConfigurationSection child in pluginConfig.GetSection("target_modes").GetChildren()) { LoadConfiguration(service, key, child); } } private void LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text != null) { string id = key.GetId("TargetModeEnum", text); TargetMode val = EnumAllocator.CreateEnum(key, text); ((IRegisterableDictionary)(object)service).Register(id, val); } } } public class TargetModeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private static readonly Dictionary VanillaTargetModeToEnum = new Dictionary { ["room"] = (TargetMode)0, ["random_in_room"] = (TargetMode)1, ["front_in_room"] = (TargetMode)2, ["room_heal_targets"] = (TargetMode)4, ["self"] = (TargetMode)5, ["last_attacked_character"] = (TargetMode)6, ["front_with_status"] = (TargetMode)7, ["tower"] = (TargetMode)8, ["back_in_room"] = (TargetMode)11, ["drop_target_character"] = (TargetMode)12, ["draw_pile"] = (TargetMode)13, ["discard"] = (TargetMode)14, ["exhaust"] = (TargetMode)15, ["eaten"] = (TargetMode)24, ["weakest"] = (TargetMode)16, ["last_attacker_character"] = (TargetMode)17, ["hand"] = (TargetMode)18, ["last_drawn_card"] = (TargetMode)19, ["last_feeder_character"] = (TargetMode)20, ["pyre"] = (TargetMode)21, ["last_targeted_characters"] = (TargetMode)22, ["last_damaged_characters"] = (TargetMode)23, ["last_spawned_morsel"] = (TargetMode)25, ["front_in_all_rooms"] = (TargetMode)26, ["front_in_room_and_room_above"] = (TargetMode)27, ["weakest_all_rooms"] = (TargetMode)29, ["strongest_all_rooms"] = (TargetMode)30, ["last_equipped_character"] = (TargetMode)31, ["last_sacrificed_character"] = (TargetMode)32, ["dying_character"] = (TargetMode)34, ["last_spawned_character"] = (TargetMode)36, ["random_from_any_room"] = (TargetMode)35 }; private readonly IModLogger logger; public TargetModeRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaTargetModeToEnum); } List IRegister.GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } void IRegisterableDictionary.Register(string key, TargetMode item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register TargetMode Enum (" + key + ")")); Add(key, item); } bool IRegister.TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out TargetMode lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (TargetMode)0; IsModded = !VanillaTargetModeToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class TrackedValueTypePipeline : IDataPipeline, TrackedValueType> { private readonly PluginAtlas atlas; public TrackedValueTypePipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { LoadTrackedValueTypes(service, pluginDefinition.Key, pluginDefinition.Value.Configuration); } return new List>(); } private void LoadTrackedValueTypes(IRegister service, string key, IConfiguration pluginConfig) { foreach (IConfigurationSection child in pluginConfig.GetSection("tracked_value_types").GetChildren()) { LoadConfiguration(service, key, child); } } private void LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text != null) { string id = key.GetId("TrackedValueTypeEnum", text); TrackedValueType val = EnumAllocator.CreateEnum(key, text); ((IRegisterableDictionary)(object)service).Register(id, val); } } } public class TrackedValueTypeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private static readonly Dictionary VanillaTrackedValueTypeToEnum = new Dictionary { ["subtype_in_deck"] = (TrackedValueType)0, ["subtype_in_discard_pile"] = (TrackedValueType)20, ["subtype_in_exhaust_pile"] = (TrackedValueType)21, ["subtype_in_draw_pile"] = (TrackedValueType)22, ["subtype_in_eaten_pile"] = (TrackedValueType)26, ["type_in_deck"] = (TrackedValueType)15, ["type_in_discard_pile"] = (TrackedValueType)16, ["type_in_exhaust_pile"] = (TrackedValueType)18, ["type_in_draw_pile"] = (TrackedValueType)19, ["type_in_eaten_pile"] = (TrackedValueType)27, ["played_cost"] = (TrackedValueType)1, ["unmodified_played_cost"] = (TrackedValueType)24, ["heroes_killed"] = (TrackedValueType)2, ["spawned_monster_deaths"] = (TrackedValueType)3, ["times_discarded"] = (TrackedValueType)4, ["times_played"] = (TrackedValueType)5, ["times_drawn"] = (TrackedValueType)6, ["times_exhausted"] = (TrackedValueType)7, ["last_sacrificed_monster_stats"] = (TrackedValueType)8, ["any_hero_killed"] = (TrackedValueType)9, ["any_monster_death"] = (TrackedValueType)10, ["any_monster_spawned"] = (TrackedValueType)23, ["any_discarded"] = (TrackedValueType)11, ["any_card_played"] = (TrackedValueType)12, ["any_card_drawn"] = (TrackedValueType)13, ["any_exhausted"] = (TrackedValueType)14, ["any_character"] = (TrackedValueType)39, ["any_monster_spawned_top_floor"] = (TrackedValueType)32, ["monster_subtype_played"] = (TrackedValueType)25, ["status_effect_count_in_target_room"] = (TrackedValueType)17, ["corruption_in_target_room"] = (TrackedValueType)30, ["turn_count"] = (TrackedValueType)31, ["dragons_hoard_amount"] = (TrackedValueType)34, ["moon_phase"] = (TrackedValueType)35, ["magic_power_in_target_room"] = (TrackedValueType)36, ["gold"] = (TrackedValueType)37, ["status_effect_count_on_last_ability_activator"] = (TrackedValueType)38, ["pyre_heart_resurrection"] = (TrackedValueType)40, ["num_specific_cards_in_deck"] = (TrackedValueType)41, ["any_status_effect_stacks_added"] = (TrackedValueType)42, ["any_status_effect_stacks_removed"] = (TrackedValueType)43, ["last_attack_damage_dealt"] = (TrackedValueType)44, ["capacity_of_target_room"] = (TrackedValueType)46, ["current_cost"] = (TrackedValueType)48, ["energy_remaining_end_of_turn"] = (TrackedValueType)45, ["forge_points"] = (TrackedValueType)47 }; private readonly IModLogger logger; public TrackedValueTypeRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaTrackedValueTypeToEnum); } List IRegister.GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } void IRegisterableDictionary.Register(string key, TrackedValueType item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register TrackedValueType Enum (" + key + ")")); Add(key, item); } bool IRegister.TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out TrackedValueType lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (TrackedValueType)0; IsModded = !VanillaTrackedValueTypeToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } } namespace TrainworksReloaded.Base.Effect { public class CardEffectDataPipeline : IDataPipeline, CardEffectData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; public CardEffectDataPipeline(PluginAtlas atlas, IRegister termRegister, IModLogger logger) { this.atlas = atlas; this.termRegister = termRegister; this.logger = logger; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadEffects(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadEffects(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("effects").GetChildren()) { CardEffectDefinition cardEffectDefinition = LoadEffectConfiguration(service, key, child); if (cardEffectDefinition != null) { list.Add(cardEffectDefinition); } } return list; } public CardEffectDefinition? LoadEffectConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0746: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0783: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07fd: Unknown result type (might be due to invalid IL or missing references) //IL_0828: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_0877: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Unknown result type (might be due to invalid IL or missing references) //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_08bf: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) //IL_08db: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Effect", text); CardEffectData val = new CardEffectData(); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("name").ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text2 = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text2, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to load effect state name " + id2 + " in " + text + " mod " + text2 + ", Make sure the class exists in " + text2 + " and that the class inherits from CardEffectBase.")); return null; } AccessTools.Field(typeof(CardEffectData), "effectStateName").SetValue(val, fullyQualifiedName); string text3 = ""; AccessTools.Field(typeof(CardEffectData), "paramStr").SetValue(val, ParseExtensions.ParseString(configuration.GetSection("param_str")) ?? text3); bool flag = false; AccessTools.Field(typeof(CardEffectData), "suppressPyreRoomFocus").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("supress_pyre_room_focus", "suppress_pyre_room_focus")) ?? flag); bool flag2 = false; AccessTools.Field(typeof(CardEffectData), "targetIgnoreBosses").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("target_ignore_bosses")) ?? flag2); bool flag3 = false; AccessTools.Field(typeof(CardEffectData), "filterBasedOnMainSubClass").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("filter_based_on_main_subclass", "filter_based_on_main_sub_class")) ?? flag3); bool flag4 = false; AccessTools.Field(typeof(CardEffectData), "copyModifiersFromSource").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("copy_modifiers", "copy_modifiers_from_source")) ?? flag4); bool flag5 = false; AccessTools.Field(typeof(CardEffectData), "ignoreTemporaryModifiersFromSource").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("ignore_temporary_modifiers", "ignore_temporary_modifiers_from_source")) ?? flag5); bool flag6 = false; AccessTools.Field(typeof(CardEffectData), "hideTooltip").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("hide_tooltip")) ?? flag6); bool flag7 = false; AccessTools.Field(typeof(CardEffectData), "showPyreNotification").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("show_pyre_notification")) ?? flag7); bool flag8 = true; AccessTools.Field(typeof(CardEffectData), "shouldTest").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("should_test")) ?? flag8); bool flag9 = false; AccessTools.Field(typeof(CardEffectData), "shouldCancelSubsequentEffectsIfTestFails").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("cancel_subsequent_effects_on_failure", "should_cancel_subsequent_effects_if_test_fails")) ?? flag9); bool flag10 = false; AccessTools.Field(typeof(CardEffectData), "shouldFailToCastIfTestFails").SetValue(val, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("fail_to_cast_on_failure", "should_fail_to_cast_if_test_fails")) ?? flag10); bool flag11 = false; AccessTools.Field(typeof(CardEffectData), "useIntRange").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("use_int_range")) ?? flag11); bool flag12 = false; AccessTools.Field(typeof(CardEffectData), "paramBool").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_bool")) ?? flag12); bool flag13 = false; AccessTools.Field(typeof(CardEffectData), "paramBool2").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_bool_2")) ?? flag13); bool flag14 = false; AccessTools.Field(typeof(CardEffectData), "paramBool3").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("param_bool_3")) ?? flag14); bool flag15 = false; AccessTools.Field(typeof(CardEffectData), "useStatusEffectStackMultiplier").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("use_status_effect_multiplier")) ?? flag15); bool flag16 = false; AccessTools.Field(typeof(CardEffectData), "useHealthMissingStackMultiplier").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("use_health_missing_multiplier")) ?? flag16); bool flag17 = false; AccessTools.Field(typeof(CardEffectData), "useMagicPowerMultiplier").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("use_magic_power_multiplier")) ?? flag17); bool flag18 = false; AccessTools.Field(typeof(CardEffectData), "disallowStatusEffectStackModifiers").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("disallow_status_effect_modifiers")) ?? flag18); int num = 0; AccessTools.Field(typeof(CardEffectData), "paramInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int")) ?? num); int num2 = 0; AccessTools.Field(typeof(CardEffectData), "additionalParamInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int_2")) ?? num2); int num3 = 0; AccessTools.Field(typeof(CardEffectData), "additionalParamInt1").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_int_3")) ?? num3); int num4 = 0; AccessTools.Field(typeof(CardEffectData), "paramMinInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_min_int")) ?? num4); int num5 = 0; AccessTools.Field(typeof(CardEffectData), "paramMaxInt").SetValue(val, ParseExtensions.ParseInt(configuration.GetSection("param_max_int")) ?? num5); float num6 = 1f; AccessTools.Field(typeof(CardEffectData), "paramMultiplier").SetValue(val, ParseExtensions.ParseFloat(configuration.GetSection("param_multiplier")) ?? num6); float num7 = 0f; AccessTools.Field(typeof(CardEffectData), "paramFloat").SetValue(val, ParseExtensions.ParseFloat(configuration.GetSection("param_float")) ?? num7); HealthFilter val2 = (HealthFilter)0; AccessTools.Field(typeof(CardEffectData), "targetModeHealthFilter").SetValue(val, configuration.GetSection("target_mode_health_filter").ParseHealthFilter() ?? val2); Type val3 = (Type)0; AccessTools.Field(typeof(CardEffectData), "targetTeamType").SetValue(val, configuration.GetSection("target_team").ParseTeamType() ?? val3); CardType val4 = (CardType)0; AccessTools.Field(typeof(CardEffectData), "targetCardType").SetValue(val, configuration.GetSection("target_card_type").ParseCardType() ?? val4); CardSelectionMode val5 = (CardSelectionMode)0; AccessTools.Field(typeof(CardEffectData), "targetCardSelectionMode").SetValue(val, configuration.GetSection("target_card_selection_mode").ParseCardSelectionMode() ?? val5); bool flag19 = false; AccessTools.Field(typeof(CardEffectData), "statusEffectTooltipsSuppressed").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("status_effect_tooltips_suppressed")) ?? flag19); Anim val6 = (Anim)0; AccessTools.Field(typeof(CardEffectData), "animToPlay").SetValue(val, configuration.GetSection("anim_to_play").ParseAnim() ?? val6); Vector3 val7 = ParseTimingDelays(configuration.GetSection("param_timing_delays")); AccessTools.Field(typeof(CardEffectData), "paramTimingDelays").SetValue(val, val7); ((IRegisterableDictionary)(object)service).Register(id, val); return new CardEffectDefinition(key, val, configuration); } private Vector3 ParseTimingDelays(IConfiguration configuration) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) float valueOrDefault = ParseExtensions.ParseFloat(configuration.GetSection("normal")).GetValueOrDefault(); float valueOrDefault2 = ParseExtensions.ParseFloat(configuration.GetSection("fast")).GetValueOrDefault(); float valueOrDefault3 = ParseExtensions.ParseFloat(configuration.GetSection("ultra")).GetValueOrDefault(); return new Vector3(valueOrDefault, valueOrDefault2, valueOrDefault3); } } public class CardEffectDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; public CardEffectDataRegister(IModLogger logger) { this.logger = logger; } public void Register(string key, CardEffectData item) { logger.Log((LogLevel)32, (object)("Register Effect (" + key + ")")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Values.Select((CardEffectData effect) => effect.GetEffectStateName()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardEffectData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 lookup = null; IsModded = true; if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } foreach (CardEffectData value in base.Values) { if (value.GetEffectStateName() == identifier) { lookup = value; return true; } } return false; } } public class CardEffectDefinition(string key, CardEffectData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CardEffectData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded { get; set; } = true; } public class CardEffectFinalizer : IDataFinalizer { private readonly IRegister tooltipRegister; private readonly IRegister cardRegister; private readonly IRegister characterDataRegister; private readonly IRegister cardUpgradeRegister; private readonly IRegister statusRegister; private readonly IRegister triggerEnumRegister; private readonly IRegister upgradeMaskRegister; private readonly IRegister cardPoolRegister; private readonly IRegister subtypeRegister; private readonly IRegister targetModeRegister; private readonly IRegister vfxRegister; private readonly IRegister relicRegister; private readonly IRegister rewardRegister; private readonly ICache> cache; public CardEffectFinalizer(IRegister tooltipRegister, IRegister cardRegister, IRegister characterDataRegister, IRegister cardUpgradeRegister, IRegister upgradeMaskRegister, IRegister statusRegister, IRegister triggerEnumRegister, IRegister cardPoolRegister, IRegister subtypeRegister, IRegister targetModeRegister, IRegister vfxRegister, IRegister relicRegister, IRegister rewardRegister, ICache> cache) { this.tooltipRegister = tooltipRegister; this.cardRegister = cardRegister; this.characterDataRegister = characterDataRegister; this.cardUpgradeRegister = cardUpgradeRegister; this.statusRegister = statusRegister; this.triggerEnumRegister = triggerEnumRegister; this.upgradeMaskRegister = upgradeMaskRegister; this.cardPoolRegister = cardPoolRegister; this.subtypeRegister = subtypeRegister; this.targetModeRegister = targetModeRegister; this.vfxRegister = vfxRegister; this.relicRegister = relicRegister; this.rewardRegister = rewardRegister; this.cache = cache; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardEffectData(cacheItem); } cache.Clear(); } private void FinalizeCardEffectData(IDefinition definition) { //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_05fa: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Expected O, but got Unknown //IL_07c4: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; string key = definition.Key; CardEffectData data = definition.Data; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetDeprecatedSection("param_card_data", "param_card").ParseReference(); if (referencedObject != null && cardRegister.TryLookupName(referencedObject.ToId(key, "Card"), out CardData lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(CardEffectData), "paramCardData").SetValue(data, lookup); } ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetDeprecatedSection("param_character_data", "param_character").ParseReference(); if (referencedObject2 != null && characterDataRegister.TryLookupName(referencedObject2.ToId(key, "Character"), out CharacterData lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(CardEffectData), "paramCharacterData").SetValue(data, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetDeprecatedSection("param_character_data_2", "param_character_2").ParseReference(); if (referencedObject3 != null && characterDataRegister.TryLookupName(referencedObject3.ToId(key, "Character"), out CharacterData lookup3, out IsModded, referencedObject3.context)) { AccessTools.Field(typeof(CardEffectData), "paramAdditionalCharacterData").SetValue(data, lookup3); } List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetDeprecatedSection("param_character_data_pool", "param_character_pool").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (characterDataRegister.TryLookupName(item.ToId(key, "Character"), out CharacterData lookup4, out IsModded, item.context)) { list.Add(lookup4); } } AccessTools.Field(typeof(CardEffectData), "paramCharacterDataPool").SetValue(data, list); ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("param_upgrade").ParseReference(); if (referencedObject4 != null && cardUpgradeRegister.TryLookupName(referencedObject4.ToId(key, "Upgrade"), out CardUpgradeData lookup5, out IsModded, referencedObject4.context)) { AccessTools.Field(typeof(CardEffectData), "paramCardUpgradeData").SetValue(data, lookup5); } string value = string.Empty; ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("status_effect_multiplier").ParseReference(); if (referencedObject5 != null) { string id = referencedObject5.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id, out StatusEffectData lookup6, out IsModded, referencedObject5.context)) { value = lookup6.GetStatusId(); } } AccessTools.Field(typeof(CardEffectData), "statusEffectStackMultiplier").SetValue(data, value); IEnumerable enumerable = (from x in configuration.GetDeprecatedSection("target_mode_status_effect_filter", "target_mode_status_effects_filter").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); List list2 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item2 in enumerable) { string id2 = item2.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup7, out IsModded, item2.context)) { list2.Add(lookup7.GetStatusId()); } } AccessTools.Field(typeof(CardEffectData), "targetModeStatusEffectsFilter").SetValue(data, list2.ToArray()); IEnumerable enumerable2 = (from x in configuration.GetSection("target_mode_status_effects_excluded_filter").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); List list3 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item3 in enumerable2) { string id3 = item3.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id3, out StatusEffectData lookup8, out IsModded, item3.context)) { list3.Add(lookup8.GetStatusId()); } } AccessTools.Field(typeof(CardEffectData), "targetModeStatusEffectsExcludedFilter").SetValue(data, list3.ToArray()); List list4 = new List(); foreach (IConfigurationSection child in configuration.GetSection("param_status_effects").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject6 = child.GetSection("status").ParseReference(); if (referencedObject6 == null) { continue; } string id4 = referencedObject6.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id4, out StatusEffectData lookup9, out IsModded, referencedObject6.context)) { StatusEffectStackData val = new StatusEffectStackData { statusId = lookup9.GetStatusId(), count = ((child != null) ? ParseExtensions.ParseInt(child.GetSection("count")) : ((int?)null)).GetValueOrDefault() }; bool? flag; if (child == null) { IsModded = null; flag = IsModded; } else { flag = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); } IsModded = flag; val.fromPermanentUpgrade = IsModded == true; list4.Add(val); } } AccessTools.Field(typeof(CardEffectData), "paramStatusEffects").SetValue(data, list4.ToArray()); Trigger val2 = (Trigger)0; ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetDeprecatedSection("trigger", "param_trigger").ParseReference(); if (referencedObject7 != null && triggerEnumRegister.TryLookupId(referencedObject7.ToId(key, "CTriggerEnum"), out var lookup10, out IsModded, referencedObject7.context)) { val2 = lookup10; } AccessTools.Field(typeof(CardEffectData), "paramTrigger").SetValue(data, val2); ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetSection("param_card_filter").ParseReference(); if (referencedObject8 != null) { upgradeMaskRegister.TryLookupId(referencedObject8.ToId(key, "UpgradeMask"), out CardUpgradeMaskData lookup11, out IsModded, referencedObject8.context); AccessTools.Field(typeof(CardEffectData), "paramCardFilter").SetValue(data, lookup11); } ParseReferenceExtensions.ReferencedObject referencedObject9 = configuration.GetSection("param_card_filter_2").ParseReference(); if (referencedObject9 != null) { upgradeMaskRegister.TryLookupId(referencedObject9.ToId(key, "UpgradeMask"), out CardUpgradeMaskData lookup12, out IsModded, referencedObject9.context); AccessTools.Field(typeof(CardEffectData), "paramCardFilterSecondary").SetValue(data, lookup12); } ParseReferenceExtensions.ReferencedObject referencedObject10 = configuration.GetSection("param_relic").ParseReference(); if (referencedObject10 != null) { relicRegister.TryLookupName(referencedObject10.ToId(key, "RelicData"), out RelicData lookup13, out IsModded, referencedObject10.context); AccessTools.Field(typeof(CardEffectData), "paramRelicData").SetValue(data, lookup13); } ParseReferenceExtensions.ReferencedObject referencedObject11 = configuration.GetSection("param_card_pool").ParseReference(); if (referencedObject11 != null) { cardPoolRegister.TryLookupId(referencedObject11.ToId(key, "CardPool"), out CardPool lookup14, out IsModded, referencedObject11.context); AccessTools.Field(typeof(CardEffectData), "paramCardPool").SetValue(data, lookup14); } ParseReferenceExtensions.ReferencedObject referencedObject12 = configuration.GetSection("target_mode").ParseReference(); if (referencedObject12 != null) { targetModeRegister.TryLookupId(referencedObject12.ToId(key, "TargetModeEnum"), out var lookup15, out IsModded, referencedObject12.context); AccessTools.Field(typeof(CardEffectData), "targetMode").SetValue(data, lookup15); } string value2 = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject13 = configuration.GetSection("target_subtype").ParseReference(); if (referencedObject13 != null && subtypeRegister.TryLookupId(referencedObject13.ToId(key, "Subtype"), out SubtypeData lookup16, out IsModded, referencedObject13.context)) { value2 = lookup16.Key; } AccessTools.Field(typeof(CardEffectData), "targetCharacterSubtype").SetValue(data, value2); IEnumerable enumerable3 = (from x in configuration.GetSection("target_character_excluded_subtypes").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); List list5 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item4 in enumerable3) { string id5 = item4.ToId(key, "Subtype"); if (subtypeRegister.TryLookupId(id5, out SubtypeData lookup17, out IsModded, item4.context)) { list5.Add(lookup17.Key); } } AccessTools.Field(typeof(CardEffectData), "targetCharacterExcludedSubtypes").SetValue(data, list5); string value3 = "SubtypesData_None"; ParseReferenceExtensions.ReferencedObject referencedObject14 = configuration.GetSection("param_subtype").ParseReference(); if (referencedObject14 != null && subtypeRegister.TryLookupId(referencedObject14.ToId(key, "Subtype"), out SubtypeData lookup18, out IsModded, referencedObject14.context)) { value3 = lookup18.Key; } AccessTools.Field(typeof(CardEffectData), "paramSubtype").SetValue(data, value3); List list6 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in configuration.GetSection("additional_tooltips").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item5.ToId(key, "AdditionalTooltip"); if (tooltipRegister.TryLookupName(name, out AdditionalTooltipData lookup19, out IsModded, item5.context)) { list6.Add(lookup19); } } AccessTools.Field(typeof(CardEffectData), "additionalTooltips").SetValue(data, list6.ToArray()); ParseReferenceExtensions.ReferencedObject referencedObject15 = configuration.GetSection("applied_to_self_vfx").ParseReference(); string id6 = referencedObject15?.ToId(key, "Vfx") ?? ""; if (vfxRegister.TryLookupId(id6, out VfxAtLoc lookup20, out IsModded, referencedObject15?.context)) { AccessTools.Field(typeof(CardEffectData), "appliedToSelfVFX").SetValue(data, lookup20); } ParseReferenceExtensions.ReferencedObject referencedObject16 = configuration.GetSection("applied_vfx").ParseReference(); string id7 = referencedObject16?.ToId(key, "Vfx") ?? ""; if (vfxRegister.TryLookupId(id7, out VfxAtLoc lookup21, out IsModded, referencedObject16?.context)) { AccessTools.Field(typeof(CardEffectData), "appliedVFX").SetValue(data, lookup21); } ParseReferenceExtensions.ReferencedObject referencedObject17 = configuration.GetSection("param_reward").ParseReference(); if (referencedObject17 != null && rewardRegister.TryLookupName(referencedObject17.ToId(key, "RewardData"), out RewardData lookup22, out IsModded, referencedObject17.context)) { AccessTools.Field(typeof(CardEffectData), "paramRewardData").SetValue(data, lookup22); } } } } namespace TrainworksReloaded.Base.Class { public class ClassAssetsDelegator { internal readonly IDictionary> ClassCharacterDisplays = new Dictionary>(); internal readonly IDictionary ClassCardDraftIcons = new Dictionary(); public void Add(string classID, List characterDisplays) { ClassCharacterDisplays.Add(classID, characterDisplays); } public void Add(string classID, Sprite cardDraftIcon) { ClassCardDraftIcons.Add(classID, cardDraftIcon); } public List? GetCharacterDisplays(string classID) { return IEnumerableUtility.GetValueOrDefault>(ClassCharacterDisplays, classID, (List)null); } public Sprite? GetCardDraftIcon(string classID) { return IEnumerableUtility.GetValueOrDefault(ClassCardDraftIcons, classID, (Sprite)null); } } public class ClassCardStyleDefinition(string key, ClassCardStyle data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public ClassCardStyle Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class ClassCardStyleDelegator { internal readonly IDictionary> ClassCardStyles = new Dictionary>(); public void Add(ClassCardStyle classStyle, IDictionary sprites) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ClassCardStyles.Add(classStyle, sprites); } public IDictionary? GetClassCardStyleSprites(ClassCardStyle classStyle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return IEnumerableUtility.GetValueOrDefault>(ClassCardStyles, classStyle, (IDictionary)null); } } public class ClassCardStyleFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly ClassCardStyleDelegator delegator; public ClassCardStyleFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, ClassCardStyleDelegator delegator) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.delegator = delegator; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeTrigger(cacheItem); } cache.Clear(); } private void FinalizeTrigger(IDefinition definition) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; string key = definition.Key; ClassCardStyle data = definition.Data; _ = definition.Id; logger.Log((LogLevel)16, (object)("Finalizing ClassCardStyle " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); Dictionary sprites = new Dictionary(); AddSprite((CardType)7, "equipment_card_frame_sprite"); AddSprite((CardType)1, "unit_card_frame_sprite"); AddSprite((CardType)8, "room_card_frame_sprite"); AddSprite((CardType)0, "spell_card_frame_sprite"); delegator.Add(data, sprites); void AddSprite(CardType type, string field) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection(field).ParseReference(); if (referencedObject != null && spriteRegister.TryLookupId(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? _, referencedObject.context)) { sprites.Add(type, lookup); } } } } public class ClassCardStylePipeline : IDataPipeline, ClassCardStyle> { private readonly PluginAtlas atlas; private static int NextEnumId = (from int x in Enum.GetValues(typeof(ClassCardStyle)).AsQueryable() select (x)).Max() + 1; public ClassCardStylePipeline(PluginAtlas atlas) { this.atlas = atlas; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange(LoadClassCardStyles(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List> LoadClassCardStyles(IRegister service, string key, IConfiguration pluginConfig) { List> list = new List>(); foreach (IConfigurationSection child in pluginConfig.GetSection("class_card_styles").GetChildren()) { ClassCardStyleDefinition classCardStyleDefinition = LoadConfiguration(service, key, child); if (classCardStyleDefinition != null) { list.Add(classCardStyleDefinition); } } return list; } private ClassCardStyleDefinition? LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("ClassCardStyle", text); ClassCardStyle val = (ClassCardStyle)(NextEnumId++); ((IRegisterableDictionary)(object)service).Register(id, val); return new ClassCardStyleDefinition(key, val, configuration) { Id = text }; } } public class ClassCardStyleRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private static readonly Dictionary VanillaClassStyleToEnum = new Dictionary { ["none"] = (ClassCardStyle)0, ["banished"] = (ClassCardStyle)7, ["pyreborne"] = (ClassCardStyle)8, ["luna_coven"] = (ClassCardStyle)9, ["underlegion"] = (ClassCardStyle)10, ["lazarus_league"] = (ClassCardStyle)11, ["hellhorned"] = (ClassCardStyle)1, ["awoken"] = (ClassCardStyle)2, ["stygian_guard"] = (ClassCardStyle)4, ["umbra"] = (ClassCardStyle)5, ["melting_remnant"] = (ClassCardStyle)3, ["wurmkin"] = (ClassCardStyle)6, ["railforged"] = (ClassCardStyle)12 }; public ClassCardStyleRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange((Dictionary)this, VanillaClassStyleToEnum); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return base.Keys.ToList(); } return new List(); } return base.Keys.ToList(); } public void Register(string key, ClassCardStyle item) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) logger.Log((LogLevel)16, (object)("Register ClassCardStyle (" + key + ")")); Add(key, item); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out ClassCardStyle lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 lookup = (ClassCardStyle)0; IsModded = !VanillaClassStyleToEnum.ContainsKey(identifier); if ((int)identifierType != 0) { if ((int)identifierType == 1) { return TryGetValue(identifier, out lookup); } return false; } return TryGetValue(identifier, out lookup); } } public class ClassDataDefinition : IDefinition { public string Key { get; set; } public ClassData Data { get; set; } public IConfiguration Configuration { get; set; } public string Id { get; set; } public bool IsModded { get; set; } public ClassDataDefinition(string key, ClassData data, IConfiguration configuration, bool isOverride) { Key = key; Data = data; Configuration = configuration; Id = ""; IsModded = !isOverride; base..ctor(); } } public class ClassDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister cardDataRegister; private readonly IRegister relicDataRegister; private readonly IRegister upgradeDataRegister; private readonly IRegister enhancerPoolRegister; private readonly IRegister gameObjectRegister; private readonly IRegister classCardStyleRegister; private readonly IRegister soundCueRegister; private readonly ClassAssetsDelegator classAssetsDelegator; public ClassDataFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, IRegister cardDataRegister, IRegister relicDataRegister, IRegister upgradeDataRegister, IRegister enhancerPoolRegister, IRegister gameObjectRegister, IRegister classCardStyleRegister, IRegister soundCueRegister, ClassAssetsDelegator classAssetsDelegator) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; this.cardDataRegister = cardDataRegister; this.relicDataRegister = relicDataRegister; this.upgradeDataRegister = upgradeDataRegister; this.enhancerPoolRegister = enhancerPoolRegister; this.gameObjectRegister = gameObjectRegister; this.classCardStyleRegister = classCardStyleRegister; this.soundCueRegister = soundCueRegister; this.classAssetsDelegator = classAssetsDelegator; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeClassData(cacheItem); } cache.Clear(); } private void FinalizeClassData(IDefinition definition) { //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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Invalid comparison between Unknown and I4 //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Invalid comparison between Unknown and I4 //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Invalid comparison between Unknown and I4 //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Invalid comparison between Unknown and I4 //IL_0903: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Expected O, but got Unknown IConfiguration configuration = definition.Configuration; ClassData data = definition.Data; string key = definition.Key; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); logger.Log((LogLevel)16, (object)("Finalizing Clan " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("card_draft_icon").ParseReference(); if (referencedObject != null && spriteRegister.TryLookupName(referencedObject.ToId(key, "Sprite"), out Sprite lookup, out bool? IsModded, referencedObject.context)) { classAssetsDelegator.Add(((Object)data).name, lookup); } object obj = AccessTools.Field(typeof(ClassData), "icons").GetValue(data); Type nestedType = typeof(ClassData).GetNestedType("IconSet", BindingFlags.NonPublic); if (obj == null) { obj = nestedType.GetConstructor(Array.Empty()).Invoke(Array.Empty()); AccessTools.Field(typeof(ClassData), "icons").SetValue(data, obj); } IConfigurationSection section = configuration.GetSection("icons"); ParseReferenceExtensions.ReferencedObject referencedObject2 = section.GetSection("small").ParseReference(); if (referencedObject2 != null && spriteRegister.TryLookupName(referencedObject2.ToId(key, "Sprite"), out Sprite lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(nestedType, "small").SetValue(obj, lookup2); } ParseReferenceExtensions.ReferencedObject referencedObject3 = section.GetSection("medium").ParseReference(); if (referencedObject3 != null && spriteRegister.TryLookupName(referencedObject3.ToId(key, "Sprite"), out Sprite lookup3, out IsModded, referencedObject3.context)) { AccessTools.Field(nestedType, "medium").SetValue(obj, lookup3); } ParseReferenceExtensions.ReferencedObject referencedObject4 = section.GetSection("large").ParseReference(); if (referencedObject4 != null && spriteRegister.TryLookupName(referencedObject4.ToId(key, "Sprite"), out Sprite lookup4, out IsModded, referencedObject4.context)) { AccessTools.Field(nestedType, "large").SetValue(obj, lookup4); } ParseReferenceExtensions.ReferencedObject referencedObject5 = section.GetSection("silhouette").ParseReference(); if (referencedObject5 != null && spriteRegister.TryLookupName(referencedObject5.ToId(key, "Sprite"), out Sprite lookup5, out IsModded, referencedObject5.context)) { AccessTools.Field(nestedType, "silhouette").SetValue(obj, lookup5); } string value = data.GetClanSelectSfxCue() ?? ""; ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetDeprecatedSection("sfx_cue", "clan_select_sfx_cue").ParseReference(); if (referencedObject6 != null && soundCueRegister.TryLookupName(referencedObject6.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup6, out IsModded, referencedObject6.context)) { value = lookup6.Name; } AccessTools.Field(typeof(ClassData), "clanSelectSfxCue").SetValue(data, value); ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("card_style").ParseReference(); if (referencedObject7 != null) { classCardStyleRegister.TryLookupId(referencedObject7.ToId(key, "ClassCardStyle"), out var lookup7, out IsModded, referencedObject7.context); AccessTools.Field(typeof(ClassData), "cardStyle").SetValue(data, lookup7); } List list = data.GetStarterRelics() ?? new List(); IConfigurationSection section2 = configuration.GetSection("starter_relics"); if ((int)val == 1 && section2.Exists()) { list.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section2.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item.ToId(key, "RelicData"); if (relicDataRegister.TryLookupName(name, out RelicData lookup8, out IsModded, item.context)) { list.Add(lookup8); } } AccessTools.Field(typeof(ClassData), "starterRelics").SetValue(data, list); List list2 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("class_select_character_displays").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item2.ToId(key, "GameObject"); if (gameObjectRegister.TryLookupId(id, out GameObject lookup9, out IsModded, item2.context)) { list2.Add(lookup9); } } classAssetsDelegator.Add(((Object)data).name, list2); IConfigurationSection deprecatedSection = configuration.GetDeprecatedSection("starter_upgrade", "starter_card_upgrade"); ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetDeprecatedSection("starter_upgrade", "starter_card_upgrade").ParseReference(); if (referencedObject8 != null && upgradeDataRegister.TryLookupName(referencedObject8.ToId(key, "Upgrade"), out CardUpgradeData lookup10, out IsModded, referencedObject8.context)) { AccessTools.Field(typeof(ClassData), "starterCardUpgrade").SetValue(data, lookup10); } if ((int)val == 1 && referencedObject8 == null && deprecatedSection.Exists()) { AccessTools.Field(typeof(ClassData), "starterCardUpgrade").SetValue(data, null); } IConfigurationSection section3 = configuration.GetSection("random_draft_enhancer_pool"); ParseReferenceExtensions.ReferencedObject referencedObject9 = section3.ParseReference(); if (referencedObject9 != null && enhancerPoolRegister.TryLookupId(referencedObject9.ToId(key, "EnhancerPool"), out EnhancerPool lookup11, out IsModded, referencedObject9.context)) { AccessTools.Field(typeof(ClassData), "randomDraftEnhancerPool").SetValue(data, lookup11); } if ((int)val == 1 && referencedObject9 == null && section3.Exists()) { AccessTools.Field(typeof(ClassData), "randomDraftEnhancerPool").SetValue(data, null); } List list3 = configuration.GetSection("champions").GetChildren().ToList(); List list4 = ((List)AccessTools.Field(typeof(ClassData), "champions").GetValue(data)) ?? new List(); if ((int)val == 1 && list3.Count > 0) { list4.Clear(); } foreach (IConfigurationSection item3 in list3) { ChampionData val2 = ScriptableObject.CreateInstance(); val2.championSelectedCue = ParseExtensions.ParseString(configuration.GetSection("selected_cue")) ?? ""; ParseReferenceExtensions.ReferencedObject referencedObject10 = item3.GetSection("card_data").ParseReference(); if (referencedObject10 != null && cardDataRegister.TryLookupName(referencedObject10.ToId(key, "Card"), out CardData lookup12, out IsModded, referencedObject10.context)) { val2.championCardData = lookup12; } ParseReferenceExtensions.ReferencedObject referencedObject11 = item3.GetSection("starter_card").ParseReference(); if (referencedObject11 != null && cardDataRegister.TryLookupName(referencedObject11.ToId(key, "Card"), out CardData lookup13, out IsModded, referencedObject11.context)) { val2.starterCardData = lookup13; } ParseReferenceExtensions.ReferencedObject referencedObject12 = item3.GetSection("icon").ParseReference(); if (referencedObject12 != null && spriteRegister.TryLookupName(referencedObject12.ToId(key, "Sprite"), out Sprite lookup14, out IsModded, referencedObject12.context)) { val2.championIcon = lookup14; } ParseReferenceExtensions.ReferencedObject referencedObject13 = item3.GetSection("locked_icon").ParseReference(); if (referencedObject13 != null && spriteRegister.TryLookupName(referencedObject13.ToId(key, "Sprite"), out Sprite lookup15, out IsModded, referencedObject13.context)) { val2.championLockedIcon = lookup15; } ParseReferenceExtensions.ReferencedObject referencedObject14 = item3.GetSection("portrait").ParseReference(); if (referencedObject14 != null && spriteRegister.TryLookupName(referencedObject14.ToId(key, "Sprite"), out Sprite lookup16, out IsModded, referencedObject14.context)) { val2.championPortrait = lookup16; } ParseReferenceExtensions.ReferencedObject referencedObject15 = item3.GetDeprecatedSection("selected_cue", "selected_sfx_cue").ParseReference(); if (referencedObject15 != null && soundCueRegister.TryLookupName(referencedObject15.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup17, out IsModded, referencedObject15.context)) { val2.championSelectedCue = lookup17.Name; } CardUpgradeTreeData val3 = ScriptableObject.CreateInstance(); if ((Object)(object)val2.championCardData != (Object)null) { CharacterData spawnCharacterData = val2.championCardData.GetSpawnCharacterData(); if ((Object)(object)spawnCharacterData != (Object)null) { AccessTools.Field(typeof(CardUpgradeTreeData), "champion").SetValue(val3, spawnCharacterData); } } List list5 = new List(); AccessTools.Field(typeof(CardUpgradeTreeData), "upgradeTrees").SetValue(val3, list5); foreach (IConfigurationSection child in item3.GetSection("upgrade_tree").GetChildren()) { UpgradeTree val4 = new UpgradeTree(); List list6 = new List(); AccessTools.Field(typeof(UpgradeTree), "cardUpgrades").SetValue(val4, list6); foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in child.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (upgradeDataRegister.TryLookupName(item4.ToId(key, "Upgrade"), out CardUpgradeData lookup18, out IsModded, item4.context)) { list6.Add(lookup18); } } list5.Add(val4); } AccessTools.Field(typeof(ChampionData), "upgradeTree").SetValue(val2, val3); list4.Add(val2); } AccessTools.Field(typeof(ClassData), "champions").SetValue(data, list4); } } public class ClassDataPipeline : IDataPipeline, ClassData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; private readonly CardPoolRegister cardPoolRegister; public ClassDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, CardPoolRegister cardPoolRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.cardPoolRegister = cardPoolRegister; this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadClasses(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadClasses(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("classes").GetChildren()) { ClassDataDefinition classDataDefinition = LoadClassConfiguration(service, key, child); if (classDataDefinition != null) { list.Add(classDataDefinition); } } return list; } private ClassDataDefinition? LoadClassConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Expected O, but got Unknown //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Invalid comparison between Unknown and I4 //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Class", text); string text2 = "ClassData_titleKey-" + id; string text3 = "ClassData_descriptionKey-" + id; string text4 = "ClassData_subclassDescriptionKey-" + id; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value; if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out ClassData lookup, out bool? _)) { logger.Log((LogLevel)16, (object)("Overriding Clan " + text + "...")); text2 = lookup.GetTitleKey(); text3 = lookup.GetDescriptionKey(); text4 = lookup.GetSubclassDescriptionKey(); value = ((GameData)lookup).GetID(); } else { lookup = ScriptableObject.CreateInstance(); ((Object)lookup).name = id; value = guidProvider.GetGuidDeterministic(id).ToString(); } AccessTools.Field(typeof(ClassData), "id").SetValue(lookup, value); LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(ClassData), "titleLoc").SetValue(lookup, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(ClassData), "descriptionLoc").SetValue(lookup, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } LocalizationTerm localizationTerm3 = configuration.GetSection("subclass_descriptions").ParseLocalizationTerm(); if (localizationTerm3 != null) { AccessTools.Field(typeof(ClassData), "subclassDescriptionLoc").SetValue(lookup, text4); localizationTerm3.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm3); } bool corruptionEnabled = lookup.GetCorruptionEnabled(); AccessTools.Field(typeof(ClassData), "corruptionEnabled").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("corruption_enabled")) ?? corruptionEnabled); bool flag = lookup.IsCrew(); AccessTools.Field(typeof(ClassData), "isCrew").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_crew")) ?? flag); bool flag2 = true; AccessTools.Field(typeof(ClassData), "isLaunchClan").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_launch_clan")) ?? flag2); bool flag3 = false; AccessTools.Field(typeof(ClassData), "isWurmkin").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_wurmkin")) ?? flag3); DLC val2 = (DLC)0; AccessTools.Field(typeof(ClassData), "requiredDlc").SetValue(lookup, configuration.GetSection("required_dlc").ParseDLC() ?? val2); Color val3 = (OverrideModeExtensions.IsNewContent(val) ? Color.white : lookup.GetUIColor()); AccessTools.Field(typeof(ClassData), "uiColor").SetValue(lookup, configuration.GetSection("ui_color").ParseColor() ?? val3); Color val4 = (OverrideModeExtensions.IsNewContent(val) ? Color.black : lookup.GetUIColorDark()); AccessTools.Field(typeof(ClassData), "uiColorDark").SetValue(lookup, configuration.GetSection("ui_color_dark").ParseColor() ?? val4); Gradient val5 = (OverrideModeExtensions.IsNewContent(val) ? new Gradient() : ((Gradient)AccessTools.Field(typeof(ClassData), "uiColorGradient").GetValue(lookup))); IConfigurationSection section = configuration.GetSection("ui_gradient"); List list = new List(); foreach (IConfigurationSection child in section.GetChildren()) { float? num = ParseExtensions.ParseFloat(child.GetSection("time")); Color val6 = (Color)(((??)child.GetSection("color").ParseColor()) ?? Color.white); if (num.HasValue) { list.Add(new GradientColorKey(val6, num.Value)); } } val5.SetKeys(list.ToArray(), Array.Empty()); AccessTools.Field(typeof(ClassData), "uiColorGradient").SetValue(lookup, val5); List list2 = (List)AccessTools.Field(typeof(ClassData), "classUnlockPreviewTexts").GetValue(lookup); IConfigurationSection deprecatedSection = configuration.GetDeprecatedSection("class_preview_texts", "class_unlock_preview_texts"); if ((int)val == 1 && deprecatedSection.Exists()) { list2.Clear(); } int num2 = 0; foreach (IConfigurationSection child2 in deprecatedSection.GetChildren()) { LocalizationTerm localizationTerm4 = child2.ParseLocalizationTerm(); if (localizationTerm4 != null) { localizationTerm4.Key = $"ClassData_previewKey-{id}-{num2}"; num2++; ((IRegisterableDictionary)(object)termRegister).Register(localizationTerm4.Key, localizationTerm4); list2.Add(localizationTerm4.Key); } } IConfigurationSection section2 = configuration.GetSection("unlock_criteria"); if (section2.Exists()) { UnlockCriteria unlockCriteria = lookup.GetUnlockCriteria(); LocalizationTerm localizationTerm5 = section2.GetSection("descriptions").ParseLocalizationTerm(); string text5 = unlockCriteria.GetDescriptionKey(); if (localizationTerm5 != null) { text5 = (localizationTerm5.Key = "ClassData_unlockDescriptionKey-" + id); ((IRegisterableDictionary)(object)termRegister).Register(text5, localizationTerm5); } AccessTools.Field(typeof(UnlockCriteria), "descriptionKey").SetValue(unlockCriteria, text5); TrackedValue val7 = (TrackedValue)(((??)section2.GetSection("unlock_condition").ParseTrackedValue()) ?? unlockCriteria.GetUnlockCondition()); AccessTools.Field(typeof(UnlockCriteria), "unlockCondition").SetValue(unlockCriteria, val7); int num3 = ParseExtensions.ParseInt(section2.GetSection("param_int")) ?? unlockCriteria.GetParamInt(); AccessTools.Field(typeof(UnlockCriteria), "paramInt").SetValue(unlockCriteria, num3); } bool flag4 = OverrideModeExtensions.IsNewContent(val); if (flag4) { ((IRegisterableDictionary)(object)service).Register(id, lookup); CardPool val8 = ScriptableObject.CreateInstance(); ((Object)val8).name = "Units" + text + "BannerReplacementMutator"; string key2 = ((Object)val8).name.ToId(key, "CardPool"); cardPoolRegister.Register(key2, val8); cardPoolRegister.RegisterBannerReplacementPool(id, val8); } return new ClassDataDefinition(key, lookup, configuration, !flag4); } } public class ClassDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly Lazy SaveManager; private readonly IModLogger logger; public ClassDataRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.logger = logger; } public void Register(string key, ClassData item) { logger.Log((LogLevel)16, (object)("Register Clan " + key + "...")); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "classDatas").GetValue(allGameData)).Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from classData in SaveManager.Value.GetAllGameData().GetAllClassDatas() select ((GameData)classData).GetID()).ToList(); } return new List(); } return (from classData in SaveManager.Value.GetAllGameData().GetAllClassDatas() select ((Object)classData).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out ClassData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 lookup = null; IsModded = null; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (ClassData allClassData in SaveManager.Value.GetAllGameData().GetAllClassDatas()) { if (((GameData)allClassData).GetID().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allClassData; IsModded = ContainsKey(((Object)allClassData).name); return true; } } return false; } return false; } foreach (ClassData allClassData2 in SaveManager.Value.GetAllGameData().GetAllClassDatas()) { if (((Object)allClassData2).name.Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allClassData2; IsModded = ContainsKey(((Object)allClassData2).name); return true; } } return false; } } } namespace TrainworksReloaded.Base.Character { public class CharacterChatterDefinition(string key, CharacterChatterData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CharacterChatterData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class CharacterChatterFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister triggerEnumRegister; private readonly IRegister chatterRegister; private readonly IRegister termRegister; public CharacterChatterFinalizer(IModLogger logger, ICache> cache, IRegister triggerEnumRegister, IRegister chatterRegister, IRegister termRegister) { this.logger = logger; this.cache = cache; this.triggerEnumRegister = triggerEnumRegister; this.chatterRegister = chatterRegister; this.termRegister = termRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCharacterChatterData(cacheItem); } cache.Clear(); } public void FinalizeCharacterChatterData(IDefinition definition) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; CharacterChatterData data = definition.Data; string key = definition.Key; string name = ((Object)data).name; logger.Log((LogLevel)16, (object)("Finalizing Character Chatter " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); int num = 0; List list = new List(); bool? IsModded; foreach (IConfigurationSection child in configuration.GetSection("trigger_expressions").GetChildren()) { Trigger trigger = (Trigger)0; ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("trigger").ParseReference(); if (referencedObject != null && triggerEnumRegister.TryLookupId(referencedObject.ToId(key, "CTriggerEnum"), out var lookup, out IsModded, referencedObject.context)) { trigger = lookup; } LocalizationTerm localizationTerm = child.GetSection("expressions").ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = $"CharacterChatterData_triggerExpressions{num}-{name}"; ((IDictionary)termRegister).Add(localizationTerm.Key, localizationTerm); list.Add(new TriggerChatterExpressionData { trigger = trigger, locKey = localizationTerm.Key }); } num++; } AccessTools.Field(typeof(CharacterChatterData), "characterTriggerExpressions").SetValue(data, list); ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("base_chatter").ParseReference(); if (referencedObject2 != null && chatterRegister.TryLookupId(referencedObject2.ToId(key, "Chatter"), out CharacterChatterData lookup2, out IsModded, referencedObject2.context)) { AccessTools.Field(typeof(CharacterChatterData), "baseData").SetValue(data, lookup2); } } } public class CharacterChatterPipeline : IDataPipeline, CharacterChatterData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; public CharacterChatterPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadChatter(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadChatter(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("chatter").GetChildren()) { CharacterChatterDefinition characterChatterDefinition = LoadChatterConfiguration(service, key, child); if (characterChatterDefinition != null) { list.Add(characterChatterDefinition); } } return list; } private CharacterChatterDefinition? LoadChatterConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } CharacterChatterData val = ScriptableObject.CreateInstance(); string text2 = (((Object)val).name = key.GetId("Chatter", text)); int num = 0; List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("added_expressions").GetChildren()) { LocalizationTerm localizationTerm = child.ParseLocalizationTerm(); if (localizationTerm != null) { localizationTerm.Key = $"CharacterChatterData_addedExpressions{num}-{text2}"; ((IDictionary)termRegister).Add(localizationTerm.Key, localizationTerm); list.Add(new ChatterExpressionData { locKey = localizationTerm.Key }); } num++; } AccessTools.Field(typeof(CharacterChatterData), "characterAddedExpressions").SetValue(val, list); num = 0; List list2 = new List(); foreach (IConfigurationSection child2 in configuration.GetSection("attacking_expressions").GetChildren()) { LocalizationTerm localizationTerm2 = child2.ParseLocalizationTerm(); if (localizationTerm2 != null) { localizationTerm2.Key = $"CharacterChatterData_attackingExpressions{num}-{text2}"; ((IDictionary)termRegister).Add(localizationTerm2.Key, localizationTerm2); list2.Add(new ChatterExpressionData { locKey = localizationTerm2.Key }); } num++; } AccessTools.Field(typeof(CharacterChatterData), "characterAttackingExpressions").SetValue(val, list2); num = 0; List list3 = new List(); foreach (IConfigurationSection child3 in configuration.GetSection("idle_expressions").GetChildren()) { LocalizationTerm localizationTerm3 = child3.ParseLocalizationTerm(); if (localizationTerm3 != null) { localizationTerm3.Key = $"CharacterChatterData_idleExpressions{num}-{text2}"; ((IDictionary)termRegister).Add(localizationTerm3.Key, localizationTerm3); list3.Add(new ChatterExpressionData { locKey = localizationTerm3.Key }); } num++; } AccessTools.Field(typeof(CharacterChatterData), "characterIdleExpressions").SetValue(val, list3); num = 0; List list4 = new List(); foreach (IConfigurationSection child4 in configuration.GetSection("slayed_expressions").GetChildren()) { LocalizationTerm localizationTerm4 = child4.ParseLocalizationTerm(); if (localizationTerm4 != null) { localizationTerm4.Key = $"CharacterChatterData_slayedExpressions{num}-{text2}"; ((IDictionary)termRegister).Add(localizationTerm4.Key, localizationTerm4); list4.Add(new ChatterExpressionData { locKey = localizationTerm4.Key }); } num++; } AccessTools.Field(typeof(CharacterChatterData), "characterSlayedExpressions").SetValue(val, list4); Gender val2 = configuration.GetSection("gender").ParseGender((Gender)0); AccessTools.Field(typeof(CharacterChatterData), "gender").SetValue(val, val2); ((IRegisterableDictionary)(object)service).Register(text2, val); return new CharacterChatterDefinition(key, val, configuration) { Id = text }; } } public class CharacterChatterRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaChatter = new Dictionary(); public CharacterChatterRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaChatter, Resources.FindObjectsOfTypeAll().ToDictionary((CharacterChatterData x) => ((Object)x).name, (CharacterChatterData x) => x)); Extensions.AddRange((Dictionary)this, VanillaChatter); } public void Register(string key, CharacterChatterData item) { logger.Log((LogLevel)32, (object)("Register Character Chatter " + key + "...")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CharacterChatterData? lookup, [NotNullWhen(true)] out bool? IsModded) { lookup = null; IsModded = !VanillaChatter.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } public class CharacterDataDefinition : IDefinition { public string Key { get; set; } public CharacterData Data { get; set; } public CharacterData CopyData { get; set; } public OverrideMode Override { get; set; } public IConfiguration Configuration { get; set; } public string Id { get; set; } public bool IsModded { get; set; } public CharacterDataDefinition(string key, CharacterData data, CharacterData copyData, IConfiguration configuration, OverrideMode overrideMode, bool modded) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) Key = key; Data = data; CopyData = copyData; Override = overrideMode; Configuration = configuration; Id = ""; IsModded = modded; base..ctor(); } } public class CharacterDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister assetReferenceRegister; private readonly IRegister gameObjectRegister; private readonly IRegister triggerRegister; private readonly IRegister vfxRegister; private readonly IRegister statusRegister; private readonly IRegister cardRegister; private readonly IRegister chatterRegister; private readonly IRegister subtypeRegister; private readonly IRegister roomModifierRegister; private readonly IRegister relicRegister; private readonly IRegister soundCueRegister; private readonly IRegister pyreHeartRegister; private readonly FallbackDataProvider dataProvider; private readonly IRegister effectRegister; private readonly PluginAtlas atlas; public CharacterDataFinalizer(IModLogger logger, ICache> cache, PluginAtlas atlas, IRegister assetReferenceRegister, IRegister gameObjectRegister, IRegister triggerRegister, IRegister vfxRegister, IRegister statusRegister, IRegister cardRegister, IRegister chatterRegister, IRegister subtypeRegister, IRegister roomModifierRegister, IRegister relicRegister, IRegister soundCueRegister, IRegister pyreHeartRegister, IRegister effectRegister, FallbackDataProvider dataProvider) { this.logger = logger; this.cache = cache; this.assetReferenceRegister = assetReferenceRegister; this.atlas = atlas; this.gameObjectRegister = gameObjectRegister; this.triggerRegister = triggerRegister; this.vfxRegister = vfxRegister; this.statusRegister = statusRegister; this.cardRegister = cardRegister; this.chatterRegister = chatterRegister; this.subtypeRegister = subtypeRegister; this.roomModifierRegister = roomModifierRegister; this.relicRegister = relicRegister; this.soundCueRegister = soundCueRegister; this.pyreHeartRegister = pyreHeartRegister; this.effectRegister = effectRegister; this.dataProvider = dataProvider; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCharacterData(cacheItem as CharacterDataDefinition); } cache.Clear(); } public void FinalizeCharacterData(CharacterDataDefinition definition) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Invalid comparison between Unknown and I4 //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Invalid comparison between Unknown and I4 //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_077c: Invalid comparison between Unknown and I4 //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_0894: Invalid comparison between Unknown and I4 //IL_09b7: Unknown result type (might be due to invalid IL or missing references) //IL_09ba: Invalid comparison between Unknown and I4 //IL_0a2d: Unknown result type (might be due to invalid IL or missing references) //IL_0a32: Unknown result type (might be due to invalid IL or missing references) //IL_0a3f: Unknown result type (might be due to invalid IL or missing references) //IL_0a5f: Unknown result type (might be due to invalid IL or missing references) //IL_0a84: Expected O, but got Unknown //IL_0b83: Unknown result type (might be due to invalid IL or missing references) //IL_0b86: Invalid comparison between Unknown and I4 //IL_0afc: Unknown result type (might be due to invalid IL or missing references) //IL_0aff: Invalid comparison between Unknown and I4 //IL_0bf0: Unknown result type (might be due to invalid IL or missing references) //IL_0bf3: Invalid comparison between Unknown and I4 //IL_0cf8: Unknown result type (might be due to invalid IL or missing references) //IL_0cfb: Invalid comparison between Unknown and I4 //IL_0e53: Unknown result type (might be due to invalid IL or missing references) //IL_0e56: Invalid comparison between Unknown and I4 //IL_0efa: Unknown result type (might be due to invalid IL or missing references) //IL_0efd: Invalid comparison between Unknown and I4 //IL_0f7a: Unknown result type (might be due to invalid IL or missing references) IConfiguration configuration = definition.Configuration; CharacterData data = definition.Data; CharacterData copyData = definition.CopyData; string key = definition.Key; OverrideMode val = definition.Override; logger.Log((LogLevel)16, (object)("Finalizing Character " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("character_art").ParseAssetReference(); object? value = AccessTools.Field(typeof(CharacterData), "characterPrefabVariantRef").GetValue(copyData); AssetReferenceGameObject value2 = (AssetReferenceGameObject)((value is AssetReferenceGameObject) ? value : null); if (referencedObject != null && assetReferenceRegister.TryLookupId(referencedObject.ToId(key, "GameObject"), out AssetReferenceGameObject lookup, out bool? IsModded, referencedObject.context)) { value2 = lookup; } AccessTools.Field(typeof(CharacterData), "characterPrefabVariantRef").SetValue(data, value2); IEnumerable enumerable = (from x in configuration.GetSection("sound_effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); if (enumerable.Any() && referencedObject != null && gameObjectRegister.TryLookupName(referencedObject.ToId(key, "GameObject"), out GameObject lookup2, out IsModded, referencedObject.context)) { CoreSoundEffectHolder val2 = lookup2.AddComponent(); val2.SoundEffectData = ScriptableObject.CreateInstance(); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in enumerable) { if (soundCueRegister.TryLookupId(item.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup3, out bool? _, item.context)) { list.Add(lookup3); } } val2.SoundEffectData.Sounds = list.ToArray(); } IConfigurationSection section = configuration.GetSection("ability"); AccessTools.Field(typeof(CharacterData), "unitAbility").SetValue(data, copyData.GetUnitAbilityCardData()); ParseReferenceExtensions.ReferencedObject referencedObject2 = section.ParseReference(); if (referencedObject2 != null) { cardRegister.TryLookupName(referencedObject2.ToId(key, "Card"), out CardData lookup4, out IsModded, referencedObject2.context); if ((Object)(object)lookup4 != (Object)null && !lookup4.IsUnitAbility()) { logger.Log((LogLevel)4, (object)("Attempting to add " + ((Object)lookup4).name + " as a unit ability upgrade for " + ((Object)data).name + ", but is not a unit ability card.")); } AccessTools.Field(typeof(CharacterData), "unitAbility").SetValue(data, lookup4); } if ((int)val == 1 && referencedObject2 == null && section.Exists()) { AccessTools.Field(typeof(CharacterData), "unitAbility").SetValue(data, null); } IConfigurationSection section2 = configuration.GetSection("grafted_equipment"); AccessTools.Field(typeof(CharacterData), "graftedEquipment").SetValue(data, copyData.GetGraftedEquipment()); ParseReferenceExtensions.ReferencedObject referencedObject3 = section2.ParseReference(); if (referencedObject3 != null) { cardRegister.TryLookupName(referencedObject3.ToId(key, "Card"), out CardData lookup5, out IsModded, referencedObject3.context); AccessTools.Field(typeof(CharacterData), "graftedEquipment").SetValue(data, lookup5); } if ((int)val == 1 && section2.Exists() && referencedObject3 == null) { AccessTools.Field(typeof(CharacterData), "graftedEquipment").SetValue(data, null); } ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("projectile_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "projectilePrefab").SetValue(data, copyData.GetProjectilePrefab()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject4 != null) { vfxRegister.TryLookupId(referencedObject4?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup6, out IsModded, referencedObject4?.context); AccessTools.Field(typeof(CharacterData), "projectilePrefab").SetValue(data, lookup6); } ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("attack_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "attackVFX").SetValue(data, copyData.GetAttackVfx()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject5 != null) { vfxRegister.TryLookupId(referencedObject5?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup7, out IsModded, referencedObject5?.context); AccessTools.Field(typeof(CharacterData), "attackVFX").SetValue(data, lookup7); } ParseReferenceExtensions.ReferencedObject referencedObject6 = configuration.GetSection("impact_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "impactVFX").SetValue(data, copyData.GetImpactVfx()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject6 != null) { vfxRegister.TryLookupId(referencedObject6?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup8, out IsModded, referencedObject6?.context); AccessTools.Field(typeof(CharacterData), "impactVFX").SetValue(data, lookup8); } ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("death_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "deathVFX").SetValue(data, copyData.GetDeathVfx()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject7 != null) { vfxRegister.TryLookupId(referencedObject7?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup9, out IsModded, referencedObject7?.context); AccessTools.Field(typeof(CharacterData), "deathVFX").SetValue(data, lookup9); } ParseReferenceExtensions.ReferencedObject referencedObject8 = configuration.GetDeprecatedSection("boss_cast_vfx", "boss_spell_cast_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "bossSpellCastVFX").SetValue(data, copyData.GetBossSpellCastVfx()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject8 != null) { vfxRegister.TryLookupId(referencedObject8?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup10, out IsModded, referencedObject8?.context); AccessTools.Field(typeof(CharacterData), "bossSpellCastVFX").SetValue(data, lookup10); } ParseReferenceExtensions.ReferencedObject referencedObject9 = configuration.GetSection("boss_room_cast_vfx").ParseReference(); AccessTools.Field(typeof(CharacterData), "bossRoomSpellCastVFX").SetValue(data, copyData.GetBossRoomSpellCastVfx()); if (OverrideModeExtensions.IsNewContent(val) || referencedObject9 != null) { vfxRegister.TryLookupId(referencedObject9?.ToId(key, "Vfx") ?? "", out VfxAtLoc lookup11, out IsModded, referencedObject9?.context); AccessTools.Field(typeof(CharacterData), "bossRoomSpellCastVFX").SetValue(data, lookup11); } List list2 = copyData.GetTriggers().ToList() ?? new List(); if ((Object)(object)copyData != (Object)(object)data) { list2 = list2.ToList(); } IConfigurationSection section3 = configuration.GetSection("triggers"); if ((int)val == 1 && section3.Exists()) { list2.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in section3.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (triggerRegister.TryLookupId(item2.ToId(key, "CTrigger"), out CharacterTriggerData lookup12, out IsModded, item2.context)) { list2.Add(lookup12); } } AccessTools.Field(typeof(CharacterData), "triggers").SetValue(data, list2); List list3 = copyData.GetStatusEffectImmunities()?.ToList() ?? new List(); if ((Object)(object)copyData != (Object)(object)data) { list3 = list3.ToList(); } IConfigurationSection section4 = configuration.GetSection("status_effect_immunities"); if ((int)val == 1 && section4.Exists()) { list3.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in section4.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item3.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id, out StatusEffectData lookup13, out IsModded, item3.context)) { list3.Add(lookup13.GetStatusId()); } } AccessTools.Field(typeof(CharacterData), "statusEffectImmunities").SetValue(data, list3.ToArray()); List list4 = copyData.GetStartingStatusEffects()?.ToList() ?? new List(); if ((Object)(object)copyData != (Object)(object)data) { list4 = list4.ToList(); } IConfigurationSection section5 = configuration.GetSection("starting_status_effects"); if ((int)val == 1 && section5.Exists()) { list4.Clear(); } foreach (IConfigurationSection child in section5.GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject10 = child.GetSection("status").ParseReference(); if (referencedObject10 != null) { string id2 = referencedObject10.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup14, out IsModded, referencedObject10.context)) { List list5 = list4; StatusEffectStackData val3 = new StatusEffectStackData { statusId = lookup14.GetStatusId(), count = ParseExtensions.ParseInt(child.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); val3.fromPermanentUpgrade = IsModded == true; list5.Add(val3); } } } AccessTools.Field(typeof(CharacterData), "startingStatusEffects").SetValue(data, list4.ToArray()); IConfigurationSection section6 = configuration.GetSection("chatter"); AccessTools.Field(typeof(CharacterData), "characterChatterData").SetValue(data, copyData.GetCharacterChatterData()); ParseReferenceExtensions.ReferencedObject referencedObject11 = section6.ParseReference(); if (referencedObject11 != null) { if ((int)val == 2) { logger.Log((LogLevel)4, (object)("Requested Append override mode for Character " + definition.Id + " key " + definition.Key + ", but this isn't supported for CharacterChatterData, replacing the chatter with what is given.")); } if (chatterRegister.TryLookupId(referencedObject11.ToId(key, "Chatter"), out CharacterChatterData lookup15, out IsModded, referencedObject11.context)) { AccessTools.Field(typeof(CharacterData), "characterChatterData").SetValue(data, lookup15); } } if ((int)val == 2 && referencedObject11 == null && section6.Exists()) { AccessTools.Field(typeof(CharacterData), "characterChatterData").SetValue(data, null); } List list6 = (List)AccessTools.Field(typeof(CharacterData), "subtypeKeys").GetValue(copyData); if ((Object)(object)copyData != (Object)(object)data) { list6 = list6.ToList(); } IConfigurationSection section7 = configuration.GetSection("subtypes"); if ((int)val == 1 && section7.Exists()) { list6.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in section7.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (subtypeRegister.TryLookupId(item4.ToId(key, "Subtype"), out SubtypeData lookup16, out IsModded, item4.context)) { list6.Add(lookup16.Key); } } AccessTools.Field(typeof(CharacterData), "subtypeKeys").SetValue(data, list6); List list7 = copyData.GetRoomModifiersData(); if ((Object)(object)copyData != (Object)(object)data) { list7 = list7.ToList(); } IConfigurationSection section8 = configuration.GetSection("room_modifiers"); if ((int)val == 1 && section8.Exists()) { list7.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in section8.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (roomModifierRegister.TryLookupId(item5.ToId(key, "RoomModifier"), out RoomModifierData lookup17, out IsModded, item5.context)) { list7.Add(lookup17); } } AccessTools.Field(typeof(CharacterData), "roomModifiers").SetValue(data, list7); IConfigurationSection deprecatedSection = configuration.GetDeprecatedSection("enemy_relic_data", "enemy_relic"); AccessTools.Field(typeof(CharacterData), "enemyRelicData").SetValue(data, copyData.GetEnemyRelicData()); ParseReferenceExtensions.ReferencedObject referencedObject12 = deprecatedSection.ParseReference(); if (referencedObject12 != null) { relicRegister.TryLookupId(referencedObject12.ToId(key, "RelicData"), out RelicData lookup18, out IsModded, referencedObject12.context); AccessTools.Field(typeof(CharacterData), "enemyRelicData").SetValue(data, lookup18); } if ((int)val == 1 && referencedObject12 == null && deprecatedSection.Exists()) { AccessTools.Field(typeof(CharacterData), "enemyRelicData").SetValue(data, null); } IConfigurationSection section9 = configuration.GetSection("pyre_heart_data"); AccessTools.Field(typeof(CharacterData), "pyreHeartData").SetValue(data, copyData.GetPyreHeartData()); ParseReferenceExtensions.ReferencedObject referencedObject13 = section9.ParseReference(); if (referencedObject13 != null) { pyreHeartRegister.TryLookupName(referencedObject13.ToId(key, "PyreHeart"), out PyreHeartData lookup19, out IsModded, referencedObject13.context); AccessTools.Field(typeof(CharacterData), "pyreHeartData").SetValue(data, lookup19); } if ((int)val == 1 && referencedObject13 == null && section9.Exists()) { AccessTools.Field(typeof(CharacterData), "pyreHeartData").SetValue(data, null); } List value3 = copyData.GetBossActionData().ToList(); if ((Object)(object)copyData != (Object)(object)data) { AccessTools.Field(typeof(CharacterData), "bossActionGroups").SetValue(data, value3); } IConfigurationSection section10 = configuration.GetSection("boss_action_groups"); if (section10.Exists()) { ParseBossActionGroups(section10, key, definition.Id, data, val); } AccessTools.Field(typeof(CharacterData), "fallbackData").SetValue(data, dataProvider.FallbackData); } private void ParseBossActionGroups(IConfiguration configuration, string key, string id, CharacterData data, OverrideMode mode) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown List bossActionData = data.GetBossActionData(); if ((int)mode == 1) { bossActionData.Clear(); } foreach (IConfigurationSection child in configuration.GetChildren()) { ActionGroupData val = new ActionGroupData(); AccessTools.Field(typeof(ActionGroupData), "_actions").SetValue(val, new List()); int num = ParseExtensions.ParseInt(child.GetSection("num_repeats")) ?? val.GetNumRepeats(); AccessTools.Field(typeof(ActionGroupData), "_numRepeats").SetValue(val, num); List actions = val.GetActions(); foreach (IConfigurationSection child2 in child.GetSection("actions").GetChildren()) { actions.Add(ParseBossActionData(child2, key, id)); } bossActionData.Add(val); } } private BossActionData? ParseBossActionData(IConfiguration configuration, string key, string id) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) BossActionData val = new BossActionData(); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("name").ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)2, (object)("Failed to boss action behavior " + id2 + " in " + id + " mod " + text + ", Make sure the class exists in " + text + " and that the class implements IBossActionBehavior.")); return null; } AccessTools.Field(typeof(BossActionData), "_actionBehaviorName").SetValue(val, fullyQualifiedName); Type valueOrDefault2 = configuration.GetSection("param_team").ParseTeamType().GetValueOrDefault(); AccessTools.Field(typeof(BossActionData), "_paramTeamType").SetValue(val, valueOrDefault2); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (effectRegister.TryLookupId(item.ToId(key, "Effect"), out CardEffectData lookup, out bool? _, item.context)) { list.Add(lookup); } } AccessTools.Field(typeof(BossActionData), "_actionEffects").SetValue(val, list); return val; } } public class CharacterDataPipeline : IDataPipeline, CharacterData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; public CharacterDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadCharacters(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadCharacters(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("characters").GetChildren()) { CharacterDataDefinition characterDataDefinition = LoadCharacterConfiguration(service, key, child); if (characterDataDefinition != null) { list.Add(characterDataDefinition); } } return list; } private CharacterDataDefinition? LoadCharacterConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_076d: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0780: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_07b1: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07c2: Unknown result type (might be due to invalid IL or missing references) //IL_07cc: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_0805: Unknown result type (might be due to invalid IL or missing references) //IL_0807: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_0850: Invalid comparison between Unknown and I4 //IL_0a05: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Character", text); string text2 = "CharacterData_nameKey-" + id; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value = configuration.GetSection("clone_id").Value; bool? IsModded; CharacterData lookup2; string value2; CharacterData val2; if (value != null) { logger.Log((LogLevel)32, (object)("Cloning Character " + value + "...")); service.TryLookupName(value, out CharacterData lookup, out IsModded); lookup2 = ScriptableObject.CreateInstance(); ((Object)lookup2).name = id; value2 = guidProvider.GetGuidDeterministic(id).ToString(); val2 = lookup ?? lookup2; } else if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out lookup2, out IsModded)) { logger.Log((LogLevel)16, (object)("Overriding Character " + text + "...")); text2 = lookup2.GetNameKey(); value2 = ((GameData)lookup2).GetID(); val2 = lookup2; } else { lookup2 = ScriptableObject.CreateInstance(); ((Object)lookup2).name = id; value2 = guidProvider.GetGuidDeterministic(id).ToString(); val2 = lookup2; } AccessTools.Field(typeof(CharacterData), "id").SetValue(lookup2, value2); AccessTools.Field(typeof(CharacterData), "nameKey").SetValue(lookup2, val2.GetNameKey()); LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(CharacterData), "nameKey").SetValue(lookup2, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } bool hideInLogbook = val2.GetHideInLogbook(); AccessTools.Field(typeof(CharacterData), "hideInLogbook").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("hide_in_logbook")) ?? hideInLogbook); bool flag = val2.BlockVisualSizeIncrease(); AccessTools.Field(typeof(CharacterData), "blockVisualSizeIncrease").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("block_size_increase", "block_visual_size_increase")) ?? flag); bool canBeHealed = val2.GetCanBeHealed(); AccessTools.Field(typeof(CharacterData), "canBeHealed").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("can_be_healed")) ?? canBeHealed); bool flag2 = val2.IsOuterTrainBoss(); AccessTools.Field(typeof(CharacterData), "isOuterTrainBoss").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("is_outer_train_boss")) ?? flag2); bool flag3 = val2.IsMiniboss(); AccessTools.Field(typeof(CharacterData), "isMiniboss").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("is_mini_boss")) ?? flag3); bool flag4 = val2.IsCompanionBoss(); AccessTools.Field(typeof(CharacterData), "isCompanionBoss").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("is_companion_boss")) ?? flag4); bool canAttack = val2.GetCanAttack(); AccessTools.Field(typeof(CharacterData), "canAttack").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("can_attack")) ?? canAttack); bool ascendsTrainAutomatically = val2.GetAscendsTrainAutomatically(); AccessTools.Field(typeof(CharacterData), "ascendsTrainAutomatically").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("ascends_train_automatically")) ?? ascendsTrainAutomatically); bool loopsBetweenTrainFloors = val2.GetLoopsBetweenTrainFloors(); AccessTools.Field(typeof(CharacterData), "loopsBetweenTrainFloors").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("loops_between_floors", "loops_between_train_floors")) ?? loopsBetweenTrainFloors); bool flag5 = val2.IsAttackTeleportsToDefender(); AccessTools.Field(typeof(CharacterData), "attackTeleportsToDefender").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("attack_teleports_to_defender")) ?? flag5); bool flag6 = val2.IsDeathSlidesBackwards(); AccessTools.Field(typeof(CharacterData), "deathSlidesBackwards").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("death_slides_backwards")) ?? flag6); bool flag7 = val2.IsChosenVariant(); AccessTools.Field(typeof(CharacterData), "chosenVariant").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("chosen_variant")) ?? flag7); bool flag8 = val2.IsLifemotherVariant(); AccessTools.Field(typeof(CharacterData), "lifemotherVariant").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("lifemother_variant")) ?? flag8); bool flag9 = val2.IsPyreHeart(); AccessTools.Field(typeof(CharacterData), "isPyreHeart").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("is_pyre", "is_pyre_heart")) ?? flag9); bool disableInDailyChallenges = val2.GetDisableInDailyChallenges(); AccessTools.Field(typeof(CharacterData), "disableInDailyChallenges").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("disable_in_daily_challenges")) ?? disableInDailyChallenges); bool preventAblitiesFromEquipment = val2.GetPreventAblitiesFromEquipment(); AccessTools.Field(typeof(CharacterData), "preventAbilitiesFromEquipment").SetValue(lookup2, ParseExtensions.ParseBool(configuration.GetSection("prevent_abilities_from_equipment")) ?? preventAblitiesFromEquipment); int size = val2.GetSize(); AccessTools.Field(typeof(CharacterData), "size").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("size")) ?? size); int num = ((!OverrideModeExtensions.IsNewContent(val)) ? val2.GetHealth() : 0); AccessTools.Field(typeof(CharacterData), "health").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("health")) ?? num); int num2 = ((!OverrideModeExtensions.IsNewContent(val)) ? val2.GetAttackDamage() : 0); AccessTools.Field(typeof(CharacterData), "attackDamage").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetSection("attack_damage")) ?? num2); int equipmentLimit = val2.GetEquipmentLimit(); AccessTools.Field(typeof(CharacterData), "equipmentLimit").SetValue(lookup2, ParseExtensions.ParseInt(configuration.GetDeprecatedSection("equip_limit", "equipment_limit")) ?? equipmentLimit); AttackPhase validBossAttackPhase = val2.GetValidBossAttackPhase(); AccessTools.Field(typeof(CharacterData), "validBossAttackPhase").SetValue(lookup2, configuration.GetDeprecatedSection("valid_attack_phase", "valid_boss_attack_phase").ParseAttackPhase() ?? validBossAttackPhase); Type deathType = val2.GetDeathType(); AccessTools.Field(typeof(CharacterData), "deathType").SetValue(lookup2, configuration.GetSection("death_type").ParseCharacterDeathType() ?? deathType); TitanAffinity val3 = (TitanAffinity)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)val2.GetBossTitanAffinity()) : 0); AccessTools.Field(typeof(CharacterData), "bossTitanAffinity").SetValue(lookup2, configuration.GetDeprecatedSection("titan_affinity", "boss_titan_affinity").ParseTitanAffinity() ?? val3); List list = val2.GetCharacterLoreTooltipKeys() ?? new List(); if ((Object)(object)val2 != (Object)(object)lookup2) { list = list.ToList(); } IConfigurationSection deprecatedSection = configuration.GetDeprecatedSection("character_lore_tooltips", "lore_tooltips"); if ((int)val == 1 && deprecatedSection.Exists()) { list.Clear(); } int num3 = list.Count; foreach (IConfigurationSection child in deprecatedSection.GetChildren()) { LocalizationTerm localizationTerm2 = child.ParseLocalizationTerm(); if (localizationTerm2 != null) { string text3 = $"CharacterData_tooltipKey{num3}-{id}"; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm2.Key)) { localizationTerm2.Key = text3; } list.Add(text3); if (localizationTerm2.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } num3++; } } AccessTools.Field(typeof(CharacterData), "characterLoreTooltipKeys").SetValue(lookup2, list); string artistAttribution = val2.GetArtistAttribution(); AccessTools.Field(typeof(CharacterData), "artistAttribution").SetValue(lookup2, ParseExtensions.ParseString(configuration.GetSection("artist")) ?? artistAttribution); EndlessBaselineStats endlessBaselineStats = val2.GetEndlessBaselineStats(); int? num4 = ParseExtensions.ParseInt(configuration.GetSection("endless_stats").GetSection("health")); if (num4.HasValue) { AccessTools.Field(typeof(EndlessBaselineStats), "endlessHealth").SetValue(endlessBaselineStats, num4); } int? num5 = ParseExtensions.ParseInt(configuration.GetSection("endless_stats").GetSection("attack")); if (num4.HasValue) { AccessTools.Field(typeof(EndlessBaselineStats), "endlessAttack").SetValue(endlessBaselineStats, num5); } AccessTools.Field(typeof(CharacterData), "endlessBaselineStats").SetValue(lookup2, endlessBaselineStats); bool flag10 = value != null || OverrideModeExtensions.IsNewContent(val); if (flag10) { ((IRegisterableDictionary)(object)service).Register(id, lookup2); } return new CharacterDataDefinition(key, lookup2, val2, configuration, val, flag10) { Id = text }; } } public class CharacterDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly Lazy SaveManager; private readonly IModLogger logger; public CharacterDataRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.logger = logger; } public void Register(string key, CharacterData item) { logger.Log((LogLevel)16, (object)("Register Character " + key + "...")); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "characterDatas").GetValue(allGameData)).Add(item); if (item.IsPyreHeart()) { allGameData.GetBalanceData().GetPyreHeartCharacterDatas().Add(item); } Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from character in SaveManager.Value.GetAllGameData().GetAllCharacterData() select ((GameData)character).GetID()).ToList(); } return new List(); } return (from character in SaveManager.Value.GetAllGameData().GetAllCharacterData() select character.GetAssetKey()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CharacterData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 lookup = null; IsModded = null; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (CharacterData allCharacterDatum in SaveManager.Value.GetAllGameData().GetAllCharacterData()) { if (((GameData)allCharacterDatum).GetID().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCharacterDatum; IsModded = ContainsKey(((Object)allCharacterDatum).name); return true; } } return false; } return false; } foreach (CharacterData allCharacterDatum2 in SaveManager.Value.GetAllGameData().GetAllCharacterData()) { if (allCharacterDatum2.GetAssetKey().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCharacterDatum2; IsModded = ContainsKey(((Object)allCharacterDatum2).name); return true; } } return false; } } } namespace TrainworksReloaded.Base.Challenges { public class ChallengeDataDefinition : IDefinition { public string Key { get; set; } public SpChallengeData Data { get; set; } public IConfiguration Configuration { get; set; } public string Id { get; set; } public bool IsModded { get; set; } public ChallengeDataDefinition(string key, SpChallengeData data, IConfiguration configuration, bool isOverride) { Key = key; Data = data; Configuration = configuration; Id = ""; IsModded = !isOverride; base..ctor(); } } public class ChallengeDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister spriteRegister; private readonly IRegister classRegister; private readonly IRegister relicRegister; private readonly IRegister characterRegister; private readonly FieldInfo MutatorsField = AccessTools.Field(typeof(SpChallengeData), "mutators"); public ChallengeDataFinalizer(IModLogger logger, ICache> cache, IRegister spriteRegister, IRegister classDataRegister, IRegister relicDataRegister, IRegister characterDataRegister) { this.logger = logger; this.cache = cache; this.spriteRegister = spriteRegister; classRegister = classDataRegister; relicRegister = relicDataRegister; characterRegister = characterDataRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeChallengeData(cacheItem); } cache.Clear(); } private void FinalizeChallengeData(IDefinition definition) { //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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Invalid comparison between Unknown and I4 //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Invalid comparison between Unknown and I4 //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Invalid comparison between Unknown and I4 //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Invalid comparison between Unknown and I4 //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; SpChallengeData data = definition.Data; string key = definition.Key; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); logger.Log((LogLevel)16, (object)("Finalizing Challenge " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); IConfigurationSection section = configuration.GetSection("main_clan"); ParseReferenceExtensions.ReferencedObject referencedObject = section.ParseReference(); bool? IsModded; if (referencedObject != null) { classRegister.TryLookupName(referencedObject.ToId(key, "Class"), out ClassData lookup, out IsModded, referencedObject.context); AccessTools.Field(typeof(SpChallengeData), "mainClan").SetValue(data, lookup); } else if ((int)val == 1 && referencedObject == null && section.Exists()) { AccessTools.Field(typeof(SpChallengeData), "mainClan").SetValue(data, null); } IConfigurationSection section2 = configuration.GetSection("allied_clan"); ParseReferenceExtensions.ReferencedObject referencedObject2 = section2.ParseReference(); if (referencedObject2 != null) { classRegister.TryLookupName(referencedObject2.ToId(key, "Class"), out ClassData lookup2, out IsModded, referencedObject2.context); AccessTools.Field(typeof(SpChallengeData), "alliedClan").SetValue(data, lookup2); } else if ((int)val == 1 && referencedObject2 == null && section2.Exists()) { AccessTools.Field(typeof(SpChallengeData), "alliedClan").SetValue(data, null); } IConfigurationSection section3 = configuration.GetSection("icon"); ParseReferenceExtensions.ReferencedObject referencedObject3 = section3.ParseReference(); if (referencedObject3 != null) { spriteRegister.TryLookupName(referencedObject3.ToId(key, "Sprite"), out Sprite lookup3, out IsModded, referencedObject3.context); AccessTools.Field(typeof(SpChallengeData), "icon").SetValue(data, lookup3); } else if ((int)val == 1 && referencedObject3 == null && section3.Exists()) { AccessTools.Field(typeof(SpChallengeData), "icon").SetValue(data, null); } IConfigurationSection section4 = configuration.GetSection("pyre_heart"); ParseReferenceExtensions.ReferencedObject referencedObject4 = section4.ParseReference(); if (referencedObject4 != null) { characterRegister.TryLookupName(referencedObject4.ToId(key, "Character"), out CharacterData lookup4, out IsModded, referencedObject4.context); AccessTools.Field(typeof(SpChallengeData), "pyreHeartCharacterData").SetValue(data, lookup4); } else if ((int)val == 1 && referencedObject4 == null && section4.Exists()) { AccessTools.Field(typeof(SpChallengeData), "pyreHeartCharacterData").SetValue(data, null); } List list = (MutatorsField.GetValue(data) as List) ?? new List(); IConfigurationSection section5 = configuration.GetSection("mutators"); if ((int)val == 1 && section5.Exists()) { list.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section5.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item.ToId(key, "RelicData"); if (relicRegister.TryLookupName(name, out RelicData lookup5, out IsModded, item.context)) { MutatorData val2 = (MutatorData)(object)((lookup5 is MutatorData) ? lookup5 : null); if (val2 == null) { logger.Log((LogLevel)4, (object)("Attempt to add non-Mutator RelicData " + ((Object)lookup5).name + " to Challenge " + definition.Id + ". Ignoring...")); } else { list.Add(val2); } } } MutatorsField.SetValue(data, list); } } public class ChallengeDataPipeline : IDataPipeline, SpChallengeData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; public ChallengeDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, CardPoolRegister cardPoolRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadItems(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadItems(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("challenges").GetChildren()) { ChallengeDataDefinition challengeDataDefinition = LoadConfiguration(service, key, child); if (challengeDataDefinition != null) { list.Add(challengeDataDefinition); } } return list; } private ChallengeDataDefinition? LoadConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Challenge", text); string text2 = "SpChallengeData_nameKey-" + id; string text3 = "SpChallengeData_descriptionKey-" + id; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value; if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out SpChallengeData lookup, out bool? _)) { logger.Log((LogLevel)16, (object)("Overriding Challenge " + text + "...")); text2 = lookup.GetNameKey(); text3 = lookup.GetDescriptionKey(); value = ((GameData)lookup).GetID(); } else { lookup = ScriptableObject.CreateInstance(); ((Object)lookup).name = id; value = guidProvider.GetGuidDeterministic(id).ToString(); } AccessTools.Field(typeof(SpChallengeData), "id").SetValue(lookup, value); LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(SpChallengeData), "nameKey").SetValue(lookup, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(SpChallengeData), "descriptionKey").SetValue(lookup, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } int mainChampionIndex = lookup.GetMainChampionIndex(); AccessTools.Field(typeof(SpChallengeData), "mainChampionIndex").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("main_champion_index")) ?? mainChampionIndex); int alliedChampionIndex = lookup.GetAlliedChampionIndex(); AccessTools.Field(typeof(SpChallengeData), "alliedChampionIndex").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("allied_champion_index")) ?? alliedChampionIndex); int covenantLevel = lookup.GetCovenantLevel(); AccessTools.Field(typeof(SpChallengeData), "covenantLevel").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("covenant_level")) ?? covenantLevel); bool flag = OverrideModeExtensions.IsNewContent(val); if (flag) { ((IRegisterableDictionary)(object)service).Register(id, lookup); } return new ChallengeDataDefinition(key, lookup, configuration, !flag) { Id = text }; } } public class ChallengeDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly Lazy SaveManager; private readonly IModLogger logger; public ChallengeDataRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); this.logger = logger; } public void Register(string key, SpChallengeData item) { logger.Log((LogLevel)16, (object)("Register Challenge " + key + "...")); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "spChallengeDatas").GetValue(allGameData)).Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from spChallengeData in SaveManager.Value.GetAllGameData().GetAllSpChallengeDatas() select ((GameData)spChallengeData).GetID()).ToList(); } return new List(); } return (from spChallengeData in SaveManager.Value.GetAllGameData().GetAllSpChallengeDatas() select ((Object)spChallengeData).name).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out SpChallengeData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 lookup = null; IsModded = null; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (SpChallengeData allSpChallengeData in SaveManager.Value.GetAllGameData().GetAllSpChallengeDatas()) { if (((GameData)allSpChallengeData).GetID().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allSpChallengeData; IsModded = ContainsKey(((Object)allSpChallengeData).name); return true; } } return false; } return false; } foreach (SpChallengeData allSpChallengeData2 in SaveManager.Value.GetAllGameData().GetAllSpChallengeDatas()) { if (((Object)allSpChallengeData2).name.Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allSpChallengeData2; IsModded = ContainsKey(((Object)allSpChallengeData2).name); return true; } } return false; } } } namespace TrainworksReloaded.Base.CardUpgrade { public class CardUpgradeDefinition : IDefinition { public string Key { get; set; } public CardUpgradeData Data { get; set; } public IConfiguration Configuration { get; set; } public string Id { get; set; } public bool IsModded { get; set; } public CardUpgradeDefinition(string key, CardUpgradeData data, IConfiguration configuration, bool isOverride) { Key = key; Data = data; Configuration = configuration; Id = ""; IsModded = !isOverride; base..ctor(); } } public class CardUpgradeFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister cardRegister; private readonly IRegister triggerRegister; private readonly IRegister roomModifierRegister; private readonly IRegister traitRegister; private readonly IRegister cardTriggerRegister; private readonly IRegister upgradeRegister; private readonly IRegister vfxRegister; private readonly IRegister statusRegister; private readonly IRegister spriteRegister; private readonly IRegister upgradeMaskRegister; public CardUpgradeFinalizer(IModLogger logger, ICache> cache, IRegister cardRegister, IRegister triggerRegister, IRegister roomModifierRegister, IRegister traitRegister, IRegister cardTriggerRegister, IRegister upgradeRegister, IRegister vfxRegister, IRegister statusRegister, IRegister spriteRegister, IRegister upgradeMaskRegister) { this.logger = logger; this.cache = cache; this.cardRegister = cardRegister; this.triggerRegister = triggerRegister; this.roomModifierRegister = roomModifierRegister; this.traitRegister = traitRegister; this.cardTriggerRegister = cardTriggerRegister; this.upgradeRegister = upgradeRegister; this.vfxRegister = vfxRegister; this.statusRegister = statusRegister; this.spriteRegister = spriteRegister; this.upgradeMaskRegister = upgradeMaskRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardUpgradeData(cacheItem); } cache.Clear(); } private void FinalizeCardUpgradeData(IDefinition definition) { //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_0038: 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) //IL_00b6: Invalid comparison between Unknown and I4 //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Invalid comparison between Unknown and I4 //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Invalid comparison between Unknown and I4 //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Invalid comparison between Unknown and I4 //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Invalid comparison between Unknown and I4 //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Invalid comparison between Unknown and I4 //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Expected O, but got Unknown //IL_07f7: Unknown result type (might be due to invalid IL or missing references) //IL_07f9: Invalid comparison between Unknown and I4 //IL_0988: Unknown result type (might be due to invalid IL or missing references) //IL_098a: Invalid comparison between Unknown and I4 //IL_0a66: Unknown result type (might be due to invalid IL or missing references) //IL_0a68: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; CardUpgradeData data = definition.Data; string key = definition.Key; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); bool flag = configuration.GetSection("clone_id").Value != null || OverrideModeExtensions.IsNewContent(val); logger.Log((LogLevel)16, (object)("Finalizing Upgrade " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = data.GetTraitDataUpgrades() ?? new List(); IConfigurationSection section = configuration.GetSection("trait_upgrades"); if ((int)val == 1 && section.Exists()) { list.Clear(); } bool? IsModded; foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item.ToId(key, "Trait"); if (traitRegister.TryLookupId(id, out CardTraitData lookup, out IsModded, item.context)) { list.Add(lookup); } } AccessTools.Field(typeof(CardUpgradeData), "traitDataUpgrades").SetValue(data, list); List characterTriggerUpgrades = data.GetCharacterTriggerUpgrades(); IConfigurationSection section2 = configuration.GetSection("trigger_upgrades"); if ((int)val == 1 && section2.Exists()) { characterTriggerUpgrades.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in section2.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id2 = item2.ToId(key, "CTrigger"); if (triggerRegister.TryLookupId(id2, out CharacterTriggerData lookup2, out IsModded, item2.context)) { characterTriggerUpgrades.Add(lookup2); } } AccessTools.Field(typeof(CardUpgradeData), "triggerUpgrades").SetValue(data, characterTriggerUpgrades); List cardTriggerUpgrades = data.GetCardTriggerUpgrades(); IConfigurationSection section3 = configuration.GetSection("card_trigger_upgrades"); if ((int)val == 1 && section3.Exists()) { cardTriggerUpgrades.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in section3.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id3 = item3.ToId(key, "Trigger"); if (cardTriggerRegister.TryLookupId(id3, out CardTriggerEffectData lookup3, out IsModded, item3.context)) { cardTriggerUpgrades.Add(lookup3); } } AccessTools.Field(typeof(CardUpgradeData), "cardTriggerUpgrades").SetValue(data, cardTriggerUpgrades); List roomModifierUpgrades = data.GetRoomModifierUpgrades(); IConfigurationSection section4 = configuration.GetSection("room_modifier_upgrades"); if ((int)val == 1 && section4.Exists()) { roomModifierUpgrades.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in section4.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id4 = item4.ToId(key, "RoomModifier"); if (roomModifierRegister.TryLookupId(id4, out RoomModifierData lookup4, out IsModded, item4.context)) { roomModifierUpgrades.Add(lookup4); } } AccessTools.Field(typeof(CardUpgradeData), "roomModifierUpgrades").SetValue(data, roomModifierUpgrades); List list2 = data.GetStatusEffectUpgrades() ?? new List(); IConfigurationSection section5 = configuration.GetSection("status_effect_upgrades"); if ((int)val == 1 && section5.Exists()) { list2.Clear(); } foreach (IConfigurationSection child in section5.GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject = child.GetSection("status").ParseReference(); if (referencedObject != null) { string id5 = referencedObject.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id5, out StatusEffectData lookup5, out IsModded, referencedObject.context)) { StatusEffectStackData val2 = new StatusEffectStackData { statusId = lookup5.GetStatusId(), count = ParseExtensions.ParseInt(child.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); val2.fromPermanentUpgrade = IsModded == true; list2.Add(val2); } } } AccessTools.Field(typeof(CardUpgradeData), "statusEffectUpgrades").SetValue(data, list2); List upgradesToRemove = data.GetUpgradesToRemove(); IConfigurationSection section6 = configuration.GetSection("remove_upgrades"); if ((int)val == 1 && section6.Exists()) { upgradesToRemove.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in section6.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item5.ToId(key, "Upgrade"); if (upgradeRegister.TryLookupName(name, out CardUpgradeData lookup6, out IsModded, item5.context)) { upgradesToRemove.Add(lookup6); } } AccessTools.Field(typeof(CardUpgradeData), "upgradesToRemove").SetValue(data, upgradesToRemove); ParseReferenceExtensions.ReferencedObject referencedObject2 = configuration.GetSection("applied_vfx").ParseReference(); if (flag || referencedObject2 != null) { string id6 = referencedObject2?.ToId(key, "Vfx") ?? ""; vfxRegister.TryLookupId(id6, out VfxAtLoc lookup7, out IsModded, referencedObject2?.context); AccessTools.Field(typeof(CardUpgradeData), "appliedVFX").SetValue(data, lookup7); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetSection("removed_vfx").ParseReference(); if (flag || referencedObject3 != null) { string id7 = referencedObject3?.ToId(key, "Vfx") ?? ""; vfxRegister.TryLookupId(id7, out VfxAtLoc lookup8, out IsModded, referencedObject3?.context); AccessTools.Field(typeof(CardUpgradeData), "removedVFX").SetValue(data, lookup8); } ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetSection("persistent_vfx").ParseReference(); if (flag || referencedObject4 != null) { string id8 = referencedObject4?.ToId(key, "Vfx") ?? ""; vfxRegister.TryLookupId(id8, out VfxAtLoc lookup9, out IsModded, referencedObject4?.context); AccessTools.Field(typeof(CardUpgradeData), "persistentVFX").SetValue(data, lookup9); } List filters = data.GetFilters(); IConfigurationSection section7 = configuration.GetSection("filters"); if ((int)val == 1 && section7.Exists()) { filters.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item6 in (from x in section7.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id9 = item6.ToId(key, "UpgradeMask"); if (upgradeMaskRegister.TryLookupId(id9, out CardUpgradeMaskData lookup10, out IsModded, item6.context)) { filters.Add(lookup10); } } AccessTools.Field(typeof(CardUpgradeData), "filters").SetValue(data, filters); IConfigurationSection section8 = configuration.GetSection("ability_upgrade"); ParseReferenceExtensions.ReferencedObject referencedObject5 = section8.ParseReference(); if (referencedObject5 != null) { cardRegister.TryLookupName(referencedObject5.ToId(key, "Card"), out CardData lookup11, out IsModded, referencedObject5.context); if ((Object)(object)lookup11 != (Object)null && !lookup11.IsUnitAbility()) { logger.Log((LogLevel)4, (object)("Attempting to add " + ((Object)lookup11).name + " as a unit ability upgrade for " + ((Object)data).name + ", but is not a unit ability card.")); } AccessTools.Field(typeof(CardUpgradeData), "unitAbilityUpgrade").SetValue(data, lookup11); } if ((int)val == 1 && referencedObject5 == null && section8.Exists()) { AccessTools.Field(typeof(CardUpgradeData), "unitAbilityUpgrade").SetValue(data, null); } IConfigurationSection section9 = configuration.GetSection("room_ability_upgrade"); ParseReferenceExtensions.ReferencedObject referencedObject6 = section9.ParseReference(); if (referencedObject6 != null) { cardRegister.TryLookupName(referencedObject6.ToId(key, "Card"), out CardData lookup12, out IsModded, referencedObject6.context); if ((Object)(object)lookup12 != (Object)null && !lookup12.IsRoomAbility()) { logger.Log((LogLevel)4, (object)("Attempting to add " + ((Object)lookup12).name + " as a room ability upgrade for " + ((Object)data).name + ", but is not a room ability card.")); } AccessTools.Field(typeof(CardUpgradeData), "roomAbilityUpgrade").SetValue(data, lookup12); } if ((int)val == 1 && referencedObject6 == null && section9.Exists()) { AccessTools.Field(typeof(CardUpgradeData), "roomAbilityUpgrade").SetValue(data, null); } ParseReferenceExtensions.ReferencedObject referencedObject7 = configuration.GetSection("icon").ParseReference(); if (referencedObject7 != null) { spriteRegister.TryLookupId(referencedObject7.ToId(key, "Sprite"), out Sprite lookup13, out IsModded, referencedObject7.context); AccessTools.Field(typeof(CardUpgradeData), "upgradeIcon").SetValue(data, lookup13); } } } public class CardUpgradeMaskDefinition(string key, CardUpgradeMaskData data, IConfiguration configuration) : IDefinition { public string Key { get; set; } = key; public CardUpgradeMaskData Data { get; set; } = data; public IConfiguration Configuration { get; set; } = configuration; public string Id { get; set; } = ""; public bool IsModded => true; } public class CardUpgradeMaskFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister upgradeRegister; private readonly IRegister statusRegister; private readonly IRegister classRegister; private readonly IRegister poolRegister; private readonly IRegister subtypeRegister; public CardUpgradeMaskFinalizer(IModLogger logger, ICache> cache, IRegister upgradeRegister, IRegister statusRegister, IRegister classRegister, IRegister poolRegister, IRegister subtypeRegister) { this.logger = logger; this.cache = cache; this.upgradeRegister = upgradeRegister; this.statusRegister = statusRegister; this.classRegister = classRegister; this.poolRegister = poolRegister; this.subtypeRegister = subtypeRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardUpgradeMask(cacheItem); } cache.Clear(); } private void FinalizeCardUpgradeMask(IDefinition definition) { //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0387: 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_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown IConfiguration configuration = definition.Configuration; CardUpgradeMaskData data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Upgrade Mask " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); bool? IsModded; foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("required_class").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (classRegister.TryLookupName(item.ToId(key, "Class"), out ClassData lookup, out IsModded, item.context)) { list.Add(lookup); } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredLinkedClans").SetValue(data, list); List list2 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in configuration.GetSection("excluded_class").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (classRegister.TryLookupName(item2.ToId(key, "Class"), out ClassData lookup2, out IsModded, item2.context)) { list2.Add(lookup2); } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedLinkedClans").SetValue(data, list2); List list3 = new List(); foreach (IConfigurationSection child in configuration.GetSection("required_status").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject = child.GetSection("status").ParseReference(); if (referencedObject != null) { string id = referencedObject.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id, out StatusEffectData lookup3, out IsModded, referencedObject.context)) { StatusEffectStackData val = new StatusEffectStackData { statusId = lookup3.GetStatusId(), count = ParseExtensions.ParseInt(child.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child.GetSection("from_permanent_upgrade")); val.fromPermanentUpgrade = IsModded == true; list3.Add(val); } } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredStatusEffects").SetValue(data, list3); List list4 = new List(); foreach (IConfigurationSection child2 in configuration.GetSection("excluded_status").GetChildren()) { ParseReferenceExtensions.ReferencedObject referencedObject2 = child2.GetSection("status").ParseReference(); if (referencedObject2 != null) { string id2 = referencedObject2.ToId(key, "StatusEffect"); if (statusRegister.TryLookupId(id2, out StatusEffectData lookup4, out IsModded, referencedObject2.context)) { StatusEffectStackData val2 = new StatusEffectStackData { statusId = lookup4.GetStatusId(), count = ParseExtensions.ParseInt(child2.GetSection("count")).GetValueOrDefault() }; IsModded = ParseExtensions.ParseBool(child2.GetSection("from_permanent_upgrade")); val2.fromPermanentUpgrade = IsModded == true; list4.Add(val2); } } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedStatusEffects").SetValue(data, list4); List list5 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item3 in (from x in configuration.GetSection("allowed_pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (poolRegister.TryLookupId(item3.ToId(key, "CardPool"), out CardPool lookup5, out IsModded, item3.context)) { list5.Add(lookup5); } } AccessTools.Field(typeof(CardUpgradeMaskData), "allowedCardPools").SetValue(data, list5); List list6 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in configuration.GetSection("disallowed_pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (poolRegister.TryLookupId(item4.ToId(key, "CardPool"), out CardPool lookup6, out IsModded, item4.context)) { list6.Add(lookup6); } } AccessTools.Field(typeof(CardUpgradeMaskData), "disallowedCardPools").SetValue(data, list6); List list7 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in configuration.GetDeprecatedSection("required_upgrade", "required_upgrades").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (upgradeRegister.TryLookupName(item5.ToId(key, "Upgrade"), out CardUpgradeData lookup7, out IsModded, item5.context)) { list7.Add(lookup7); } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardUpgrades").SetValue(data, list7); List list8 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item6 in (from x in configuration.GetDeprecatedSection("excluded_upgrade", "excluded_upgrades").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (upgradeRegister.TryLookupName(item6.ToId(key, "Upgrade"), out CardUpgradeData lookup8, out IsModded, item6.context)) { list8.Add(lookup8); } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardUpgrades").SetValue(data, list8); List list9 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item7 in (from x in configuration.GetSection("required_subtypes").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (subtypeRegister.TryLookupId(item7.ToId(key, "Subtype"), out SubtypeData lookup9, out IsModded, item7.context)) { list9.Add(lookup9.Key); } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredSubtypes").SetValue(data, list9); List list10 = new List(); foreach (ParseReferenceExtensions.ReferencedObject item8 in (from x in configuration.GetSection("excluded_subtypes").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (subtypeRegister.TryLookupId(item8.ToId(key, "Subtype"), out SubtypeData lookup10, out IsModded, item8.context)) { list10.Add(lookup10.Key); } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedSubtypes").SetValue(data, list10); } } public class CardUpgradeMaskPipeline : IDataPipeline, CardUpgradeMaskData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; public CardUpgradeMaskPipeline(PluginAtlas atlas, IModLogger logger) { this.atlas = atlas; this.logger = logger; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadMasks(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadMasks(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("upgrade_masks").GetChildren()) { CardUpgradeMaskDefinition cardUpgradeMaskDefinition = LoadMaskConfiguration(service, key, child); if (cardUpgradeMaskDefinition != null) { list.Add(cardUpgradeMaskDefinition); } } return list; } private CardUpgradeMaskDefinition? LoadMaskConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_07f8: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("UpgradeMask", text); CardUpgradeMaskData val = ScriptableObject.CreateInstance(); ((Object)val).name = id; AccessTools.Field(typeof(CardUpgradeMaskData), "requiredRaritiesOperator").SetValue(val, configuration.GetSection("required_rarities_operator").ParseCompareOperator("or")); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedRaritiesOperator").SetValue(val, configuration.GetSection("excluded_rarities_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredSubtypesOperator").SetValue(val, configuration.GetSection("required_subtypes_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedSubtypesOperator").SetValue(val, configuration.GetSection("excluded_subtypes_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredStatusEffectsOperator").SetValue(val, configuration.GetSection("required_status_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedStatusEffectsOperator").SetValue(val, configuration.GetSection("excluded_status_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardTraitsOperator").SetValue(val, configuration.GetSection("required_traits_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardTraitsOperator").SetValue(val, configuration.GetSection("excluded_traits_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardEffectsOperator").SetValue(val, configuration.GetSection("required_effects_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardEffectsOperator").SetValue(val, configuration.GetSection("excluded_effects_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredLinkedClansOperator").SetValue(val, configuration.GetSection("required_class_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedLinkedClansOperator").SetValue(val, configuration.GetSection("excluded_class_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardUpgradesOperator").SetValue(val, configuration.GetDeprecatedSection("required_upgrade_operator", "required_upgrades_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardUpgradesOperator").SetValue(val, configuration.GetDeprecatedSection("excluded_upgrade_operator", "excluded_upgrades_operator").ParseCompareOperator()); AccessTools.Field(typeof(CardUpgradeMaskData), "requireXCost").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("require_x_cost")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeXCost").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_x_cost")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeNonAttackingMonsters").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_non_attacking")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeIfHasUnitAbility").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_if_has_ability")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeIfHasGraftedEquipment").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_if_grafted")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeIfHasAnyUpgrades").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_if_upgraded")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "excludeIfHasNoUpgrades").SetValue(val, ParseExtensions.ParseBool(configuration.GetSection("exclude_if_not_upgraded")) == true); AccessTools.Field(typeof(CardUpgradeMaskData), "cardType").SetValue(val, (object)(CardType)(((??)configuration.GetSection("card_type").ParseCardType()) ?? 4)); List value = (from xs in configuration.GetSection("additional_card_types").GetChildren() select xs.ParseCardType() into xs where xs.HasValue select xs).Cast().ToList(); AccessTools.Field(typeof(CardUpgradeMaskData), "additionalCardTypes").SetValue(val, value); CardTargetMode valueOrDefault = configuration.GetSection("card_target_mode").ParseCardTargetMode().GetValueOrDefault(); AccessTools.Field(typeof(CardUpgradeMaskData), "cardTargetMode").SetValue(val, valueOrDefault); List value2 = (from xs in configuration.GetSection("required_rarities").GetChildren() select xs.ParseRarity() into xs where xs.HasValue select xs).Cast().ToList(); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredRarities").SetValue(val, value2); List value3 = (from xs in configuration.GetSection("excluded_rarities").GetChildren() select xs.ParseRarity() into xs where xs.HasValue select xs).Cast().ToList(); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedRarities").SetValue(val, value3); List value4 = (from xs in configuration.GetSection("required_sizes").GetChildren() select ParseExtensions.ParseInt(xs) into xs where xs.HasValue select xs).Cast().ToList(); AccessTools.Field(typeof(CardUpgradeMaskData), "requiredSizes").SetValue(val, value4); List value5 = (from xs in configuration.GetSection("excluded_sizes").GetChildren() select ParseExtensions.ParseInt(xs) into xs where xs.HasValue select xs).Cast().ToList(); AccessTools.Field(typeof(CardUpgradeMaskData), "excludedSizes").SetValue(val, value5); IConfigurationSection section = configuration.GetSection("cost_range"); if (section != null) { int? num = ParseExtensions.ParseInt(section.GetSection("x")); int? num2 = ParseExtensions.ParseInt(section.GetSection("y")); if (num.HasValue && num2.HasValue) { Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)num.Value, (float)num2.Value); AccessTools.Field(typeof(CardUpgradeMaskData), "costRange").SetValue(val, val2); } } UpgradeDisabledReason valueOrDefault2 = configuration.GetSection("disabled_reason").ParseUpgradeDisabledReason().GetValueOrDefault(); AccessTools.Field(typeof(CardUpgradeMaskData), "upgradeDisabledReason").SetValue(val, valueOrDefault2); List list = new List(); foreach (IConfigurationSection child in configuration.GetSection("required_effects").GetChildren()) { string text2 = ParseEffectType(child, key, atlas, text); if (text2 != null) { list.Add(text2); } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardEffects").SetValue(val, list); List list2 = new List(); foreach (IConfigurationSection child2 in configuration.GetSection("excluded_effects").GetChildren()) { string text3 = ParseEffectType(child2, key, atlas, text); if (text3 != null) { list2.Add(text3); } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardEffects").SetValue(val, list2); List list3 = new List(); foreach (IConfigurationSection child3 in configuration.GetSection("required_traits").GetChildren()) { string text4 = ParseEffectType(child3, key, atlas, text); if (text4 != null) { list3.Add(text4); } } AccessTools.Field(typeof(CardUpgradeMaskData), "requiredCardTraits").SetValue(val, list3); List list4 = new List(); foreach (IConfigurationSection child4 in configuration.GetSection("excluded_traits").GetChildren()) { string text5 = ParseEffectType(child4, key, atlas, text); if (text5 != null) { list4.Add(text5); } } AccessTools.Field(typeof(CardUpgradeMaskData), "excludedCardTraits").SetValue(val, list4); ((IRegisterableDictionary)(object)service).Register(id, val); return new CardUpgradeMaskDefinition(key, val, configuration) { Id = text }; } private string? ParseEffectType(IConfigurationSection configuration, string key, PluginAtlas atlas, string id) { ParseReferenceExtensions.ReferencedObject referencedObject = configuration.ParseReference(); if (referencedObject == null) { return null; } string id2 = referencedObject.id; string text = referencedObject.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { return fullyQualifiedName; } logger.Log((LogLevel)4, (object)("Failed to load class name " + id2 + " in upgrade_mask " + id + " with mod reference " + text + ", Note that this isn't a reference, but a class that inherits from " + typeof(T).Name + ".")); return null; } } public class CardUpgradeMaskRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaFilters = new Dictionary(); public CardUpgradeMaskRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaFilters, Resources.FindObjectsOfTypeAll().ToDictionary((CardUpgradeMaskData x) => ((Object)x).name, (CardUpgradeMaskData x) => x)); Extensions.AddRange((Dictionary)this, VanillaFilters); } public void Register(string key, CardUpgradeMaskData item) { logger.Log((LogLevel)32, (object)("Registering Upgrade Mask " + key + "...")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardUpgradeMaskData? lookup, [NotNullWhen(true)] out bool? IsModded) { IsModded = !VanillaFilters.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } } public class CardUpgradePipeline : IDataPipeline, CardUpgradeData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; public CardUpgradePipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, IGuidProvider guidProvider) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadUpgrades(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } private List LoadUpgrades(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("upgrades").GetChildren()) { CardUpgradeDefinition cardUpgradeDefinition = LoadUpgradeConfiguration(service, key, child); if (cardUpgradeDefinition != null) { list.Add(cardUpgradeDefinition); } } return list; } private CardUpgradeDefinition? LoadUpgradeConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_089f: Unknown result type (might be due to invalid IL or missing references) //IL_08a2: Invalid comparison between Unknown and I4 //IL_09e4: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Upgrade", text); string text2 = "CardUpgrade_titleKey-" + id; string text3 = "CardUpgrade_descriptionKey-" + id; string text4 = "CardUpgrade_notificationKey-" + id; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value; if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out CardUpgradeData lookup, out bool? _)) { logger.Log((LogLevel)16, (object)("Overriding Upgrade " + text + "...")); text2 = lookup.GetUpgradeTitleKey(); text3 = lookup.GetUpgradeDescriptionKey(); text4 = lookup.GetUpgradeNotificationKey(); value = ((GameData)lookup).GetID(); } else { lookup = ScriptableObject.CreateInstance(); ((Object)lookup).name = id; value = guidProvider.GetGuidDeterministic(id).ToString(); } AccessTools.Field(typeof(CardUpgradeData), "id").SetValue(lookup, value); LocalizationTerm localizationTerm = configuration.GetSection("titles").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(CardUpgradeData), "upgradeTitleKey").SetValue(lookup, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(CardUpgradeData), "upgradeDescriptionKey").SetValue(lookup, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } LocalizationTerm localizationTerm3 = configuration.GetSection("notifications").ParseLocalizationTerm(); if (localizationTerm3 != null) { AccessTools.Field(typeof(CardUpgradeData), "upgradeNotificationKey").SetValue(lookup, text4); localizationTerm3.Key = text4; ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm3); } bool flag = (bool)AccessTools.Field(typeof(CardUpgradeData), "allowSecondaryTooltipPlacement").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "allowSecondaryTooltipPlacement").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("allow_secondary_tooltip_placement")) ?? flag); bool flag2 = (bool)AccessTools.Field(typeof(CardUpgradeData), "hideUpgradeIconOnCard").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "hideUpgradeIconOnCard").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("hide_icon_on_card")) ?? flag2); bool flag3 = (bool)AccessTools.Field(typeof(CardUpgradeData), "useUpgradeHighlightTextTags").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "useUpgradeHighlightTextTags").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("use_upgrade_highlight_tags")) ?? flag3); bool flag4 = (bool)AccessTools.Field(typeof(CardUpgradeData), "showUpgradeDescriptionOnCards").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "showUpgradeDescriptionOnCards").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("show_description_on_cards")) ?? flag4); bool flag5 = (bool)AccessTools.Field(typeof(CardUpgradeData), "isUnique").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "isUnique").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_unique")) ?? flag5); bool flag6 = (bool)AccessTools.Field(typeof(CardUpgradeData), "restrictSizeToRoomCapacity").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "restrictSizeToRoomCapacity").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("restrict_to_room_capacity", "restrict_size_to_room_capacity")) ?? flag6); bool flag7 = (bool)AccessTools.Field(typeof(CardUpgradeData), "doNotReplaceExistingUnitAbility").GetValue(lookup); AccessTools.Field(typeof(CardUpgradeData), "doNotReplaceExistingUnitAbility").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("does_not_replace_ability")) ?? flag7); AccessTools.Field(typeof(CardUpgradeData), "bonusDamage").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_damage")) ?? lookup.GetBonusDamage()); AccessTools.Field(typeof(CardUpgradeData), "bonusHP").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_hp")) ?? lookup.GetBonusHP()); AccessTools.Field(typeof(CardUpgradeData), "unhealedBonusHP").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_unhealed_hp")) ?? lookup.GetUnhealedBonusHP()); AccessTools.Field(typeof(CardUpgradeData), "costReduction").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("cost_reduction")) ?? lookup.GetCostReduction()); AccessTools.Field(typeof(CardUpgradeData), "xCostReduction").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("x_cost_reduction")) ?? lookup.GetXCostReduction()); AccessTools.Field(typeof(CardUpgradeData), "bonusHeal").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_heal")) ?? lookup.GetBonusHeal()); AccessTools.Field(typeof(CardUpgradeData), "bonusSize").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_size")) ?? lookup.GetBonusSize()); AccessTools.Field(typeof(CardUpgradeData), "bonusEquipment").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_equipment")) ?? lookup.GetBonusEquipment()); AccessTools.Field(typeof(CardUpgradeData), "bonusUpgradeSlotCount").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("bonus_upgrade_slot_count")) ?? lookup.GetBonusUpgradeSlotCount()); AccessTools.Field(typeof(CardUpgradeData), "excludeFromClones").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("exclude_from_clones")) ?? lookup.GetExcludeFromClones()); AccessTools.Field(typeof(CardUpgradeData), "magicPowerTraitScalingOnly").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("magic_power_trait_scaling_only")) ?? lookup.GetMagicPowerTraitScalingOnly()); AccessTools.Field(typeof(CardUpgradeData), "upgradeWillBeScaledByNonMagicPowerTrait").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("upgrade_will_be_scaled_by_non_magic_power_trait")) ?? lookup.GetUpgradeWillBeScaledByNonMagicPowerTrait()); AccessTools.Field(typeof(CardUpgradeData), "isRegionRunUpgrade").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_region_run_upgrade")) ?? lookup.GetIsRegionRunUpgrade()); AccessTools.Field(typeof(CardUpgradeData), "skipDefaultStatusEffectNotif").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("skip_default_status_effect_notification")) ?? lookup.GetSkipDefaultStatusEffectNotif()); List list = lookup.GetRemoveTraitUpgrades() ?? new List(); IConfigurationSection section = configuration.GetSection("remove_trait_upgrades"); if ((int)val == 1 && section.Exists()) { list.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id2 = item.id; string text5 = item.mod_reference ?? key; PluginDefinition valueOrDefault = IEnumerableUtility.GetValueOrDefault((IDictionary)atlas.PluginDefinitions, text5, (PluginDefinition)null); Assembly assembly = ((valueOrDefault != null) ? valueOrDefault.Assembly : null); if (!id2.GetFullyQualifiedName(assembly, out string fullyQualifiedName)) { logger.Log((LogLevel)4, (object)("Failed to load trait state name " + id2 + " in upgrade " + text + " with mod reference " + text5 + ", Note that this isn't a reference to a CardTraitData, but a class that inherits from CardTraitState.")); } else { list.Add(fullyQualifiedName); } } AccessTools.Field(typeof(CardUpgradeData), "removeTraitUpgrades").SetValue(lookup, list); bool flag8 = OverrideModeExtensions.IsNewContent(val); if (flag8) { ((IRegisterableDictionary)(object)service).Register(id, lookup); } return new CardUpgradeDefinition(key, lookup, configuration, flag8); } } public class CardUpgradeRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly Lazy SaveManager; private readonly IModLogger logger; public CardUpgradeRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (!client.TryGetValue(typeof(SaveManager), out ProviderDetails value)) ? new SaveManager() : ((SaveManager)value.Provider))); this.logger = logger; } public void Register(string key, CardUpgradeData item) { logger.Log((LogLevel)16, (object)("Registering Upgrade " + key + "...")); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "cardUpgradeDatas").GetValue(allGameData)).Add(item); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from upgrade in SaveManager.Value.GetAllGameData().GetAllCardUpgradeData() select ((GameData)upgrade).GetID()).ToList(); } return new List(); } return (from upgrade in SaveManager.Value.GetAllGameData().GetAllCardUpgradeData() select upgrade.GetAssetKey()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardUpgradeData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 lookup = null; IsModded = null; if ((int)identifierType != 0) { if ((int)identifierType == 1) { foreach (CardUpgradeData allCardUpgradeDatum in SaveManager.Value.GetAllGameData().GetAllCardUpgradeData()) { if (((GameData)allCardUpgradeDatum).GetID().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCardUpgradeDatum; IsModded = ContainsKey(((Object)allCardUpgradeDatum).name); return true; } } return false; } return false; } foreach (CardUpgradeData allCardUpgradeDatum2 in SaveManager.Value.GetAllGameData().GetAllCardUpgradeData()) { if (allCardUpgradeDatum2.GetAssetKey().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCardUpgradeDatum2; IsModded = ContainsKey(((Object)allCardUpgradeDatum2).name); return true; } } return false; } } } namespace TrainworksReloaded.Base.Card { public class CardDataDefinition : IDefinition { public string Id { get; set; } public string Key { get; set; } public CardData Data { get; set; } public IConfiguration Configuration { get; set; } public bool IsModded => !P; public CardDataDefinition(string key, CardData data, IConfiguration configuration, bool isOverride) { P = isOverride; Id = ""; Key = key; Data = data; Configuration = configuration; base..ctor(); } } public class CardDataFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister classRegister; private readonly IRegister cardRegister; private readonly IRegister cardPoolRegister; private readonly IRegister traitRegister; private readonly IRegister effectRegister; private readonly IRegister assetReferenceRegister; private readonly IRegister gameObjectRegister; private readonly IRegister upgradeRegister; private readonly IRegister triggerEffectRegister; private readonly IRegister triggerDataRegister; private readonly IRegister vfxRegister; private readonly IRegister soundCueRegister; private readonly FallbackDataProvider fallbackDataProvider; private readonly FieldInfo CardPoolCardDataListField = AccessTools.Field(typeof(CardPool), "cardDataList"); public CardDataFinalizer(IModLogger logger, ICache> cache, IRegister classRegister, IRegister cardRegister, IRegister cardPoolRegister, IRegister traitRegister, IRegister effectRegister, IRegister assetReferenceRegister, IRegister gameObjectRegister, IRegister upgradeRegister, IRegister triggerEffectRegister, IRegister triggerDataRegister, IRegister soundCueRegister, IRegister vfxRegister, FallbackDataProvider fallbackDataProvider) { this.logger = logger; this.cache = cache; this.classRegister = classRegister; this.cardRegister = cardRegister; this.cardPoolRegister = cardPoolRegister; this.traitRegister = traitRegister; this.effectRegister = effectRegister; this.assetReferenceRegister = assetReferenceRegister; this.gameObjectRegister = gameObjectRegister; this.upgradeRegister = upgradeRegister; this.triggerEffectRegister = triggerEffectRegister; this.triggerDataRegister = triggerDataRegister; this.vfxRegister = vfxRegister; this.soundCueRegister = soundCueRegister; this.fallbackDataProvider = fallbackDataProvider; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardData(cacheItem); } cache.Clear(); } private void FinalizeCardData(IDefinition definition) { //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_0026: 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_00ef: Invalid comparison between Unknown and I4 //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Invalid comparison between Unknown and I4 //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Invalid comparison between Unknown and I4 //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0552: Invalid comparison between Unknown and I4 //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Invalid comparison between Unknown and I4 //IL_0734: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Invalid comparison between Unknown and I4 //IL_082f: Unknown result type (might be due to invalid IL or missing references) //IL_0831: Invalid comparison between Unknown and I4 //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_0927: Invalid comparison between Unknown and I4 IConfiguration configuration = definition.Configuration; CardData data = definition.Data; string key = definition.Key; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); bool flag = OverrideModeExtensions.IsNewContent(val); logger.Log((LogLevel)16, (object)("Finalizing Card " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); ParseReferenceExtensions.ReferencedObject referencedObject = configuration.GetSection("class").ParseReference(); if (referencedObject != null && classRegister.TryLookupName(referencedObject.ToId(key, "Class"), out ClassData lookup, out bool? IsModded, referencedObject.context)) { AccessTools.Field(typeof(CardData), "linkedClass").SetValue(data, lookup); } List sharedDiscoveryCards = data.GetSharedDiscoveryCards(); IConfigurationSection section = configuration.GetSection("shared_discovery_cards"); if ((int)val == 1 && section.Exists()) { sharedDiscoveryCards.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item in (from x in section.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (cardRegister.TryLookupName(item.ToId(key, "Card"), out CardData lookup2, out IsModded, item.context)) { sharedDiscoveryCards.Add(lookup2); } } AccessTools.Field(typeof(CardData), "sharedDiscoveryCards").SetValue(data, sharedDiscoveryCards); List sharedMasteryCards = data.GetSharedMasteryCards(); IConfigurationSection section2 = configuration.GetSection("shared_mastery_cards"); if ((int)val == 1 && section2.Exists()) { sharedMasteryCards.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item2 in (from x in section2.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (cardRegister.TryLookupName(item2.ToId(key, "Card"), out CardData lookup3, out IsModded, item2.context)) { sharedMasteryCards.Add(lookup3); } } AccessTools.Field(typeof(CardData), "sharedMasteryCards").SetValue(data, sharedMasteryCards); IConfigurationSection deprecatedSection = configuration.GetDeprecatedSection("mastery_card", "linked_mastery_card"); ParseReferenceExtensions.ReferencedObject referencedObject2 = deprecatedSection.ParseReference(); if (referencedObject2 != null) { cardRegister.TryLookupName(referencedObject2.ToId(key, "Card"), out CardData lookup4, out IsModded, referencedObject2.context); AccessTools.Field(typeof(CardData), "linkedMasteryCard").SetValue(data, lookup4); } if ((int)val == 1 && deprecatedSection.Exists() && referencedObject2 == null) { AccessTools.Field(typeof(CardData), "linkedMasteryCard").SetValue(data, null); } ParseReferenceExtensions.ReferencedObject referencedObject3 = configuration.GetDeprecatedSection("card_art_reference", "card_art").ParseAssetReference(); if (referencedObject3 != null) { if (assetReferenceRegister.TryLookupId(referencedObject3.ToId(key, "GameObject"), out AssetReferenceGameObject lookup5, out IsModded, referencedObject3.context)) { AccessTools.Field(typeof(CardData), "cardArtPrefabVariantRef").SetValue(data, lookup5); } } else if (data.IsUnitAbility() || data.IsRoomAbility()) { AccessTools.Field(typeof(CardData), "cardArtPrefabVariantRef").SetValue(data, (object?)new AssetReferenceGameObject()); } else if (OverrideModeExtensions.IsNewContent(val)) { logger.Log((LogLevel)4, (object)("Card " + key + " " + definition.Id + " is missing card_art. This is required for non ability cards.")); } IEnumerable enumerable = (from x in configuration.GetSection("sound_effects").GetChildren() select x.ParseReference() into x where x != null select x).Cast(); if (enumerable.Any() && referencedObject3 != null && gameObjectRegister.TryLookupId(referencedObject3.ToId(key, "GameObject"), out GameObject lookup6, out IsModded, referencedObject3.context)) { CoreSoundEffectHolder val2 = lookup6.AddComponent(); val2.SoundEffectData = ScriptableObject.CreateInstance(); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item3 in enumerable) { if (soundCueRegister.TryLookupName(item3.ToId(key, "SoundCueDefinition"), out SoundCueDefinition lookup7, out bool? _, item3.context)) { list.Add(lookup7); } } val2.SoundEffectData.Sounds = list.ToArray(); } List traits = data.GetTraits(); IConfigurationSection section3 = configuration.GetSection("traits"); if ((int)val == 1 && section3.Exists()) { traits.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item4 in (from x in section3.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id = item4.ToId(key, "Trait"); if (traitRegister.TryLookupId(id, out CardTraitData lookup8, out IsModded, item4.context)) { traits.Add(lookup8); } } AccessTools.Field(typeof(CardData), "traits").SetValue(data, traits); List effects = data.GetEffects(); IConfigurationSection section4 = configuration.GetSection("effects"); if ((int)val == 1 && section4.Exists()) { effects.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item5 in (from x in section4.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { if (effectRegister.TryLookupId(item5.ToId(key, "Effect"), out CardEffectData lookup9, out IsModded, item5.context)) { effects.Add(lookup9); } } AccessTools.Field(typeof(CardData), "effects").SetValue(data, effects); List cardTriggers = data.GetCardTriggers(); IConfigurationSection section5 = configuration.GetSection("triggers"); if ((int)val == 1 && section5.Exists()) { cardTriggers.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item6 in (from x in section5.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id2 = item6.ToId(key, "Trigger"); if (triggerEffectRegister.TryLookupId(id2, out CardTriggerEffectData lookup10, out IsModded, item6.context)) { cardTriggers.Add(lookup10); } } AccessTools.Field(typeof(CardData), "triggers").SetValue(data, cardTriggers); List list2 = new List(); IReadOnlyList upgradeData = data.GetUpgradeData(); IConfigurationSection section6 = configuration.GetSection("initial_upgrades"); if ((int)val != 1 || !section6.Exists()) { list2.AddRange(upgradeData); } foreach (ParseReferenceExtensions.ReferencedObject item7 in (from x in section6.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item7.ToId(key, "Upgrade"); if (upgradeRegister.TryLookupName(name, out CardUpgradeData lookup11, out IsModded, item7.context)) { list2.Add(lookup11); } } AccessTools.Field(typeof(CardData), "startingUpgrades").SetValue(data, list2); List effectTriggers = data.GetEffectTriggers(); IConfigurationSection section7 = configuration.GetSection("effect_triggers"); if ((int)val == 1 && section7.Exists()) { effectTriggers.Clear(); } foreach (ParseReferenceExtensions.ReferencedObject item8 in (from x in section7.GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id3 = item8.ToId(key, "CTrigger"); if (triggerDataRegister.TryLookupId(id3, out CharacterTriggerData lookup12, out IsModded, item8.context)) { effectTriggers.Add(lookup12); } } AccessTools.Field(typeof(CardData), "effectTriggers").SetValue(data, effectTriggers); ParseReferenceExtensions.ReferencedObject referencedObject4 = configuration.GetDeprecatedSection("vfx", "off_cooldown_vfx").ParseReference(); if (flag || referencedObject4 != null) { string id4 = referencedObject4?.ToId(key, "Vfx") ?? ""; vfxRegister.TryLookupId(id4, out VfxAtLoc lookup13, out IsModded, referencedObject4?.context); AccessTools.Field(typeof(CardData), "offCooldownVFX").SetValue(data, lookup13); } ParseReferenceExtensions.ReferencedObject referencedObject5 = configuration.GetSection("special_edge_vfx").ParseReference(); if (flag || referencedObject5 != null) { string id5 = referencedObject5?.ToId(key, "Vfx") ?? ""; vfxRegister.TryLookupId(id5, out VfxAtLoc lookup14, out IsModded, referencedObject4?.context); AccessTools.Field(typeof(CardData), "specialEdgeVFX").SetValue(data, lookup14); } foreach (ParseReferenceExtensions.ReferencedObject item9 in (from x in configuration.GetSection("pools").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string id6 = item9.ToId(key, "CardPool"); if (cardPoolRegister.TryLookupId(id6, out CardPool lookup15, out IsModded, item9.context)) { (CardPoolCardDataListField.GetValue(lookup15) as ReorderableArray)?.Add(data); } } AccessTools.Field(typeof(CardData), "fallbackData").SetValue(data, fallbackDataProvider.FallbackData); } } public class CardDataPipeline : IDataPipeline, CardData> { private readonly PluginAtlas atlas; private readonly IModLogger logger; private readonly IRegister termRegister; private readonly IGuidProvider guidProvider; private readonly IInstanceGenerator generator; public CardDataPipeline(PluginAtlas atlas, IModLogger logger, IRegister termRegister, IGuidProvider guidProvider, IInstanceGenerator generator) { this.atlas = atlas; this.logger = logger; this.termRegister = termRegister; this.guidProvider = guidProvider; this.generator = generator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadCards(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadCards(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("cards").GetChildren()) { CardDataDefinition cardDataDefinition = LoadCardConfiguration(service, key, child); if (cardDataDefinition != null) { list.Add(cardDataDefinition); } } return list; } public CardDataDefinition? LoadCardConfiguration(IRegister service, string key, IConfiguration configuration) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Invalid comparison between Unknown and I4 //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0647: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_0658: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_084b: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_08be: Unknown result type (might be due to invalid IL or missing references) //IL_0908: Unknown result type (might be due to invalid IL or missing references) //IL_0913: Unknown result type (might be due to invalid IL or missing references) //IL_091b: Unknown result type (might be due to invalid IL or missing references) //IL_0947: Unknown result type (might be due to invalid IL or missing references) //IL_0949: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("Card", text); string text2 = "CardData_nameKey-" + id; string text3 = "CardData_descriptionKey-" + id; OverrideMode val = configuration.GetSection("override").ParseOverrideMode(); string value; if (OverrideModeExtensions.IsOverriding(val) && service.TryLookupName(text, out CardData lookup, out bool? _)) { logger.Log((LogLevel)16, (object)("Overriding Card " + text + "... ")); text3 = lookup.GetOverrideDescriptionKey(); text2 = lookup.GetNameKey(); value = ((GameData)lookup).GetID(); } else { lookup = generator.CreateInstance(); ((Object)lookup).name = id; value = guidProvider.GetGuidDeterministic(id).ToString(); } AccessTools.Field(typeof(CardData), "id").SetValue(lookup, value); LocalizationTerm localizationTerm = configuration.GetSection("names").ParseLocalizationTerm(); if (localizationTerm != null) { AccessTools.Field(typeof(CardData), "nameKey").SetValue(lookup, text2); localizationTerm.Key = text2; ((IRegisterableDictionary)(object)termRegister).Register(text2, localizationTerm); } LocalizationTerm localizationTerm2 = configuration.GetSection("descriptions").ParseLocalizationTerm(); if (localizationTerm2 != null) { AccessTools.Field(typeof(CardData), "overrideDescriptionKey").SetValue(lookup, text3); localizationTerm2.Key = text3; ((IRegisterableDictionary)(object)termRegister).Register(text3, localizationTerm2); } List list = (List)AccessTools.Field(typeof(CardData), "cardLoreTooltipKeys").GetValue(lookup); IConfigurationSection section = configuration.GetSection("lore_tooltips"); if ((int)val == 1 && section.Exists()) { list.Clear(); } int num = list.Count; foreach (IConfigurationSection child in section.GetChildren()) { LocalizationTerm localizationTerm3 = child.ParseLocalizationTerm(); if (localizationTerm3 != null) { string text4 = $"CardData_tooltipKey{num}-{id}"; if (IEnumerableUtility.IsNullOrEmpty((IEnumerable)localizationTerm3.Key)) { localizationTerm3.Key = text4; } list.Add(text4); if (localizationTerm3.HasTranslation()) { ((IRegisterableDictionary)(object)termRegister).Register(text4, localizationTerm3); } num++; } } AccessTools.Field(typeof(CardData), "cardLoreTooltipKeys").SetValue(lookup, list); int num2 = (int)AccessTools.Field(typeof(CardData), "cost").GetValue(lookup); AccessTools.Field(typeof(CardData), "cost").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("cost")) ?? num2); CostType val2 = (CostType)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)(CostType)AccessTools.Field(typeof(CardData), "costType").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "costType").SetValue(lookup, configuration.GetSection("cost_type").ParseCostType() ?? val2); CardType val3 = (CardType)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)(CardType)AccessTools.Field(typeof(CardData), "cardType").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "cardType").SetValue(lookup, configuration.GetDeprecatedSection("type", "card_type").ParseCardType() ?? val3); int num3 = ((!OverrideModeExtensions.IsNewContent(val)) ? ((int)AccessTools.Field(typeof(CardData), "cooldownAtSpawn").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "cooldownAtSpawn").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("initial_cooldown")) ?? num3); int num4 = ((!OverrideModeExtensions.IsNewContent(val)) ? ((int)AccessTools.Field(typeof(CardData), "cooldownAfterActivated").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "cooldownAfterActivated").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("cooldown")) ?? num4); bool flag = (bool)AccessTools.Field(typeof(CardData), "isUnitAbility").GetValue(lookup); AccessTools.Field(typeof(CardData), "isUnitAbility").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("ability", "is_an_ability")) ?? flag); bool flag2 = (bool)AccessTools.Field(typeof(CardData), "isRoomAbility").GetValue(lookup); AccessTools.Field(typeof(CardData), "isRoomAbility").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("is_room_ability")) ?? flag2); bool flag3 = (bool)AccessTools.Field(typeof(CardData), "targetsRoom").GetValue(lookup); AccessTools.Field(typeof(CardData), "targetsRoom").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("targets_room")) ?? flag3); bool flag4 = (bool)AccessTools.Field(typeof(CardData), "targetless").GetValue(lookup); AccessTools.Field(typeof(CardData), "targetless").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("targetless")) ?? flag4); CollectableRarity val4 = (CollectableRarity)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)(CollectableRarity)AccessTools.Field(typeof(CardData), "rarity").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "rarity").SetValue(lookup, configuration.GetSection("rarity").ParseRarity() ?? val4); DLC val5 = (DLC)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)(DLC)AccessTools.Field(typeof(CardData), "requiredDLC").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "requiredDLC").SetValue(lookup, configuration.GetDeprecatedSection("dlc", "required_dlc").ParseDLC() ?? val5); int num5 = ((!OverrideModeExtensions.IsNewContent(val)) ? ((int)AccessTools.Field(typeof(CardData), "unlockLevel").GetValue(lookup)) : 0); AccessTools.Field(typeof(CardData), "unlockLevel").SetValue(lookup, ParseExtensions.ParseInt(configuration.GetSection("unlock_level")) ?? num5); bool flag5 = (bool)AccessTools.Field(typeof(CardData), "ignoreWhenCountingMastery").GetValue(lookup); AccessTools.Field(typeof(CardData), "ignoreWhenCountingMastery").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("count_for_mastery", "ignore_when_counting_mastery")) ?? flag5); bool flag6 = (bool)AccessTools.Field(typeof(CardData), "hideInLogbook").GetValue(lookup); AccessTools.Field(typeof(CardData), "hideInLogbook").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetSection("hide_in_logbook")) ?? flag6); CardInitialKeyboardTarget val6 = (CardInitialKeyboardTarget)(OverrideModeExtensions.IsNewContent(val) ? 1 : ((int)(CardInitialKeyboardTarget)AccessTools.Field(typeof(CardData), "initialKeyboardTarget").GetValue(lookup))); AccessTools.Field(typeof(CardData), "initialKeyboardTarget").SetValue(lookup, configuration.GetDeprecatedSection("target_assist", "initial_keyboard_target").ParseKeyboardTarget() ?? val6); bool flag7 = (bool)AccessTools.Field(typeof(CardData), "canAbilityTargetOtherFloors").GetValue(lookup); AccessTools.Field(typeof(CardData), "canAbilityTargetOtherFloors").SetValue(lookup, ParseExtensions.ParseBool(configuration.GetDeprecatedSection("ability_effects_other_floors", "can_ability_target_other_floors")) ?? flag7); string text5 = (OverrideModeExtensions.IsNewContent(val) ? "" : lookup.GetArtistAttribution()); AccessTools.Field(typeof(CardData), "artistAttribution").SetValue(lookup, ParseExtensions.ParseString(configuration.GetSection("artist")) ?? text5); RoomTargetPos val7 = (RoomTargetPos)((!OverrideModeExtensions.IsNewContent(val)) ? ((int)lookup.GetRoomKeyboardDefaultTargetPos()) : 0); AccessTools.Field(typeof(CardData), "roomKeyboardDefaultTargetPos").SetValue(lookup, configuration.GetSection("room_keyboard_default_target_pos").ParseRoomTargetPos() ?? val7); bool flag8 = OverrideModeExtensions.IsNewContent(val); if (flag8) { ((IRegisterableDictionary)(object)service).Register(id, lookup); } return new CardDataDefinition(key, lookup, configuration, flag8) { Id = text }; } } public class CardDataRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly Lazy SaveManager; private readonly IModLogger logger; public CardPool CustomCardPool; public ReorderableArray CardPoolBacking; public CardDataRegister(GameDataClient client, IModLogger logger) { SaveManager = new Lazy((Func)(() => (SaveManager)((!client.TryGetProvider(out SaveManager provider)) ? ((object)new SaveManager()) : ((object)provider)))); CustomCardPool = ScriptableObject.CreateInstance(); ((Object)CustomCardPool).name = "ModdedPool"; CardPoolBacking = (ReorderableArray)AccessTools.Field(typeof(CardPool), "cardDataList").GetValue(CustomCardPool); this.logger = logger; } public void Register(string key, CardData item) { logger.Log((LogLevel)16, (object)("Register Card " + key + "... ")); CardPoolBacking.Add(item); AllGameData allGameData = SaveManager.Value.GetAllGameData(); ((List)AccessTools.Field(typeof(AllGameData), "cardDatas").GetValue(allGameData)).Add(item); Add(key, item); } public bool TryLookupId(string id, [NotNullWhen(true)] out CardData? lookup, [NotNullWhen(true)] out bool? IsModded) { lookup = null; IsModded = null; foreach (CardData allCardDatum in SaveManager.Value.GetAllGameData().GetAllCardData()) { if (((GameData)allCardDatum).GetID().Equals(id, StringComparison.OrdinalIgnoreCase)) { lookup = allCardDatum; IsModded = ContainsKey(((Object)allCardDatum).name); return true; } } return false; } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 if ((int)identifierType != 0) { if ((int)identifierType == 1) { return (from card in SaveManager.Value.GetAllGameData().GetAllCardData() select ((GameData)card).GetID()).ToList(); } return new List(); } return (from card in SaveManager.Value.GetAllGameData().GetAllCardData() select card.GetAssetKey()).ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardData? lookup, [NotNullWhen(true)] out bool? IsModded) { //IL_002f: 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_0034: Invalid comparison between Unknown and I4 lookup = null; IsModded = null; foreach (CardData allCardDatum in SaveManager.Value.GetAllGameData().GetAllCardData()) { if ((int)identifierType != 0) { if ((int)identifierType == 1 && ((GameData)allCardDatum).GetID().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCardDatum; IsModded = ContainsKey(((Object)allCardDatum).name); return true; } } else if (allCardDatum.GetAssetKey().Equals(identifier, StringComparison.OrdinalIgnoreCase)) { lookup = allCardDatum; IsModded = ContainsKey(((Object)allCardDatum).name); return true; } } return false; } } public class CardPoolDefinition : IDefinition { public string Id { get; set; } = ""; public string Key { get; set; } public CardPool Data { get; set; } public IConfiguration Configuration { get; set; } public bool IsModded => true; public CardPoolDefinition(string key, CardPool data, IConfiguration configuration) { Key = key; Data = data; Configuration = configuration; base..ctor(); } } public class CardPoolFinalizer : IDataFinalizer { private readonly IModLogger logger; private readonly ICache> cache; private readonly IRegister cardRegister; public CardPoolFinalizer(IModLogger logger, ICache> cache, IRegister cardRegister) { this.logger = logger; this.cache = cache; this.cardRegister = cardRegister; } public void FinalizeData() { foreach (IDefinition cacheItem in cache.GetCacheItems()) { FinalizeCardPoolData(cacheItem); } cache.Clear(); } private void FinalizeCardPoolData(IDefinition definition) { IConfiguration configuration = definition.Configuration; CardPool data = definition.Data; string key = definition.Key; logger.Log((LogLevel)16, (object)("Finalizing Card Pool " + definition.Key + " " + definition.Id + " path: " + configuration.GetPath() + "...")); List list = new List(); foreach (ParseReferenceExtensions.ReferencedObject item in (from x in configuration.GetSection("cards").GetChildren() select x.ParseReference() into x where x != null select x).Cast()) { string name = item.ToId(key, "Card"); if (cardRegister.TryLookupName(name, out CardData lookup, out bool? _, item.context)) { list.Add(lookup); } } if (list.Count == 0) { return; } ReorderableArray val = (ReorderableArray)AccessTools.Field(typeof(CardPool), "cardDataList").GetValue(data); val.Clear(); foreach (CardData item2 in list) { val.Add(item2); } AccessTools.Field(typeof(CardPool), "cardDataList").SetValue(data, val); } } public class CardPoolPipeline : IDataPipeline, CardPool> { private readonly PluginAtlas atlas; private readonly IInstanceGenerator generator; public CardPoolPipeline(PluginAtlas atlas, IRegister termRegister, IInstanceGenerator generator) { this.atlas = atlas; this.generator = generator; } public List> Run(IRegister service) { List> list = new List>(); foreach (KeyValuePair pluginDefinition in atlas.PluginDefinitions) { list.AddRange((IEnumerable>)LoadPools(service, pluginDefinition.Key, pluginDefinition.Value.Configuration)); } return list; } public List LoadPools(IRegister service, string key, IConfiguration pluginConfig) { List list = new List(); foreach (IConfigurationSection child in pluginConfig.GetSection("card_pools").GetChildren()) { CardPoolDefinition cardPoolDefinition = LoadCardPoolConfiguration(service, key, child); if (cardPoolDefinition != null) { list.Add(cardPoolDefinition); } } return list; } public CardPoolDefinition? LoadCardPoolConfiguration(IRegister service, string key, IConfiguration configuration) { string text = ParseExtensions.ParseString(configuration.GetSection("id")); if (text == null) { return null; } string id = key.GetId("CardPool", text); CardPool val = generator.CreateInstance(); ((Object)val).name = id; ((IRegisterableDictionary)(object)service).Register(id, val); return new CardPoolDefinition(key, val, configuration) { Id = text }; } } public class CardPoolRegister : Dictionary, IRegister, IRegisterableDictionary, IDictionary, ICollection>, IEnumerable>, IEnumerable { private readonly IModLogger logger; private readonly Dictionary VanillaCardPools = new Dictionary(); private readonly Dictionary ClassDraftableCardPools = new Dictionary(); public CardPoolRegister(IModLogger logger) { this.logger = logger; Extensions.AddRange(VanillaCardPools, Resources.FindObjectsOfTypeAll().ToDictionary((CardPool x) => ((Object)x).name, (CardPool x) => x)); VanillaCardPools.Remove("ModdedPool"); Extensions.AddRange((Dictionary)this, VanillaCardPools); FormVanillaClassDraftableCardPools(); } private void FormVanillaClassDraftableCardPools() { ClassDraftableCardPools.Add("ClassBanished", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsBanishedBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassPyreborne", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsPyreborneBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassLunaCoven", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsLunaCovenBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassUnderlegion", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsUnderlegionBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassLazarusLeague", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsLazarusLeagueBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassRailforged", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsRailforgedBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassHellhorned", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsHellhornedBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassAwoken", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsAwokenBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassStygian", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsStygianBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassUmbra", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsUmbraBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassRemnant", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsRemnantBannerReplacementMutator", (CardPool)null)); ClassDraftableCardPools.Add("ClassWurm", IEnumerableUtility.GetValueOrDefault((IDictionary)VanillaCardPools, "UnitsWurmBannerReplacementMutator", (CardPool)null)); } public void Register(string key, CardPool item) { logger.Log((LogLevel)16, (object)("Register Card Pool " + key + "...")); Add(key, item); } public List GetAllIdentifiers(RegisterIdentifierType identifierType) { return base.Keys.ToList(); } public bool TryLookupIdentifier(string identifier, RegisterIdentifierType identifierType, [NotNullWhen(true)] out CardPool? lookup, [NotNullWhen(true)] out bool? IsModded) { IsModded = !VanillaCardPools.ContainsKey(identifier); return TryGetValue(identifier, out lookup); } internal void RegisterBannerReplacementPool(string classname, CardPool replacementCardPool) { ClassDraftableCardPools[classname] = replacementCardPool; } public CardPool? GetBannerReplacementPool(string classname) { return IEnumerableUtility.GetValueOrDefault((IDictionary)ClassDraftableCardPools, classname, (CardPool)null); } } }