Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of PersonalizedItemReplacement v1.0.2
PersonalizedItemReplacement.dll
Decompiled 2 years agousing System; 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.Configuration; using Microsoft.CodeAnalysis; using On.RoR2; using On.RoR2.Items; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("PersonalizedItemReplacement")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PersonalizedItemReplacement")] [assembly: AssemblyTitle("PersonalizedItemReplacement")] [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 PersonalizedItemReplacement { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("GiGaGon.PersonalizedItemReplacement", "PersonalizedItemReplacement", "1.0.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class PersonalizedItemReplacement : BaseUnityPlugin { internal class ModConfig { public static ConfigEntry<float> e_percent; public static void InitConfig(ConfigFile config) { //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_0035: 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_0050: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown e_percent = config.Bind<float>("General", "Chance per Eulogy Zero stack", 0.05f, "Chance of item replacement per Eulogy Zero stack. Supports in-game modifications."); ModSettingsManager.AddOption((BaseOption)new StepSliderOption(e_percent, new StepSliderConfig { min = 0f, max = 1f, increment = 0.01f })); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_CanReplace <>9__6_0; public static hook_GiveItem_ItemIndex_int <>9__6_1; internal bool <Awake>b__6_0(orig_CanReplace orig, PickupDef pickupDef) { return false; } internal void <Awake>b__6_1(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_003b: 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: Invalid comparison between Unknown and I4 //IL_011f: 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_00d4: 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_00f3: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass6_0 CS$<>8__locals0 = new <>c__DisplayClass6_0 { self = self }; CharacterBody val = CharacterBody.readOnlyInstancesList.ToList().Find((CharacterBody x) => (Object)(object)x.inventory == (Object)(object)CS$<>8__locals0.self); int itemCount = CS$<>8__locals0.self.GetItemCount(Items.RandomlyLunar); ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); if ((Object)(object)val != (Object)null && itemCount > 0 && (int)itemDef.tier != 3 && itemDef.DoesNotContainTag((ItemTag)10)) { if ((Object)(object)Run.instance != (Object)null) { float nextNormalizedFloat = Run.instance.runRNG.nextNormalizedFloat; float num = ModConfig.e_percent.Value * (float)itemCount; if (nextNormalizedFloat < num) { List<PickupIndex> availableLunarCombinedDropList = Run.instance.availableLunarCombinedDropList; PickupDropletController.CreatePickupDroplet(availableLunarCombinedDropList[Run.instance.runRNG.RangeInt(0, availableLunarCombinedDropList.Count)], val.transform.position, new Vector3(0f, 0f, 0f)); } else { orig.Invoke(CS$<>8__locals0.self, itemIndex, count); } } } else { orig.Invoke(CS$<>8__locals0.self, itemIndex, count); } } } [CompilerGenerated] private sealed class <>c__DisplayClass6_0 { public Inventory self; internal bool <Awake>b__2(CharacterBody x) { return (Object)(object)x.inventory == (Object)(object)self; } } public const string PluginGUID = "GiGaGon.PersonalizedItemReplacement"; public const string PluginAuthor = "GiGaGon"; public const string PluginName = "PersonalizedItemReplacement"; public const string PluginVersion = "1.0.0"; public static ConfigFile PIP_cfg = new ConfigFile(Paths.ConfigPath + "\\GiGaGon.PersonalizedItemReplacement.cfg", true); public void Awake() { //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_002b: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown ModConfig.InitConfig(PIP_cfg); object obj = <>c.<>9__6_0; if (obj == null) { hook_CanReplace val = (orig_CanReplace orig, PickupDef pickupDef) => false; <>c.<>9__6_0 = val; obj = (object)val; } RandomlyLunarUtils.CanReplace += (hook_CanReplace)obj; object obj2 = <>c.<>9__6_1; if (obj2 == null) { hook_GiveItem_ItemIndex_int val2 = delegate(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_003b: 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: Invalid comparison between Unknown and I4 //IL_011f: 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_00d4: 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_00f3: Unknown result type (might be due to invalid IL or missing references) CharacterBody val3 = CharacterBody.readOnlyInstancesList.ToList().Find((CharacterBody x) => (Object)(object)x.inventory == (Object)(object)self); int itemCount = self.GetItemCount(Items.RandomlyLunar); ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); if ((Object)(object)val3 != (Object)null && itemCount > 0 && (int)itemDef.tier != 3 && itemDef.DoesNotContainTag((ItemTag)10)) { if ((Object)(object)Run.instance != (Object)null) { float nextNormalizedFloat = Run.instance.runRNG.nextNormalizedFloat; float num = ModConfig.e_percent.Value * (float)itemCount; if (nextNormalizedFloat < num) { List<PickupIndex> availableLunarCombinedDropList = Run.instance.availableLunarCombinedDropList; PickupDropletController.CreatePickupDroplet(availableLunarCombinedDropList[Run.instance.runRNG.RangeInt(0, availableLunarCombinedDropList.Count)], val3.transform.position, new Vector3(0f, 0f, 0f)); } else { orig.Invoke(self, itemIndex, count); } } } else { orig.Invoke(self, itemIndex, count); } }; <>c.<>9__6_1 = val2; obj2 = (object)val2; } Inventory.GiveItem_ItemIndex_int += (hook_GiveItem_ItemIndex_int)obj2; } } }