using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HG.Reflection; using HarmonyLib; using ItemQualities; using Microsoft.CodeAnalysis; using RiskOfOptions; using RiskOfOptions.Options; using RoR2; using RoR2.Items; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ScrapMe")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+dd0d94e6831e6d6098a0cc3571d58899b30038d1")] [assembly: AssemblyProduct("ScrapMe")] [assembly: AssemblyTitle("ScrapMe")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScrapMe { public class BanRecords { public class CharItemRecord { internal Dictionary> record = new Dictionary>(); public HashSet this[BodyIndex index] { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return GetValue(index); } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) record[index] = value; } } private HashSet GetValue(BodyIndex key) { //IL_0007: 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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!record.ContainsKey(key)) { record[key] = new HashSet(); } return record[key]; } } internal class PresetBans { private readonly string charName; private readonly HashSet itemNames; public PresetBans(string bodyName, IEnumerable itemNames) { charName = bodyName; this.itemNames = new HashSet(itemNames); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public void Resolve() { //IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Invalid comparison between Unknown and I4 //IL_0097: 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_00e1: Unknown result type (might be due to invalid IL or missing references) if (charName == null) { return; } BodyIndex val = BodyCatalog.FindBodyIndex(charName); if ((int)val == -1) { Log.Warning("Couldn't find body matching " + charName + ", skipping"); return; } HashSet hashSet = new HashSet(); foreach (string itemName in itemNames) { ItemIndex val2 = ItemCatalog.FindItemIndex(itemName); if ((int)val2 == -1) { Log.Message("Couldn't find item matching " + itemName + ", skipping"); } else { hashSet.Add(val2); } } ScrapMe.plugin.bans.dev[val].UnionWith(hashSet); if (QualityCompat.enabled) { QualityCompat.SetQualityVariantBans(val); } } } public CharItemRecord dev = new CharItemRecord(); internal CharItemRecord quality = new CharItemRecord(); internal CharItemRecord user = new CharItemRecord(); internal CharItemRecord unbans = new CharItemRecord(); internal static readonly List presets = new List(2) { new PresetBans("RobRavagerBody", new <>z__ReadOnlyArray(new string[2] { "JumpBoost", "JumpDamageStrike" })), new PresetBans("RobBelmontBody", new <>z__ReadOnlyArray(new string[3] { "BarrierOnCooldown", "JumpBoost", "JumpDamageStrike" })) }; internal IEnumerable MappedBodies => dev.record.Keys.Union(quality.record.Keys).Union(user.record.Keys).Union(unbans.record.Keys); public HashSet All(BodyIndex index, bool withQuality = true) { //IL_0007: 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_0040: 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) IEnumerable first = dev[index].Union(user[index]); if (withQuality) { first = first.Union(quality[index]); } return first.Except(unbans[index]).ToHashSet(); } } internal class ConfigManager { public readonly ConfigEntry charNames = ((BaseUnityPlugin)ScrapMe.plugin).Config.Bind("! Main", "Characters to Change", "", "Characters to look for, comma-separated. Must be as prefab names, i.e. CommandoBody."); public readonly Dictionary> itemBans = new Dictionary>(); public readonly Dictionary> itemUnbans = new Dictionary>(); public readonly HashSet mappedChars = new HashSet(); public bool BindBody(string body) { if (!mappedChars.Add(body)) { return false; } ConfigEntry val = ((BaseUnityPlugin)ScrapMe.plugin).Config.Bind("Characters", body + "_ItemBans", "", "Items to auto-scrap for " + body + ", comma-separated, using prefab names, i.e. HealingPotion."); itemBans[body] = val; RiskOfOptionsCompat.CreateConfigEntry(val); ConfigEntry val2 = ((BaseUnityPlugin)ScrapMe.plugin).Config.Bind("Characters", body + "_ItemUnbans", "", "Unbanned items for " + body + ". Use at your own risk; the items were likely banned for a reason."); itemUnbans[body] = val2; RiskOfOptionsCompat.CreateConfigEntry(val2); return true; } public void Load() { //IL_0087: 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_010f: 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_01f0: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)ScrapMe.plugin).Config.SaveOnConfigSet = false; IEnumerable enumerable = from b in charNames.Value.Split(",") select b.Trim() into b where !string.IsNullOrEmpty(b) select b; foreach (string item in enumerable) { BodyIndex val = BodyCatalog.FindBodyIndex(item); BindBody(item); HashSet source = new HashSet(from b in itemBans[item].Value.Split(",") select b.Trim() into b where !string.IsNullOrEmpty(b) select b); ScrapMe.plugin.bans.user[val] = new HashSet(((IEnumerable)source).Select((Func)ItemCatalog.FindItemIndex)); HashSet source2 = new HashSet(from b in itemUnbans[item].Value.Split(",") select b.Trim() into b where !string.IsNullOrEmpty(b) select b); ScrapMe.plugin.bans.unbans[val] = new HashSet(((IEnumerable)source2).Select((Func)ItemCatalog.FindItemIndex)); if (QualityCompat.enabled) { QualityCompat.SetQualityVariantBans(val); } } ((BaseUnityPlugin)ScrapMe.plugin).Config.Save(); ((BaseUnityPlugin)ScrapMe.plugin).Config.SaveOnConfigSet = true; } public void Cleanup() { } public bool UnbindBody(string bodyName) { if (RiskOfOptionsCompat.mappedEntries.Contains(bodyName)) { return false; } ((BaseUnityPlugin)ScrapMe.plugin).Config.Remove(((ConfigEntryBase)itemBans[bodyName]).Definition); ((BaseUnityPlugin)ScrapMe.plugin).Config.Remove(((ConfigEntryBase)itemUnbans[bodyName]).Definition); return true; } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } public static class QualityCompat { private static bool? _enabled; public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SetQualityVariantBans() { //IL_0042: 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_0049: Unknown result type (might be due to invalid IL or missing references) if (!enabled) { return; } ScrapMe.plugin.bans.quality.record.Clear(); foreach (BodyIndex mappedBody in ScrapMe.plugin.bans.MappedBodies) { SetQualityVariantBans(mappedBody); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void SetQualityVariantBans(BodyIndex bodyIndex) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0053: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Invalid comparison between Unknown and I4 //IL_005f: 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_0062: 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) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!enabled) { return; } HashSet hashSet = ScrapMe.plugin.bans.quality[bodyIndex]; hashSet.Clear(); foreach (ItemIndex item in ScrapMe.plugin.bans.All(bodyIndex, withQuality: false)) { for (QualityTier val = (QualityTier)(QualityCatalog.GetQualityTier(item) + 1); (int)val < 4; val = (QualityTier)(val + 1)) { ItemIndex itemIndexOfQuality = QualityCatalog.GetItemIndexOfQuality(item, val); if ((int)itemIndexOfQuality != -1) { hashSet.Add(itemIndexOfQuality); } } } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static ItemIndex CarryQualityToNewItem(ItemIndex oldItem, ItemIndex newItem) { //IL_0011: 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_0017: 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_000d: 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_0027: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0024: 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) if (!enabled) { return newItem; } if (QualityCatalog.GetQualityTier(oldItem) == QualityCatalog.GetQualityTier(newItem)) { return newItem; } return QualityCatalog.GetItemIndexOfQuality(newItem, QualityCatalog.GetQualityTier(oldItem)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static IEnumerable GetQualityVariants(ItemIndex baseItemIndex) { //IL_0016: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected I4, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected I4, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected I4, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected I4, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected I4, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!enabled) { return new <>z__ReadOnlySingleElementList(baseItemIndex); } ItemQualityGroup itemQualityGroup = QualityCatalog.GetItemQualityGroup(QualityCatalog.FindItemQualityGroupIndex(baseItemIndex)); return new <>z__ReadOnlyArray((ItemIndex[])(object)new ItemIndex[5] { (ItemIndex)(int)itemQualityGroup.BaseItemIndex, (ItemIndex)(int)itemQualityGroup.UncommonItemIndex, (ItemIndex)(int)itemQualityGroup.RareItemIndex, (ItemIndex)(int)itemQualityGroup.EpicItemIndex, (ItemIndex)(int)itemQualityGroup.LegendaryItemIndex }); } } public static class RiskOfOptionsCompat { [CompilerGenerated] private static class <>O { public static UnityAction <0>__CreateCurrentBodyEntry; } private static bool? _enabled; internal static readonly HashSet mappedEntries = new HashSet(); public static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void InitConfigMenu() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0043: 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_004e: Expected O, but got Unknown if (enabled) { ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ScrapMe.plugin.configManager.charNames)); object obj = <>O.<0>__CreateCurrentBodyEntry; if (obj == null) { UnityAction val = CreateCurrentBodyEntry; <>O.<0>__CreateCurrentBodyEntry = val; obj = (object)val; } ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Create Entry for Current Character", "! Main", (UnityAction)obj)); ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Apply Changes", "! Main", new UnityAction(ScrapMe.plugin.configManager.Load))); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void CreateCurrentBodyEntry() { IEnumerable enumerable = PlayerCharacterMasterController.instances.Select((PlayerCharacterMasterController b) => ((Object)b.body).name); foreach (string item in enumerable) { string prefabNameFromClone = Utils.GetPrefabNameFromClone(item); if (ScrapMe.plugin.configManager.BindBody(prefabNameFromClone)) { ConfigEntry charNames = ScrapMe.plugin.configManager.charNames; charNames.Value = charNames.Value + "," + prefabNameFromClone; Log.Info("Created entry for body " + prefabNameFromClone); } else { Log.Info("Already had entry for " + prefabNameFromClone + ", skipping"); } } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void CreateConfigEntry(ConfigEntry associated) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown if (enabled) { string key = ((ConfigEntryBase)associated).Definition.Key; if (!mappedEntries.Contains(key)) { ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(associated)); mappedEntries.Add(key); } } } } public static class RoR2EventHooks { public static void Register() { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); ItemTransformation.onItemTransformedServerGlobal += HandleItemTransform; } public static void HandleItemTransform(TryTransformResult result) { //IL_0001: 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) //IL_001b: 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_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_0028: Invalid comparison between Unknown and I4 //IL_0035: 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_008f: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_00e0: 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_00f1: 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_010e: 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_00cc: 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_0131: Unknown result type (might be due to invalid IL or missing references) Inventory inventory = result.inventory; if ((Object)(object)inventory == (Object)null) { return; } ItemIndex itemIndex = result.givenItem.itemIndex; if ((int)itemIndex == -1 || Utils.IsCorrespondingVoidInInv(itemIndex, inventory)) { return; } CharacterMaster component = ((Component)inventory).GetComponent(); if ((Object)(object)component == (Object)null) { return; } CharacterBody body = component.GetBody(); if ((Object)(object)body == (Object)null || !ScrapMe.plugin.bans.All(body.bodyIndex).Contains(itemIndex)) { return; } ItemIndex replacementItem = Utils.GetReplacementItem(itemIndex); if (replacementItem != itemIndex) { if ((int)replacementItem == -1) { Log.Warning($"Replacing transformed item {itemIndex} with no item"); } ItemTransformation val = default(ItemTransformation); ((ItemTransformation)(ref val)).originalItemIndex = itemIndex; ((ItemTransformation)(ref val)).newItemIndex = replacementItem; ((ItemTransformation)(ref val)).maxToTransform = int.MaxValue; val.transformationType = (ItemTransformationTypeIndex)(-1); ItemTransformation val2 = val; TryTransformResult val3 = default(TryTransformResult); if (!((ItemTransformation)(ref val2)).TryTransform(inventory, ref val3)) { Log.Warning($"Failed to replace transformed item {itemIndex} with {replacementItem}"); } } } public static void OnLoad() { ScrapMe plugin = ScrapMe.plugin; plugin.PresetBans(); plugin.configManager.Load(); RiskOfOptionsCompat.InitConfigMenu(); } } internal static class RoR2Patches { [HarmonyPatch(typeof(GenericPickupController), "AttemptGrant")] [HarmonyPrefix] public static void ReplaceWithScrapIfBannedForChar(CharacterBody body, GenericPickupController __instance, bool __runOriginal) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_00fb: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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) //IL_0142: 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_015c: 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) if (!__runOriginal || (Object)(object)__instance == (Object)null || (Object)(object)body == (Object)null) { return; } HashSet hashSet = ScrapMe.plugin.bans.All(body.bodyIndex); if (hashSet.Count == 0) { return; } UniquePickup pickup = __instance.pickup; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { return; } Log.Debug(((Object)body).name + " picking up " + pickupDef.internalName); if (hashSet.Contains(pickupDef.itemIndex) && !((Object)(object)body.inventory == (Object)null) && !Utils.IsCorrespondingVoidInInv(pickupDef.itemIndex, body.inventory)) { ItemIndex replacementItem = Utils.GetReplacementItem(pickupDef.itemIndex); if ((int)replacementItem != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(replacementItem); PickupIndex val = PickupCatalog.FindPickupIndex(itemDef.itemIndex); Log.Info($"Replacing {pickupDef.internalName} with {((Object)itemDef).name} (index {val})"); __instance.pickup = new UniquePickup { pickupIndex = val, decayValue = __instance.pickup.decayValue, upgradeValue = __instance.pickup.upgradeValue }; } } } } [BepInPlugin("not_score.ScrapMe", "ScrapMe", "0.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ScrapMe : BaseUnityPlugin { public static ScrapMe plugin; public const string PluginGUID = "not_score.ScrapMe"; public const string PluginAuthor = "not_score"; public const string PluginName = "ScrapMe"; public const string PluginVersion = "0.3.0"; internal ConfigManager configManager; internal readonly BanRecords bans = new BanRecords(); internal void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown plugin = this; Log.Init(((BaseUnityPlugin)this).Logger); Harmony val = new Harmony("not_score.ScrapMe"); val.PatchAll(typeof(RoR2Patches)); configManager = new ConfigManager(); RoR2EventHooks.Register(); } public HashSet GetDevBans(BodyIndex bodyIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) return ((int)bodyIndex == -1) ? null : bans.dev[bodyIndex]; } internal void PresetBans() { BanRecords.presets.ForEach(delegate(BanRecords.PresetBans preset) { preset.Resolve(); }); } } public static class Utils { private static Dictionary scrapLookup = new Dictionary(); [Obsolete] public static string GetPrefabNameFromItem(string itemName) { return itemName.Substring(itemName.IndexOf("Index.") + 6); } public static ItemIndex GetScrapForTier(ItemTier tier) { //IL_0006: 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_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_0017: 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_001a: 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_0049: Expected I4, but got Unknown //IL_00f1: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) if (!scrapLookup.ContainsKey(tier)) { switch ((int)tier) { case 3: scrapLookup[tier] = ItemCatalog.FindItemIndex("Pearl"); break; case 0: case 6: scrapLookup[tier] = ItemCatalog.FindItemIndex("ScrapWhite"); break; case 1: case 7: scrapLookup[tier] = ItemCatalog.FindItemIndex("ScrapGreen"); break; case 2: case 8: scrapLookup[tier] = ItemCatalog.FindItemIndex("ScrapRed"); break; case 4: case 9: scrapLookup[tier] = ItemCatalog.FindItemIndex("ScrapYellow"); break; default: Log.Error("Failed to find appropriate replacement for item in tier " + ((Object)ItemTierCatalog.GetItemTierDef(tier)).name); return (ItemIndex)0; } } return scrapLookup[tier]; } public static ItemIndex GetReplacementItem(ItemIndex item) { //IL_0001: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0027: 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_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_0023: 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) ItemIndex scrapForTier = GetScrapForTier(ItemCatalog.GetItemDef(item).tier); if (QualityCompat.enabled) { return QualityCompat.CarryQualityToNewItem(item, scrapForTier); } return scrapForTier; } public static string GetPrefabNameFromClone(string cloneName) { return cloneName.Substring(0, cloneName.LastIndexOf("(Clone)")); } public static string SanitizePrefabName(string prefabName) { return prefabName; } public static void CheckInventory(CharacterBody body) { //IL_001c: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) //IL_006d: 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_00a0: 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_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null) { return; } HashSet hashSet = ScrapMe.plugin.bans.All(body.bodyIndex); foreach (ItemIndex item in hashSet) { int itemCountPermanent = body.inventory.GetItemCountPermanent(item); if (itemCountPermanent > 0) { body.inventory.RemoveItemPermanent(item, itemCountPermanent); body.inventory.GiveItemPermanent(GetReplacementItem(item), itemCountPermanent); } float tempItemRawValue = body.inventory.GetTempItemRawValue(item); if (tempItemRawValue > 0f) { body.inventory.RemoveItemTemp(item, (float)(int)Math.Ceiling(tempItemRawValue)); body.inventory.GiveItemTemp(GetReplacementItem(item), tempItemRawValue); } } } public static bool IsCorrespondingVoidInInv(ItemIndex item, Inventory inv) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) return GetCorrespondingVoids(item).Any((ItemIndex i) => (int)i != -1 && inv.GetItemCountEffective(i) > 0); } internal static IEnumerable GetCorrespondingVoids(ItemIndex corruptionCheck) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 //IL_002a: 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) ItemIndex transformedItemIndex = ContagiousItemManager.GetTransformedItemIndex(corruptionCheck); if ((int)transformedItemIndex == -1) { return Array.Empty(); } if (QualityCompat.enabled) { return QualityCompat.GetQualityVariants(transformedItemIndex); } return new <>z__ReadOnlySingleElementList(transformedItemIndex); } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; 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.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] 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 ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator { object IEnumerator.Current => _item; T IEnumerator.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { return !_moveNextCalled && (_moveNextCalled = true); } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => 1; T IReadOnlyList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection.Count => 1; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { return (!EqualityComparer.Default.Equals(_item, (T)value)) ? (-1) : 0; } 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 new Enumerator(_item); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return EqualityComparer.Default.Equals(_item, item); } void ICollection.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return (!EqualityComparer.Default.Equals(_item, item)) ? (-1) : 0; } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } }