using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using On.RoR2;
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: AssemblyTitle("ok")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ok")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3c9913da-dd36-4e3d-8731-3f1a7ecb3505")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RandomItemQuantity;
[BepInPlugin("com.beeru.randomitemquantity", "RandomItemQuantity", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class RandomItemQuantityMod : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static IsDisabledDelegate <>9__41_0;
public static IsDisabledDelegate <>9__41_1;
public static IsDisabledDelegate <>9__41_2;
public static IsDisabledDelegate <>9__41_3;
public static IsDisabledDelegate <>9__41_4;
public static IsDisabledDelegate <>9__41_5;
public static IsDisabledDelegate <>9__41_6;
public static IsDisabledDelegate <>9__41_7;
internal bool <Awake>b__41_0()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_1()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_2()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_3()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_4()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_5()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_6()
{
return !enableMod.Value;
}
internal bool <Awake>b__41_7()
{
return !enableMod.Value;
}
}
public const string PluginGUID = "com.beeru.randomitemquantity";
public const string PluginName = "RandomItemQuantity";
public const string PluginVersion = "1.1.0";
public static ManualLogSource logger;
private static Random rng = new Random();
public static ConfigEntry<bool> enableMod { get; set; }
public static ConfigEntry<float> minQuantity { get; set; }
public static ConfigEntry<float> maxQuantity { get; set; }
public static ConfigEntry<float> speedItemCap { get; set; }
public static ConfigEntry<bool> affectWhiteItems { get; set; }
public static ConfigEntry<bool> affectGreenItems { get; set; }
public static ConfigEntry<bool> affectRedItems { get; set; }
public static ConfigEntry<bool> affectYellowItems { get; set; }
public static ConfigEntry<bool> affectLunarItems { get; set; }
public void Awake()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Expected O, but got Unknown
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Expected O, but got Unknown
//IL_02f0: Expected O, but got Unknown
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Expected O, but got Unknown
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Expected O, but got Unknown
//IL_0335: Expected O, but got Unknown
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Expected O, but got Unknown
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Expected O, but got Unknown
//IL_037a: Expected O, but got Unknown
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_037f: Expected O, but got Unknown
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Expected O, but got Unknown
//IL_03bf: Expected O, but got Unknown
//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Expected O, but got Unknown
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03af: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Expected O, but got Unknown
//IL_0404: Expected O, but got Unknown
//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0409: Expected O, but got Unknown
//IL_040f: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Unknown result type (might be due to invalid IL or missing references)
//IL_041f: Unknown result type (might be due to invalid IL or missing references)
//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Expected O, but got Unknown
//IL_0449: Expected O, but got Unknown
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Expected O, but got Unknown
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Unknown result type (might be due to invalid IL or missing references)
//IL_046f: Unknown result type (might be due to invalid IL or missing references)
//IL_047b: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Expected O, but got Unknown
//IL_04b0: Expected O, but got Unknown
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04b5: Expected O, but got Unknown
//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
//IL_04f5: Expected O, but got Unknown
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Expected O, but got Unknown
logger = ((BaseUnityPlugin)this).Logger;
enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, (ConfigDescription)null);
minQuantity = ((BaseUnityPlugin)this).Config.Bind<float>("Quantity", "Min", 1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
maxQuantity = ((BaseUnityPlugin)this).Config.Bind<float>("Quantity", "Max", 50f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
speedItemCap = ((BaseUnityPlugin)this).Config.Bind<float>("Items", "Speed Item Cap", 10f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
affectWhiteItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "White", true, (ConfigDescription)null);
affectGreenItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Green", true, (ConfigDescription)null);
affectRedItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Red", true, (ConfigDescription)null);
affectYellowItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Boss", true, (ConfigDescription)null);
affectLunarItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Lunar", false, (ConfigDescription)null);
if (minQuantity.Value < 1f)
{
minQuantity.Value = 1f;
}
if (maxQuantity.Value > 1000f)
{
maxQuantity.Value = 1000f;
}
if (minQuantity.Value > maxQuantity.Value)
{
minQuantity.Value = maxQuantity.Value;
}
Sprite val = LoadIcon();
if ((Object)(object)val != (Object)null)
{
ModSettingsManager.SetModIcon(val);
}
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enableMod, new CheckBoxConfig
{
description = "Toggle On/Off"
}));
ConfigEntry<float> obj = minQuantity;
SliderConfig val2 = new SliderConfig
{
min = 1f,
max = 1000f,
FormatString = "{0:0}",
description = "Min Quantity to recieve"
};
object obj2 = <>c.<>9__41_0;
if (obj2 == null)
{
IsDisabledDelegate val3 = () => !enableMod.Value;
<>c.<>9__41_0 = val3;
obj2 = (object)val3;
}
((BaseOptionConfig)val2).checkIfDisabled = (IsDisabledDelegate)obj2;
ModSettingsManager.AddOption((BaseOption)new SliderOption(obj, val2));
ConfigEntry<float> obj3 = maxQuantity;
SliderConfig val4 = new SliderConfig
{
min = 1f,
max = 1000f,
FormatString = "{0:0}",
description = "Max Quantity to recieve"
};
object obj4 = <>c.<>9__41_1;
if (obj4 == null)
{
IsDisabledDelegate val5 = () => !enableMod.Value;
<>c.<>9__41_1 = val5;
obj4 = (object)val5;
}
((BaseOptionConfig)val4).checkIfDisabled = (IsDisabledDelegate)obj4;
ModSettingsManager.AddOption((BaseOption)new SliderOption(obj3, val4));
ConfigEntry<bool> obj5 = affectWhiteItems;
CheckBoxConfig val6 = new CheckBoxConfig
{
description = "Enable/Disable Randomness for White Items"
};
object obj6 = <>c.<>9__41_2;
if (obj6 == null)
{
IsDisabledDelegate val7 = () => !enableMod.Value;
<>c.<>9__41_2 = val7;
obj6 = (object)val7;
}
((BaseOptionConfig)val6).checkIfDisabled = (IsDisabledDelegate)obj6;
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj5, val6));
ConfigEntry<bool> obj7 = affectGreenItems;
CheckBoxConfig val8 = new CheckBoxConfig
{
description = "Enable/Disable Randomness for Green Items"
};
object obj8 = <>c.<>9__41_3;
if (obj8 == null)
{
IsDisabledDelegate val9 = () => !enableMod.Value;
<>c.<>9__41_3 = val9;
obj8 = (object)val9;
}
((BaseOptionConfig)val8).checkIfDisabled = (IsDisabledDelegate)obj8;
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj7, val8));
ConfigEntry<bool> obj9 = affectRedItems;
CheckBoxConfig val10 = new CheckBoxConfig
{
description = "Enable/Disable Randomness for Red Items"
};
object obj10 = <>c.<>9__41_4;
if (obj10 == null)
{
IsDisabledDelegate val11 = () => !enableMod.Value;
<>c.<>9__41_4 = val11;
obj10 = (object)val11;
}
((BaseOptionConfig)val10).checkIfDisabled = (IsDisabledDelegate)obj10;
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj9, val10));
ConfigEntry<bool> obj11 = affectYellowItems;
CheckBoxConfig val12 = new CheckBoxConfig
{
description = "Enable/Disable Randomness for Yellow Items"
};
object obj12 = <>c.<>9__41_5;
if (obj12 == null)
{
IsDisabledDelegate val13 = () => !enableMod.Value;
<>c.<>9__41_5 = val13;
obj12 = (object)val13;
}
((BaseOptionConfig)val12).checkIfDisabled = (IsDisabledDelegate)obj12;
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj11, val12));
ConfigEntry<bool> obj13 = affectLunarItems;
CheckBoxConfig val14 = new CheckBoxConfig
{
description = "Enable/Disable Randomness for Lunar Items"
};
object obj14 = <>c.<>9__41_6;
if (obj14 == null)
{
IsDisabledDelegate val15 = () => !enableMod.Value;
<>c.<>9__41_6 = val15;
obj14 = (object)val15;
}
((BaseOptionConfig)val14).checkIfDisabled = (IsDisabledDelegate)obj14;
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(obj13, val14));
ConfigEntry<float> obj15 = speedItemCap;
SliderConfig val16 = new SliderConfig
{
min = 1f,
max = 1000f,
FormatString = "{0:0}",
description = "Modify amount of speed items (dlc items don't work like Mocha or Hunter's Harpoon)"
};
object obj16 = <>c.<>9__41_7;
if (obj16 == null)
{
IsDisabledDelegate val17 = () => !enableMod.Value;
<>c.<>9__41_7 = val17;
obj16 = (object)val17;
}
((BaseOptionConfig)val16).checkIfDisabled = (IsDisabledDelegate)obj16;
ModSettingsManager.AddOption((BaseOption)new SliderOption(obj15, val16));
minQuantity.SettingChanged += OnQuantityChanged;
maxQuantity.SettingChanged += OnQuantityChanged;
Inventory.GiveItem_ItemIndex_int += new hook_GiveItem_ItemIndex_int(Inventory_GiveItem_ItemIndex_int);
}
private void OnQuantityChanged(object sender, EventArgs e)
{
if (minQuantity.Value > maxQuantity.Value)
{
if (sender == minQuantity)
{
maxQuantity.Value = minQuantity.Value;
}
else
{
minQuantity.Value = maxQuantity.Value;
}
}
}
private Sprite LoadIcon()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
try
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "icon.png");
if (!File.Exists(path))
{
return null;
}
byte[] array = File.ReadAllBytes(path);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
if (ImageConversion.LoadImage(val, array))
{
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).anisoLevel = 0;
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
}
}
catch
{
}
return null;
}
private bool IsSpeedItem(ItemIndex itemIndex)
{
//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_0016: 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_002b: 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_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)
if (itemIndex == Items.Hoof.itemIndex)
{
return true;
}
if (itemIndex == Items.SprintBonus.itemIndex)
{
return true;
}
if (itemIndex == Items.JumpBoost.itemIndex)
{
return true;
}
if (itemIndex == Items.SprintOutOfCombat.itemIndex)
{
return true;
}
return false;
}
private bool ShouldAffectItem(ItemTier tier)
{
//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_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected I4, but got Unknown
return (int)tier switch
{
0 => affectWhiteItems.Value,
1 => affectGreenItems.Value,
2 => affectRedItems.Value,
4 => affectYellowItems.Value,
3 => affectLunarItems.Value,
6 => affectWhiteItems.Value,
7 => affectGreenItems.Value,
8 => affectRedItems.Value,
9 => affectYellowItems.Value,
_ => false,
};
}
private void Inventory_GiveItem_ItemIndex_int(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_0034: Invalid comparison between Unknown and I4
//IL_00a5: 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)
PlayerCharacterMasterController component = ((Component)self).GetComponent<PlayerCharacterMasterController>();
ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
if (enableMod.Value && (Object)(object)component != (Object)null && (Object)(object)itemDef != (Object)null && (int)itemDef.tier != 5 && !itemDef.hidden && ShouldAffectItem(itemDef.tier))
{
int minValue = (int)minQuantity.Value;
int num = (int)maxQuantity.Value;
if (IsSpeedItem(itemIndex))
{
num = Math.Min(num, (int)speedItemCap.Value);
}
int num2 = rng.Next(minValue, num + 1);
orig.Invoke(self, itemIndex, num2);
}
else
{
orig.Invoke(self, itemIndex, count);
}
}
}