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 HarmonyLib; using ItemQualities; using JetBrains.Annotations; 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: 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+223fb6674917a65fa2f3931ca593f052ebad0bea")] [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 { 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 Dictionary> equipBans = new Dictionary>(); public readonly Dictionary> equipUnbans = new Dictionary>(); public readonly HashSet mappedChars = new HashSet(); public bool BindBody(string body) { ConfigFile config = ((BaseUnityPlugin)ScrapMe.plugin).Config; if (!mappedChars.Add(body)) { return false; } EventHandler eventHandler = OnBodyBansChanged(body); ConfigEntry val = config.Bind(body, "Item Bans", "", "Items to auto-scrap for " + body + ", comma-separated, using prefab names, i.e. HealingPotion."); itemBans[body] = val; val.SettingChanged += eventHandler; ConfigEntry val2 = config.Bind(body, "Item Unbans", "", "Unbanned items for " + body + ". Use at your own risk; the items were likely banned for a reason."); itemUnbans[body] = val2; val2.SettingChanged += eventHandler; ConfigEntry val3 = config.Bind(body, "Equip Bans", "", "Banned equipment for " + body + ", comma-separated, using prefab names."); equipBans[body] = val3; val3.SettingChanged += eventHandler; ConfigEntry val4 = config.Bind(body, "Equip Unbans", "", "Unbanned equipment for " + body + ". Use at your own risk; the equips were likely banned for a reason."); equipUnbans[body] = val4; val4.SettingChanged += eventHandler; if (RiskOfOptionsCompat.enabled) { RiskOfOptionsCompat instance = RiskOfOptionsCompat.instance; instance?.CreateConfigEntry(val); instance?.CreateConfigEntry(val2); instance?.CreateConfigEntry(val3); instance?.CreateConfigEntry(val4); } return true; } public void Load() { ConfigFile config = ((BaseUnityPlugin)ScrapMe.plugin).Config; 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) { CalcBans(item); } config.Save(); config.SaveOnConfigSet = true; } public void Cleanup() { } public bool UnbindBody(string bodyName) { if (!mappedChars.Remove(bodyName)) { return false; } ConfigFile config = ((BaseUnityPlugin)ScrapMe.plugin).Config; config.Remove(((ConfigEntryBase)itemBans[bodyName]).Definition); config.Remove(((ConfigEntryBase)itemUnbans[bodyName]).Definition); config.Remove(((ConfigEntryBase)equipBans[bodyName]).Definition); config.Remove(((ConfigEntryBase)equipUnbans[bodyName]).Definition); return true; } internal void CalcBans(string bodyName) { //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_0026: 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_0082: 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_00de: Unknown result type (might be due to invalid IL or missing references) BodyIndex val = BodyCatalog.FindBodyIndex(bodyName); BindBody(bodyName); ScrapMe.BanTracker bans = ScrapMe.plugin.bans; bans.items.user[val] = StringToItemIndices(itemBans[bodyName].Value).ToHashSet(); bans.items.unbans[val] = StringToItemIndices(itemUnbans[bodyName].Value).ToHashSet(); bans.equip.user[val] = StringToEquipIndices(equipBans[bodyName].Value).ToHashSet(); bans.equip.unbans[val] = StringToEquipIndices(equipUnbans[bodyName].Value).ToHashSet(); QualityModule.Instance?.SetQualityVariantBans(val); } internal EventHandler OnBodyBansChanged(string bodyName) { return delegate { CalcBans(bodyName); }; } internal IEnumerable StringToItemIndices(string items) { return (from b in items.Split(",") select b.Trim() into b where !string.IsNullOrEmpty(b) select b).Select((Func)ItemCatalog.FindItemIndex); } internal IEnumerable StringToEquipIndices(string equips) { return (from b in equips.Split(",") select b.Trim() into b where !string.IsNullOrEmpty(b) select b).Select((Func)EquipmentCatalog.FindEquipmentIndex); } } public class EquipmentBans { public class CharRecord { internal readonly 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 CharRecord() { } } internal class PresetBans { private readonly string charName; private readonly HashSet equipNames; public PresetBans(string bodyName, IEnumerable equipNames) { charName = bodyName; this.equipNames = new HashSet(equipNames); } [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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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 equipName in equipNames) { EquipmentIndex val2 = EquipmentCatalog.FindEquipmentIndex(equipName); if ((int)val2 == -1) { Log.Message("Couldn't find equip matching " + equipName + ", skipping"); } else { hashSet.Add(val2); } } ScrapMe.plugin.bans.equip.dev[val].UnionWith(hashSet); QualityModule.Instance?.SetQualityEquipVariantBans(val); } } public CharRecord dev = new CharRecord(); internal CharRecord quality = new CharRecord(); internal CharRecord user = new CharRecord(); internal CharRecord unbans = new CharRecord(); internal static readonly List presets = new List(1) { new PresetBans("_TurretlingSurvivorBody", new <>z__ReadOnlySingleElementList("GummyClone")) }; 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(); } } public class ItemBans { public class CharRecord { internal readonly 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 CharRecord() { } } 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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.items.dev[val].UnionWith(hashSet); QualityModule.Instance?.SetQualityItemVariantBans(val); } } public CharRecord dev = new CharRecord(); internal CharRecord quality = new CharRecord(); internal CharRecord user = new CharRecord(); internal CharRecord unbans = new CharRecord(); internal static readonly List presets = new List(3) { new PresetBans("RobRavagerBody", new <>z__ReadOnlySingleElementList("JumpDamageStrike")), new PresetBans("RobBelmontBody", new <>z__ReadOnlyArray(new string[2] { "BarrierOnCooldown", "JumpDamageStrike" })), new PresetBans("RobDanteBody", new <>z__ReadOnlySingleElementList("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 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 class QualityModule { private static bool? _enabled; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] [CanBeNull] private static QualityModule k__BackingField; public static bool enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities"); _enabled = valueOrDefault; } return _enabled.Value; } } [CanBeNull] public static QualityModule Instance { get { if (enabled && k__BackingField == null) { k__BackingField = new QualityModule(); } return k__BackingField; } } public void SetQualityVariantBans() { SetQualityEquipVariantBans(); SetQualityItemVariantBans(); } public void SetQualityVariantBans(BodyIndex bodyIndex) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) SetQualityEquipVariantBans(bodyIndex); SetQualityItemVariantBans(bodyIndex); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public void SetQualityItemVariantBans() { //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_0046: Unknown result type (might be due to invalid IL or missing references) ScrapMe.plugin.bans.items.quality.record.Clear(); foreach (BodyIndex mappedBody in ScrapMe.plugin.bans.items.MappedBodies) { SetQualityItemVariantBans(mappedBody); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public void SetQualityItemVariantBans(BodyIndex bodyIndex) { //IL_0017: 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_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_003f: 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_0046: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_004c: 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_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0064: 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_0070: 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) ItemBans items = ScrapMe.plugin.bans.items; HashSet hashSet = items.quality[bodyIndex]; hashSet.Clear(); foreach (ItemIndex item in items.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)] public void SetQualityEquipVariantBans() { //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_0046: Unknown result type (might be due to invalid IL or missing references) ScrapMe.plugin.bans.equip.quality.record.Clear(); foreach (BodyIndex mappedBody in ScrapMe.plugin.bans.equip.MappedBodies) { SetQualityItemVariantBans(mappedBody); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public void SetQualityEquipVariantBans(BodyIndex bodyIndex) { //IL_0017: 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_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_003f: 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_0046: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_004c: 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_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Invalid comparison between Unknown and I4 //IL_0064: 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_0070: 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) EquipmentBans equip = ScrapMe.plugin.bans.equip; HashSet hashSet = equip.quality[bodyIndex]; hashSet.Clear(); foreach (EquipmentIndex item in equip.All(bodyIndex, withQuality: false)) { for (QualityTier val = (QualityTier)(QualityCatalog.GetQualityTier(item) + 1); (int)val < 4; val = (QualityTier)(val + 1)) { EquipmentIndex equipmentIndexOfQuality = QualityCatalog.GetEquipmentIndexOfQuality(item, val); if ((int)equipmentIndexOfQuality != -1) { hashSet.Add(equipmentIndexOfQuality); } } } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public ItemIndex CarryQualityToNewItem(ItemIndex oldItem, ItemIndex newItem) { //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_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_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_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references) if (QualityCatalog.GetQualityTier(oldItem) == QualityCatalog.GetQualityTier(newItem)) { return newItem; } return QualityCatalog.GetItemIndexOfQuality(newItem, QualityCatalog.GetQualityTier(oldItem)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public IEnumerable GetQualityVariants(ItemIndex baseItemIndex) { //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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected I4, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected I4, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected I4, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected I4, but got Unknown //IL_001e: 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) ItemQualityGroup itemQualityGroup = QualityCatalog.GetItemQualityGroup(QualityCatalog.FindItemQualityGroupIndex(baseItemIndex)); if ((Object)(object)itemQualityGroup == (Object)null) { Log.Error($"Could not find corresponding item quality group for item {baseItemIndex}"); return new <>z__ReadOnlySingleElementList(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 class RiskOfOptionsCompat { private static bool? _enabled; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static RiskOfOptionsCompat k__BackingField; internal readonly HashSet mappedEntries = new HashSet(); public static bool enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); _enabled = valueOrDefault; } return _enabled.Value; } } [CanBeNull] public static RiskOfOptionsCompat instance { get { if (enabled && k__BackingField == null) { k__BackingField = new RiskOfOptionsCompat(); } return k__BackingField; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal void InitConfigMenu() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ScrapMe.plugin.configManager.charNames)); ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Create Entry for Current Character", "! Main", new UnityAction(CreateCurrentBodyEntry))); ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("Apply Changes", "! Main", new UnityAction(ScrapMe.plugin.configManager.Load))); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal void CreateCurrentBodyEntry() { IEnumerable enumerable = PlayerCharacterMasterController.instances.Select((PlayerCharacterMasterController b) => ((Object)b.body).name); ConfigManager configManager = ScrapMe.plugin.configManager; foreach (string item in enumerable) { string prefabNameFromClone = Utils.GetPrefabNameFromClone(item); if (configManager.BindBody(prefabNameFromClone)) { ConfigEntry charNames = 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 void CreateConfigEntry(ConfigEntry associated) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Invalid comparison between Unknown and I4 //IL_00dd: 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_00e0: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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.items.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 = Utils.MakeTransform(replacementItem, itemIndex); TryTransformResult val2 = default(TryTransformResult); if (!((ItemTransformation)(ref val)).TryTransform(inventory, ref val2)) { Log.Warning($"Failed to replace transformed item {itemIndex} with {replacementItem}"); } } } public static void OnLoad() { ScrapMe plugin = ScrapMe.plugin; plugin.PresetBans(); plugin.configManager.Load(); RiskOfOptionsCompat.instance?.InitConfigMenu(); } } internal static class RoR2Patches { [HarmonyPatch(typeof(GenericPickupController), "AttemptGrant")] [HarmonyPrefix] public static void ReplaceWithScrapIfBannedForChar(CharacterBody body, GenericPickupController __instance, ref bool __runOriginal) { //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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 //IL_0055: 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_006c: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_014c: 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_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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Invalid comparison between Unknown and I4 //IL_0181: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_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_01e3: 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) if (!__runOriginal || (Object)(object)__instance == (Object)null || (Object)(object)body == (Object)null) { return; } UniquePickup pickup = __instance.pickup; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null) { return; } if ((int)pickupDef.equipmentIndex != -1) { EquipmentIndex equipmentIndex = pickupDef.equipmentIndex; HashSet hashSet = ScrapMe.plugin.bans.equip.All(body.bodyIndex); if (hashSet.Contains(equipmentIndex)) { Log.Warning($"Attempting to pick up banned equipment {equipmentIndex} for character {((Object)body).name}, rejecting."); __runOriginal = false; } } else { if ((int)pickupDef.itemIndex == -1) { return; } HashSet hashSet2 = ScrapMe.plugin.bans.items.All(body.bodyIndex); if (hashSet2.Count == 0) { return; } Log.Debug(((Object)body).name + " picking up " + pickupDef.internalName); if (hashSet2.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.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ScrapMe : BaseUnityPlugin { public class BanTracker { public readonly EquipmentBans equip = new EquipmentBans(); public readonly ItemBans items = new ItemBans(); } public static ScrapMe plugin; public readonly BanTracker bans = new BanTracker(); public const string PluginGUID = "not_score.ScrapMe"; public const string PluginAuthor = "not_score"; public const string PluginName = "ScrapMe"; public const string PluginVersion = "0.5.0"; internal ConfigManager configManager; 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(); } [Obsolete("Use bans.items.dev[bodyIndex] instead")] [CanBeNull] 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_0014: Unknown result type (might be due to invalid IL or missing references) return ((int)bodyIndex == -1) ? null : bans.items.dev[bodyIndex]; } internal void PresetBans() { ItemBans.presets.ForEach(delegate(ItemBans.PresetBans preset) { preset.Resolve(); }); } } public static class Utils { private static Dictionary scrapLookup = new Dictionary(); 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)(-1); } } 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_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_0020: 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_0025: 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) ItemIndex scrapForTier = GetScrapForTier(ItemCatalog.GetItemDef(item).tier); return QualityModule.Instance?.CarryQualityToNewItem(item, scrapForTier) ?? 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_0038: 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_0056: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0080: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) if ((Object)(object)body == (Object)null) { return; } Inventory inventory = body.inventory; if ((Object)(object)inventory == (Object)null) { return; } HashSet hashSet = ScrapMe.plugin.bans.items.All(body.bodyIndex); TryTransformResult val2 = default(TryTransformResult); foreach (ItemIndex item in hashSet) { if (body.inventory.GetItemCountEffective(item) != 0) { ItemIndex replacementItem = GetReplacementItem(item); ItemTransformation val = MakeTransform(item, replacementItem); if (!((ItemTransformation)(ref val)).TryTransform(inventory, ref val2)) { Log.Warning($"Failed to replace transformed item {item} with {replacementItem}"); } } } } public static ItemTransformation MakeTransform(ItemIndex from, ItemIndex to) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_002b: 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_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) ItemTransformation result = default(ItemTransformation); ((ItemTransformation)(ref result)).originalItemIndex = from; ((ItemTransformation)(ref result)).newItemIndex = to; ((ItemTransformation)(ref result)).maxToTransform = int.MaxValue; result.transformationType = (ItemTransformationTypeIndex)(-1); return result; } public static bool IsCorrespondingVoidInInv(ItemIndex item, Inventory inv) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)inv == (Object)null) { return true; } return GetCorrespondingVoids(item).Any((ItemIndex i) => (int)i != -1 && inv.GetItemCountEffective(i) > 0); } [NotNull] public static IEnumerable GetCorrespondingVoids(ItemIndex baseItem) { //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_0024: 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) ItemIndex transformedItemIndex = ContagiousItemManager.GetTransformedItemIndex(baseItem); if ((int)transformedItemIndex == -1) { return Array.Empty(); } return QualityModule.Instance?.GetQualityVariants(transformedItemIndex) ?? 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(); } }