Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ItemStringParser v2.2.0
ItemStringParser.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HG; using HG.Reflection; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceLocations; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ItemStringParser")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f9a53bdf6e69346af8b521837d01ddaf4e84d5dd")] [assembly: AssemblyProduct("ItemStringParser")] [assembly: AssemblyTitle("ItemStringParser")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 ItemStringParser { [BepInPlugin("Def.ItemStringParser", "ItemStringParser", "2.2.0")] public class ItemStringParser : BaseUnityPlugin { private class SelectionDropTable : PickupDropTable { public WeightedSelection<UniquePickup> selection; public override int GetPickupCount() { if (selection == null) { return 0; } return selection.Count; } public override UniquePickup GeneratePickupPreReplacement(Xoroshiro128Plus rng) { //IL_0016: 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) if (selection == null || selection.Count <= 0) { return UniquePickup.none; } return selection.Evaluate(rng.nextNormalizedFloat); } } private class ItemStringEntry { public string itemKey; public int repeat = 1; public int multiplier = 1; public float weight = 1f; } public enum ItemStringFormat { DEFAULT, WEIGHTED_OR_ONLY } public const string PluginGUID = "Def.ItemStringParser"; public const string PluginAuthor = "Def"; public const string PluginName = "ItemStringParser"; public const string PluginVersion = "2.2.0"; private static readonly Regex tokenPattern = new Regex("^(?:(\\d+)\\s*x\\s*)?(\\w+(?:\\s*(?:!\\s*#?|#)\\s*\\w+)*)$", RegexOptions.IgnoreCase); private static readonly Regex filterPattern = new Regex("(!\\s*#|!|#)\\s*(\\w+)"); private static ManualLogSource Log; private static readonly Dictionary<string, AsyncOperationHandle<PickupDropTable>> loadedDropTables = new Dictionary<string, AsyncOperationHandle<PickupDropTable>>(); private static Dictionary<string, string> dropTables; private static readonly Xoroshiro128Plus rng = new Xoroshiro128Plus((ulong)DateTime.UtcNow.Ticks); private static readonly HashSet<string> warnedTierNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static SelectionDropTable selectionDropTable; private static readonly EquipmentLocationQueryArgs emptyEquipmentLocation = new EquipmentLocationQueryArgs { searchAllSlots = true, allowEmpty = true, searchPriority = (SearchPriority)1 }; public static PluginInfo PInfo { get; private set; } private static Dictionary<string, string> DropTables { get { if (dropTables == null) { dropTables = FindDropTables(); } return dropTables; } } private void Awake() { Log = ((BaseUnityPlugin)this).Logger; } private static Dictionary<string, string> FindDropTables() { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); IList<IResourceLocation> list = default(IList<IResourceLocation>); foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators) { foreach (object key in resourceLocator.Keys) { if (!(key is string text) || !text.EndsWith(".asset", StringComparison.OrdinalIgnoreCase) || !resourceLocator.Locate((object)text, typeof(PickupDropTable), ref list) || list.Count == 0) { continue; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text); if (dictionary.TryGetValue(fileNameWithoutExtension, out var value)) { if (value != text) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("Drop table name " + fileNameWithoutExtension + " is used twice; " + text + " is ignored in favor of " + value + ".")); } } } else { dictionary.Add(fileNameWithoutExtension, text); } } } return dictionary; } private static PickupDropTable GetDroptable(string droptable) { //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_0028: Unknown result type (might be due to invalid IL or missing references) string text = DropTables[droptable]; if (!loadedDropTables.TryGetValue(text, out var value)) { value = Addressables.LoadAssetAsync<PickupDropTable>((object)text); loadedDropTables[text] = value; } return value.WaitForCompletion(); } public static T GetRandom<T>(List<T> list, T defaultValue) { if (list == null || list.Count == 0) { return defaultValue; } return list[Random.RandomRangeInt(0, list.Count)]; } private static bool TryReplaceOuterBraces(string input, out string replacedString, out Dictionary<string, string> replacements) { StringBuilder stringBuilder = new StringBuilder(); int num = 0; List<(int, int)> list = new List<(int, int)>(); replacedString = input; replacements = new Dictionary<string, string>(); for (int i = 0; i < input.Length; i++) { if (input[i] == '{') { if (num == 0) { list.Add((i, -1)); } num++; } else if (input[i] == '}') { if (num == 0) { return false; } num--; if (num == 0) { (int, int) tuple = list[list.Count - 1]; list[list.Count - 1] = (tuple.Item1, i); } } } if (num != 0) { return false; } int num2 = 0; foreach (var item in list) { stringBuilder.Append(input.Substring(num2, item.Item1 - num2)); string text = input.Substring(item.Item1, item.Item2 - item.Item1 + 1); string value = text.Substring(1, text.Length - 2); string text2 = $"__group{replacements.Count}__"; replacements[text2] = value; stringBuilder.Append(text2); num2 = item.Item2 + 1; } stringBuilder.Append(input.Substring(num2)); replacedString = stringBuilder.ToString(); return true; } public static PickupIndex ResolveItemKey(string itemkey, bool availableOnly = true) { //IL_002d: 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_0035: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0066: Unknown result type (might be due to invalid IL or missing references) Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>(); ResolveItemKey(itemkey, 1, dictionary, null, availableOnly); foreach (var (val2, num2) in dictionary) { if (num2 > 0 && val2 != PickupIndex.none) { return val2; } } return PickupIndex.none; } private static List<PickupIndex> GetTierDropList(string tier) { //IL_0391: 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) //IL_035e: Unknown result type (might be due to invalid IL or missing references) Run instance = Run.instance; switch (tier.ToLowerInvariant()) { case "tier1": return instance.availableTier1DropList; case "tier2": return instance.availableTier2DropList; case "tier3": return instance.availableTier3DropList; case "boss": return instance.availableBossDropList; case "lunar": return instance.availableLunarCombinedDropList; case "lunaritem": return instance.availableLunarItemDropList; case "lunarequipment": return instance.availableLunarEquipmentDropList; case "equipment": return instance.availableEquipmentDropList; case "voidtier1": return instance.availableVoidTier1DropList; case "voidtier2": return instance.availableVoidTier2DropList; case "voidtier3": return instance.availableVoidTier3DropList; case "voidboss": return instance.availableVoidBossDropList; case "foodtier": return instance.availableFoodTierDropList; case "cursed": return instance.availableCursedTierDropList; case "hex": return instance.availableHexTierDropList; case "page": return instance.availablePageTierDropList; case "powershape": return instance.availablePowerShapeItemsDropList; case "keyitem": return instance.availableKeyItemsDropList; case "any": return GetAnyItems(instance); default: { ItemTierDef val = FindTierDef(tier); if (!Object.op_Implicit((Object)(object)val)) { return null; } if (warnedTierNames.Add(tier) && (DropTables.ContainsKey(tier) || FindPickupByName(tier) != PickupIndex.none)) { Log.LogWarning((object)(tier + " is the item tier " + ((Object)val).name + ", so the drop table or item of the same name can't be used by it.")); } if (!instance.allAvailableTierDroplists.TryGetValue(val.tier, out var value)) { return new List<PickupIndex>(); } return value; } } } private static List<PickupIndex> GetAnyItems(Run run) { return (from pickup in run.allAvailableTierDroplists.Where((KeyValuePair<ItemTier, List<PickupIndex>> pair) => (int)pair.Key != 5).SelectMany((KeyValuePair<ItemTier, List<PickupIndex>> pair) => pair.Value) where !ItemCatalog.GetItemDef(((PickupIndex)(ref pickup)).pickupDef.itemIndex).ContainsTag((ItemTag)26) select pickup).ToList(); } private static ItemTierDef FindTierDef(string name) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references) string text = NormalizeTierName(name); List<ItemTierDef> list = new List<ItemTierDef>(); Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemTierDef current = enumerator.Current; if (Object.op_Implicit((Object)(object)current)) { if (NormalizeTierName(((Object)current).name) == text) { return current; } if (ShortTierName(((Object)current).name) == text) { list.Add(current); } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (list.Count > 1 && warnedTierNames.Add(name)) { Log.LogWarning((object)(name + " could be any of the item tiers " + string.Join(", ", list.Select((ItemTierDef tierDef) => ((Object)tierDef).name)) + "; use one of these names.")); } if (list.Count != 1) { return null; } return list[0]; } private static string NormalizeTierName(string name) { return new string(name.Where((char c) => char.IsLetterOrDigit(c) || c == '_').ToArray()).ToLowerInvariant(); } private static string ShortTierName(string tierDefName) { string text = NormalizeTierName(tierDefName); string[] array = new string[2] { "tierdef", "def" }; foreach (string text2 in array) { if (text.Length > text2.Length && text.EndsWith(text2)) { return text.Substring(0, text.Length - text2.Length); } } return text; } private static UniquePickup PickThroughDropTable(WeightedSelection<UniquePickup> selection) { //IL_0008: 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) if (selection.Count == 0) { return UniquePickup.none; } if (!Object.op_Implicit((Object)(object)selectionDropTable)) { selectionDropTable = ScriptableObject.CreateInstance<SelectionDropTable>(); ((PickupDropTable)selectionDropTable).canDropBeReplaced = false; } selectionDropTable.selection = selection; return ((PickupDropTable)selectionDropTable).GeneratePickup(rng); } private static bool ResolveItemKey(string itemkey, int repeat, Dictionary<PickupIndex, int> resolvedItems, ManualLogSource log, bool availableOnly) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00c1: 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_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_0425: 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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_031e: 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_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_032c: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: 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_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: 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_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: 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_03b6: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> itemBlackList = new List<PickupIndex>(); List<ItemTag> requiredTags = new List<ItemTag>(); List<ItemTag> bannedTags = new List<ItemTag>(); MatchCollection matchCollection = filterPattern.Matches(itemkey); if (matchCollection.Count > 0) { itemkey = itemkey.Substring(0, matchCollection[0].Index); } itemkey = itemkey.Trim(); foreach (Match item in matchCollection) { string value = item.Groups[2].Value; if (item.Groups[1].Value == "!") { PickupIndex val = FindPickupByName(value); if (val != PickupIndex.none) { itemBlackList.Add(val); } else { HandleWarning(log, "ResolveItemKey: Could not get pickup from blacklisted item: " + value); } continue; } if (TryFindTag(value, out var tag)) { ((item.Groups[1].Value == "#") ? requiredTags : bannedTags).Add(tag); continue; } HandleWarning(log, "ResolveItemKey: Could not find item tag: " + value); return false; } List<PickupIndex> list = GetTierDropList(itemkey)?.Where(Passes).ToList(); if (list != null) { WeightedSelection<UniquePickup> val2 = new WeightedSelection<UniquePickup>(8); foreach (PickupIndex item2 in list) { val2.AddChoice(new UniquePickup(item2), 1f); } while (repeat > 0) { PickupIndex pickupIndex = PickThroughDropTable(val2).pickupIndex; if (pickupIndex == PickupIndex.none) { HandleWarning(log, "ResolveItemKey: Could not get pickup from item tier: " + itemkey + ", as all candidates are either disabled or locked behind expansion"); return false; } resolvedItems[pickupIndex] = resolvedItems.GetValueOrDefault(pickupIndex) + 1; repeat--; } return true; } if (DropTables.ContainsKey(itemkey)) { PickupDropTable droptable = GetDroptable(itemkey); droptable.EnsureInitialization(); BasicPickupDropTable val3 = (BasicPickupDropTable)(object)((droptable is BasicPickupDropTable) ? droptable : null); WeightedSelection<UniquePickup> val4 = ((val3 != null) ? val3.selector : ((ExplicitPickupDropTable)(((droptable is ExplicitPickupDropTable) ? droptable : null)?)).weightedSelection); WeightedSelection<UniquePickup> val5 = val4; if (val5 == null) { if (itemBlackList.Count > 0 || requiredTags.Count > 0 || bannedTags.Count > 0) { HandleWarning(log, "ResolveItemKey: Droptable " + itemkey + " does not support blacklisting items or tags."); } while (repeat > 0) { UniquePickup val6 = droptable.GeneratePickup(rng); if (!((UniquePickup)(ref val6)).isValid) { HandleWarning(log, "ResolveItemKey: Could not get pickup from droptable: " + itemkey); return false; } resolvedItems[val6.pickupIndex] = resolvedItems.GetValueOrDefault(val6.pickupIndex) + 1; repeat--; } return true; } WeightedSelection<UniquePickup> val7 = new WeightedSelection<UniquePickup>(8); for (int i = 0; i < val5.Count; i++) { ChoiceInfo<UniquePickup> choice = val5.GetChoice(i); PickupIndex pickupIndex2 = choice.value.pickupIndex; if (Passes(pickupIndex2) && Run.instance.IsPickupAvailable(pickupIndex2)) { val7.AddChoice(choice); } } if (val7.Count == 0) { HandleWarning(log, "ResolveItemKey: Could not get pickup from droptable: " + itemkey + ", as all candidates are either disabled or locked behind expansion"); return false; } while (repeat > 0) { UniquePickup val8 = PickThroughDropTable(val7); if (!((UniquePickup)(ref val8)).isValid) { HandleWarning(log, "ResolveItemKey: Could not get pickup from droptable: " + itemkey); return false; } resolvedItems[val8.pickupIndex] = resolvedItems.GetValueOrDefault(val8.pickupIndex) + 1; repeat--; } return true; } PickupIndex val9 = FindPickupByName(itemkey); if (val9 == PickupIndex.none) { HandleWarning(log, "ResolveItemKey: Could not find item key: " + itemkey); return false; } if (IsExpansionLocked(val9)) { HandleWarning(log, "ResolveItemKey: " + itemkey + " cannot be resolved as its DLC is not enabled in this run."); return false; } if (availableOnly && !Run.instance.IsPickupAvailable(val9)) { HandleWarning(log, "ResolveItemKey: " + itemkey + " cannot be resolved as it is disabled in this run."); return false; } resolvedItems[val9] = resolvedItems.GetValueOrDefault(val9) + repeat; return true; bool Passes(PickupIndex val10) { //IL_0006: 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) if (!itemBlackList.Contains(val10)) { return HasTags(val10, requiredTags, bannedTags); } return false; } } private static bool IsExpansionLocked(PickupIndex pickupIndex) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Run instance = Run.instance; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); if (!Object.op_Implicit((Object)(object)instance) || pickupDef == null) { return false; } if ((int)pickupDef.itemIndex != -1) { return instance.IsItemExpansionLocked(pickupDef.itemIndex); } if ((int)pickupDef.equipmentIndex != -1) { return instance.IsEquipmentExpansionLocked(pickupDef.equipmentIndex); } if ((int)pickupDef.droneIndex != -1) { return instance.IsDroneExpansionLocked(pickupDef.droneIndex); } if ((int)pickupDef.keyItemIndex != -1) { return instance.IsKeyItemExpansionLocked(pickupDef.keyItemIndex); } return false; } private static bool TryFindTag(string name, out ItemTag tag) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) string text = Enum.GetNames(typeof(ItemTag)).FirstOrDefault((string tagName) => tagName != "Any" && tagName != "Count" && string.Equals(tagName, name, StringComparison.OrdinalIgnoreCase)); tag = (ItemTag)((text != null) ? ((int)(ItemTag)Enum.Parse(typeof(ItemTag), text)) : 0); return text != null; } private static bool HasTags(PickupIndex pickupIndex, List<ItemTag> requiredTags, List<ItemTag> bannedTags) { //IL_0000: 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) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); ItemDef val = ((pickupDef != null) ? ItemCatalog.GetItemDef(pickupDef.itemIndex) : null); if (!Object.op_Implicit((Object)(object)val)) { return requiredTags.Count == 0; } if (((IEnumerable<ItemTag>)requiredTags).All((Func<ItemTag, bool>)val.ContainsTag)) { return !((IEnumerable<ItemTag>)bannedTags).Any((Func<ItemTag, bool>)val.ContainsTag); } return false; } private static PickupIndex FindPickupByName(string name) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0013: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_003f: Invalid comparison between Unknown and I4 //IL_002f: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(name); if ((int)val != -1) { return PickupCatalog.FindPickupIndex(val); } ItemIndex val2 = ItemCatalog.FindItemIndex(name); if ((int)val2 != -1) { return PickupCatalog.FindPickupIndex(val2); } DroneIndex val3 = DroneCatalog.FindDroneIndex(name); if ((int)val3 != -1) { return PickupCatalog.FindPickupIndex(val3); } KeyItemIndex val4 = KeyItemCatalog.FindKeyItemIndex(name); if ((int)val4 != -1) { return PickupCatalog.FindPickupIndex(val4); } return PickupIndex.none; } private static void HandleWarning(ManualLogSource log, string message) { if (log == null) { throw new ArgumentException(message); } log.LogWarning((object)message); } private static bool ParseItemString(string itemString, Dictionary<PickupIndex, int> resolvedItems, ManualLogSource log, bool availableOnly, int index, int repeat, ref bool skippedEntries) { //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: 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) if (string.IsNullOrEmpty(itemString)) { return true; } ItemStringFormat itemStringFormat = ItemStringFormat.DEFAULT; itemString = itemString.Trim(); if (!TryReplaceOuterBraces(itemString, out var replacedString, out var replacements)) { HandleWarning(log, "Unbalanced braces in '" + itemString + "'"); return false; } itemString = replacedString; string[] array; bool flag; if (itemStringFormat == ItemStringFormat.WEIGHTED_OR_ONLY) { array = itemString.Split('|'); flag = false; } else { if (itemString.Contains("&") && itemString.Contains("|")) { HandleWarning(log, "ParseItemStringReward: Cannot have & and | in the same group: '" + itemString + "'"); return false; } if (itemString.Contains("|")) { array = itemString.Split('|'); flag = false; } else { array = itemString.Split('&'); flag = true; } } WeightedSelection<ItemStringEntry> val = new WeightedSelection<ItemStringEntry>(8); List<ItemStringEntry> list = new List<ItemStringEntry>(); for (int i = 0; i < array.Length; i++) { ItemStringEntry itemStringEntry = new ItemStringEntry(); string text = array[i]; string text2 = text.Trim(); string[] array2 = text2.Split(":", 2); text2 = array2[0].Trim(); if (array2.Length > 1 && !float.TryParse(array2[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out itemStringEntry.weight)) { HandleWarning(log, "Cannot parse the weight in segment '" + text.Trim() + "'"); return false; } if (itemStringEntry.weight < 0f) { HandleWarning(log, "The weight cannot be negative in segment '" + text.Trim() + "'"); return false; } if (itemStringFormat == ItemStringFormat.WEIGHTED_OR_ONLY) { itemStringEntry.itemKey = text2; } else { array2 = text2.Split("*", 2); text2 = array2[0].Trim(); if (array2.Length > 1 && !int.TryParse(array2[1].Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out itemStringEntry.multiplier)) { HandleWarning(log, "Cannot parse the multiplier in segment '" + text.Trim() + "'"); return false; } Match match = tokenPattern.Match(text2); if (!match.Success) { HandleWarning(log, "Cannot parse segment '" + text.Trim() + "'"); return false; } if (match.Groups[1].Success && !int.TryParse(match.Groups[1].Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out itemStringEntry.repeat)) { HandleWarning(log, "Cannot parse the amount in segment '" + text.Trim() + "'"); return false; } if (!match.Groups[2].Success) { HandleWarning(log, "Cannot parse segment '" + text.Trim() + "'"); return false; } itemStringEntry.itemKey = match.Groups[2].Value; } val.AddChoice(itemStringEntry, itemStringEntry.weight); list.Add(itemStringEntry); } if (!flag && index < 0 && val.GetTotalWeight() <= 0f) { HandleWarning(log, "All weights are 0 in '" + itemString + "'"); return false; } while (repeat > 0) { PickupIndex key; int value; if (flag) { foreach (ItemStringEntry item in list) { bool skippedEntries2 = false; Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>(); if ((!replacements.ContainsKey(item.itemKey)) ? ResolveItemKey(item.itemKey, item.repeat, dictionary, log, availableOnly) : ParseItemString(replacements[item.itemKey], dictionary, log, availableOnly, -1, item.repeat, ref skippedEntries2)) { foreach (KeyValuePair<PickupIndex, int> item2 in dictionary) { item2.Deconstruct(out key, out value); PickupIndex key2 = key; int num = value; resolvedItems[key2] = resolvedItems.GetValueOrDefault(key2) + num * item.multiplier; } skippedEntries |= skippedEntries2; } else { skippedEntries = true; } } } else { bool flag2 = false; int num2 = 10; int num3 = 0; while (!flag2) { num2--; if (num2 == 0) { HandleWarning(log, "Could not resolve to item rewards: " + itemString); return false; } ItemStringEntry itemStringEntry2 = ((index < 0) ? val.Evaluate(rng.nextNormalizedFloat) : list[(index + num3) % list.Count]); bool skippedEntries3 = false; Dictionary<PickupIndex, int> dictionary2 = new Dictionary<PickupIndex, int>(); flag2 = ((!replacements.ContainsKey(itemStringEntry2.itemKey)) ? ResolveItemKey(itemStringEntry2.itemKey, itemStringEntry2.repeat, dictionary2, log, availableOnly) : ParseItemString(replacements[itemStringEntry2.itemKey], dictionary2, log, availableOnly, -1, itemStringEntry2.repeat, ref skippedEntries3)); if (flag2) { foreach (KeyValuePair<PickupIndex, int> item3 in dictionary2) { item3.Deconstruct(out key, out value); PickupIndex key3 = key; int num4 = value; resolvedItems[key3] = resolvedItems.GetValueOrDefault(key3) + num4 * itemStringEntry2.multiplier; } skippedEntries |= skippedEntries3; } else { num3++; } } } repeat--; } return true; } public static void ParseItemStringStrict(string itemString, Dictionary<PickupIndex, int> resolvedItems, bool availableOnly = true, int index = -1) { bool skippedEntries = false; ParseItemString(itemString, resolvedItems, null, availableOnly, index, 1, ref skippedEntries); } public static bool ParseItemString(string itemString, Dictionary<PickupIndex, int> resolvedItems, ManualLogSource log, bool availableOnly = true, int index = -1) { bool skippedEntries = false; if (ParseItemString(itemString, resolvedItems, log, availableOnly, index, 1, ref skippedEntries)) { return !skippedEntries; } return false; } public static List<UniquePickup> GivePickups(CharacterBody body, Dictionary<PickupIndex, int> pickups) { //IL_004c: 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) //IL_006a: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00ca: 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_00ea: Invalid comparison between Unknown and I4 //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Invalid comparison between Unknown and I4 //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Invalid comparison between Unknown and I4 //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) List<UniquePickup> list = new List<UniquePickup>(); Inventory val = (Object.op_Implicit((Object)(object)body) ? body.inventory : null); if (!NetworkServer.active || !Object.op_Implicit((Object)(object)val) || pickups == null) { return list; } bool flag = false; PickupIndex key; int value; foreach (KeyValuePair<PickupIndex, int> pickup in pickups) { pickup.Deconstruct(out key, out value); PickupIndex val2 = key; int num = value; PickupDef pickupDef = PickupCatalog.GetPickupDef(val2); if (num > 0 && pickupDef != null && (int)pickupDef.itemIndex != -1) { val.GiveItemPermanent(pickupDef.itemIndex, num); flag = true; } } if (flag) { val.RefreshInventoryStateServer(); } bool gaveEquipment = false; foreach (KeyValuePair<PickupIndex, int> pickup2 in pickups) { pickup2.Deconstruct(out key, out value); PickupIndex val3 = key; int num2 = value; PickupDef pickupDef2 = PickupCatalog.GetPickupDef(val3); if (num2 <= 0 || pickupDef2 == null || (int)pickupDef2.itemIndex != -1) { continue; } for (int i = 0; i < num2; i++) { if ((int)pickupDef2.equipmentIndex != -1) { GiveEquipment(val, pickupDef2.equipmentIndex, ref gaveEquipment, list); continue; } if ((int)pickupDef2.keyItemIndex != -1) { KeyItemIndex keyItemIndex = val.GetKeyItemIndex(); val.SetKeyItem(pickupDef2.keyItemIndex); if ((int)keyItemIndex != -1 && keyItemIndex != pickupDef2.keyItemIndex) { list.Add(new UniquePickup(PickupCatalog.FindPickupIndex(keyItemIndex))); } continue; } GrantContext val4 = new GrantContext { body = body, uniquePickup = new UniquePickup(val3), position = body.corePosition, rotation = body.transform.rotation }; AttemptGrantDelegate attemptGrant = pickupDef2.attemptGrant; if (attemptGrant != null) { attemptGrant.Invoke(ref val4); } } } return list; } private static void GiveEquipment(Inventory inventory, EquipmentIndex equipmentIndex, ref bool gaveEquipment, List<UniquePickup> leftOver) { //IL_0010: 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_003d: Unknown result type (might be due to invalid IL or missing references) //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_0048: 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_0055: Invalid comparison between Unknown and I4 //IL_0021: 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_0058: 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_005e: Unknown result type (might be due to invalid IL or missing references) EquipmentLocation val = default(EquipmentLocation); if (inventory.TryFindBestEquipmentLocation(ref emptyEquipmentLocation, ref val)) { inventory.SetEquipmentIndex(equipmentIndex, ref val); gaveEquipment = true; return; } if (gaveEquipment) { leftOver.Add(new UniquePickup(PickupCatalog.FindPickupIndex(equipmentIndex))); return; } val = inventory.FindBestEquipmentLocationOrCurrent(ref EquipmentLocationQueryArgs.defaultPickup); EquipmentIndex equipmentIndex2 = inventory.GetEquipmentIndex(ref val); inventory.SetEquipmentIndex(equipmentIndex, ref val); gaveEquipment = true; if ((int)equipmentIndex2 != -1) { leftOver.Add(new UniquePickup(PickupCatalog.FindPickupIndex(equipmentIndex2))); } } public unsafe static void WriteDropTablesMarkdownFile(string filePath) { //IL_00e9: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: 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_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: 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_0518: 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) using StreamWriter streamWriter = new StreamWriter(filePath); streamWriter.WriteLine("# Survivors"); string[] array = SurvivorCatalog.allSurvivorDefs.Select((SurvivorDef survivor) => survivor.cachedName).ToArray(); foreach (string text in array) { streamWriter.WriteLine(text ?? ""); } streamWriter.WriteLine("# Bodies"); array = BodyCatalog.allBodyPrefabs.Select((GameObject prefab) => ((Object)prefab).name).ToArray(); foreach (string text2 in array) { streamWriter.WriteLine(text2 ?? ""); } streamWriter.WriteLine("# Item Tiers"); streamWriter.WriteLine("Besides the tier keywords, item strings can use these names or the names without TierDef or Def at the end."); Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemTierDef current = enumerator.Current; if (Object.op_Implicit((Object)(object)current)) { streamWriter.WriteLine(((Object)current).name ?? ""); } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } streamWriter.WriteLine("# DropTables"); streamWriter.WriteLine("| Drop Table Name | tier1 | tier2 | tier3 | boss | lunarEquipment | lunarItem | lunarCombined | equipment | voidTier1 | voidTier2 | voidTier3 | voidBoss | foodTier | powerShapes | cursed | hex | page | canDropBeReplaced | requiredItemTags | bannedItemTags |"); streamWriter.WriteLine("|----------------------------------|-------|-------|-------|------|----------------|-----------|---------------|-----------|-----------|-----------|-----------|----------|----------|-------------|--------|-----|------|-------------------|------------------|----------------|"); List<string> list = new List<string>(); List<string> list2 = DropTables.Keys.OrderBy<string, string>((string name) => name, StringComparer.OrdinalIgnoreCase).ToList(); foreach (string item in list2) { PickupDropTable droptable = GetDroptable(item); BasicPickupDropTable val = (BasicPickupDropTable)(object)((droptable is BasicPickupDropTable) ? droptable : null); if (val == null) { list.Add($"| {item,-32} | {((object)droptable).GetType().Name} |"); continue; } string text3 = string.Join(", ", val.requiredItemTags.Select((ItemTag e) => ((object)(*(ItemTag*)(&e))/*cast due to .constrained prefix*/).ToString())); string text4 = string.Join(", ", val.bannedItemTags.Select((ItemTag e) => ((object)(*(ItemTag*)(&e))/*cast due to .constrained prefix*/).ToString())); streamWriter.WriteLine($"| {item,-32} | {val.tier1Weight} | {val.tier2Weight} | {val.tier3Weight} | {val.bossWeight} | {val.lunarEquipmentWeight} | {val.lunarItemWeight} | {val.lunarCombinedWeight} | {val.equipmentWeight} | {val.voidTier1Weight} | {val.voidTier2Weight} | {val.voidTier3Weight} | {val.voidBossWeight} | {val.foodTierWeight} | {val.powerShapesWeight} | {val.cursedWeight} | {val.hexWeight} | {val.pageWeight} | {((PickupDropTable)val).canDropBeReplaced} | {text3} | {text4} |"); } streamWriter.WriteLine("# Other DropTables"); streamWriter.WriteLine("| Drop Table Name | Type |"); streamWriter.WriteLine("|----------------------------------|------|"); foreach (string item2 in list) { streamWriter.WriteLine(item2); } string text5 = string.Join(" | ", list2.Select((string name) => "\"" + name + "\"")); string text6 = ""; ItemIndex val2 = (ItemIndex)0; for (ItemIndex val3 = (ItemIndex)ItemCatalog.itemCount; val2 < val3; val2 = (ItemIndex)(val2 + 1)) { ItemDef itemDef = ItemCatalog.GetItemDef(val2); if (!itemDef.tags.Contains((ItemTag)25) && itemDef.DoesNotContainTag((ItemTag)9)) { text6 = ((!string.IsNullOrWhiteSpace(text6)) ? (text6 + " | \"" + ((Object)itemDef).name + "\"") : ("\"" + ((Object)itemDef).name + "\"")); } } EquipmentIndex val4 = (EquipmentIndex)0; for (EquipmentIndex val5 = (EquipmentIndex)EquipmentCatalog.equipmentCount; val4 < val5; val4 = (EquipmentIndex)(val4 + 1)) { EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val4); if (equipmentDef.canDrop) { text6 = ((!string.IsNullOrWhiteSpace(text6)) ? (text6 + " | \"" + ((Object)equipmentDef).name + "\"") : ("\"" + ((Object)equipmentDef).name + "\"")); } } foreach (DroneDef allDroneDef in DroneCatalog.allDroneDefs) { text6 += (string.IsNullOrWhiteSpace(text6) ? ("\"" + ((Object)allDroneDef).name + "\"") : (" | \"" + ((Object)allDroneDef).name + "\"")); } foreach (KeyItemDef allKeyItemDef in KeyItemCatalog.allKeyItemDefs) { text6 += (string.IsNullOrWhiteSpace(text6) ? ("\"" + ((Object)allKeyItemDef).name + "\"") : (" | \"" + ((Object)allKeyItemDef).name + "\"")); } streamWriter.WriteLine("# EBNF"); streamWriter.WriteLine("```"); streamWriter.WriteLine("<itemname> ::= " + text6); streamWriter.WriteLine("<droptable> ::= " + text5); streamWriter.WriteLine("```"); } } }