using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; using pworld.Scripts.Extensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.github.LengSword.AutoItemMultiplier")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+eccbe23d41e5901d51443a8982b00ed8ae051dc7")] [assembly: AssemblyProduct("com.github.LengSword.AutoItemMultiplier")] [assembly: AssemblyTitle("AutoItemMultiplier")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace AutoItemMultiplier { [BepInPlugin("com.github.LengSword.AutoItemMultiplier", "AutoItemMultiplier", "0.2.0")] public class Plugin : BaseUnityPlugin { public const string Id = "com.github.LengSword.AutoItemMultiplier"; internal static ManualLogSource Logger { get; private set; } internal static float ItemMultiplier => GetItemMultiplier(); public static string Name => "AutoItemMultiplier"; public static string Version => "0.2.0"; private static float GetItemMultiplier() { if (PluginConfig.UseCustomMultiplier.Value) { return Mathf.Max(0f, PluginConfig.CustomMultiplier.Value); } int num = ((PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null) ? PhotonNetwork.CurrentRoom.PlayerCount : 4); return 1f + (float)Mathf.Max(0, num - 4) * PluginConfig.ItemMultiplierIncrement.Value; } private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)("Plugin " + Name + " is loaded!")); PluginConfig.Initialize(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); Harmony val = new Harmony("com.github.LengSword.AutoItemMultiplier"); val.PatchAll(); } internal static List AddMoreSlotsUntil(List spawnSpots, int target, bool addRandom = false) { if (spawnSpots.Count == 0 || (target <= 0 && !addRandom)) { return new List(); } int num = Mathf.Max(0, target); List list = new List(num + (addRandom ? 1 : 0)); int count = spawnSpots.Count; while (target >= count) { list.AddRange(spawnSpots); target -= count; } if (target > 0) { ExtCollections.Shuffle((IList)spawnSpots); list.AddRange(spawnSpots.GetRange(0, target)); } if (addRandom) { int index = Random.Range(0, count); list.Add(spawnSpots[index]); } return list; } internal static List AddMoreSlots(List spawnSpots, float multiplier) { if (spawnSpots.Count == 0 || multiplier <= 0f) { return new List(); } float num = (float)spawnSpots.Count * multiplier; int num2 = Mathf.FloorToInt(num); float num3 = num - (float)num2; bool addRandom = Random.value < num3; return AddMoreSlotsUntil(spawnSpots, num2, addRandom); } internal static void MultiplySpawnRange(ref Vector2 range, ref List spawnSpots, out Vector2 original) { //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_000e: 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_001d: Unknown result type (might be due to invalid IL or missing references) original = range; range *= ItemMultiplier; float num = Mathf.Max(range.x, range.y); if (num > (float)spawnSpots.Count) { List collection = AddMoreSlotsUntil(spawnSpots, Mathf.CeilToInt(num)); spawnSpots.Clear(); spawnSpots.AddRange(collection); } } } public static class PluginConfig { internal static ConfigEntry EnableMultiplier { get; private set; } internal static ConfigEntry ItemMultiplierIncrement { get; private set; } internal static ConfigEntry UseCustomMultiplier { get; private set; } internal static ConfigEntry CustomMultiplier { get; private set; } internal static ConfigEntry EnableLuggage { get; private set; } internal static ConfigEntry EnableRespawnChest { get; private set; } internal static ConfigEntry EnableAncientLuggage { get; private set; } internal static ConfigEntry EnableBerryBush { get; private set; } internal static ConfigEntry EnableBerryVine { get; private set; } internal static ConfigEntry EnableGroundSpawner { get; private set; } public static void Initialize(ConfigFile config, ManualLogSource logger) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown EnableMultiplier = config.Bind("General", "EnableMultiplier", true, "Enable item multiplier"); ItemMultiplierIncrement = config.Bind("General", "ItemMultiplierIncrement", 0.25f, new ConfigDescription("Item spawn multiplier increment when players count > 4 (0.25 = +0.25x/player items )", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); UseCustomMultiplier = config.Bind("General", "UseCustomMultiplier", false, "Use custom item multiplier instead of player count based multiplier"); CustomMultiplier = config.Bind("General", "CustomMultiplier", 1f, new ConfigDescription("Custom item spawn multiplier (used if UseCustomMultiplier is true)", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); EnableLuggage = config.Bind("SpawnerTypes", "EnableLuggage", true, "Enable multiplier for Luggage (excludes AncientLuggage and RespawnChest)"); EnableRespawnChest = config.Bind("SpawnerTypes", "EnableRespawnChest", false, "Enable multiplier for RespawnChest (Luggage)"); EnableAncientLuggage = config.Bind("SpawnerTypes", "EnableAncientLuggage", false, "Enable multiplier for AncientLuggage (Luggage)"); EnableBerryBush = config.Bind("SpawnerTypes", "EnableBerryBush", false, "Enable multiplier for BerryBush"); EnableBerryVine = config.Bind("SpawnerTypes", "EnableBerryVine", false, "Enable multiplier for BerryVine"); EnableGroundSpawner = config.Bind("SpawnerTypes", "EnableGroundSpawner", false, "Enable multiplier for GroundPlaceSpawner"); logger.LogInfo((object)"Plugin Config Loaded."); } } } namespace AutoItemMultiplier.Patches { [HarmonyPatch(typeof(BerryBush), "SpawnItems")] public static class BerryBushPatch { public static void Prefix(BerryBush __instance, ref List spawnSpots, out Vector2 __state) { //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_003c: 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_0063: 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) __state = __instance.possibleBerries; if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableBerryBush.Value && PhotonNetwork.IsMasterClient) { Plugin.MultiplySpawnRange(ref __instance.possibleBerries, ref spawnSpots, out __state); Vector2 possibleBerries = __instance.possibleBerries; Plugin.Logger.LogInfo((object)$"[BerryBush] Multiplier applied: {spawnSpots.Count} spawn spots, berry count range: {possibleBerries.x}-{possibleBerries.y} ({Plugin.ItemMultiplier}x)"); } } public static void Postfix(BerryBush __instance, List spawnSpots, Vector2 __state) { //IL_001b: 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) if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableBerryBush.Value) { __instance.possibleBerries = __state; } } } [HarmonyPatch(typeof(BerryVine), "SpawnItems")] public static class BerryVinePatch { public static void Prefix(BerryVine __instance, ref List spawnSpots, out Vector2 __state) { //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_003c: 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_0063: 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) __state = __instance.possibleBerries; if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableBerryVine.Value && PhotonNetwork.IsMasterClient) { Plugin.MultiplySpawnRange(ref __instance.possibleBerries, ref spawnSpots, out __state); Vector2 possibleBerries = __instance.possibleBerries; Plugin.Logger.LogInfo((object)$"[BerryVine] Multiplier applied: {spawnSpots.Count} spawn spots, berry count range: {possibleBerries.x}-{possibleBerries.y} ({Plugin.ItemMultiplier}x)"); } } public static void Postfix(BerryVine __instance, List spawnSpots, Vector2 __state) { //IL_001b: 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) if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableBerryVine.Value) { __instance.possibleBerries = __state; } } } [HarmonyPatch(typeof(GroundPlaceSpawner), "SpawnItems")] public static class GroundPlaceSpawnerPatch { public static void Prefix(GroundPlaceSpawner __instance, ref List spawnSpots, out Vector2 __state) { //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_0036: 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_0041: 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_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_0053: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00ce: 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_0131: 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) __state = __instance.possibleItems; if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableGroundSpawner.Value && PhotonNetwork.IsMasterClient) { float itemMultiplier = Plugin.ItemMultiplier; __instance.possibleItems *= itemMultiplier; Vector2 possibleItems = __instance.possibleItems; float num = possibleItems.x - Mathf.Floor(possibleItems.x); float num2 = possibleItems.y - Mathf.Floor(possibleItems.y); possibleItems.x = ((Random.value < num) ? Mathf.Ceil(possibleItems.x) : Mathf.Floor(possibleItems.x)); possibleItems.y = ((Random.value < num2) ? Mathf.Ceil(possibleItems.y) : Mathf.Floor(possibleItems.y)); __instance.possibleItems = possibleItems; float num3 = Mathf.Max(possibleItems.x, possibleItems.y); if (num3 > (float)spawnSpots.Count) { List collection = Plugin.AddMoreSlotsUntil(spawnSpots, Mathf.CeilToInt(num3)); spawnSpots.Clear(); spawnSpots.AddRange(collection); } Vector2 possibleItems2 = __instance.possibleItems; Plugin.Logger.LogInfo((object)$"[GroundSpawner] Multiplier applied: {spawnSpots.Count} spawn spots, item count range: {possibleItems2.x}-{possibleItems2.y} ({itemMultiplier}x)"); } } public static void Postfix(GroundPlaceSpawner __instance, List spawnSpots, Vector2 __state) { //IL_001b: 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) if (PluginConfig.EnableMultiplier.Value && PluginConfig.EnableGroundSpawner.Value) { __instance.possibleItems = __state; } } } [HarmonyPatch(typeof(Spawner), "SpawnItems")] public static class SpawnerPatch { internal static bool CanApplyMultiplier(string spawnerName) { switch (spawnerName) { case "Luggage": return PluginConfig.EnableLuggage.Value; case "RespawnChest": return PluginConfig.EnableRespawnChest.Value; case "LuggageCursed": return PluginConfig.EnableAncientLuggage.Value; default: Plugin.Logger.LogInfo((object)("[" + spawnerName + "] Unknown spawner type, multiplier disabled")); return false; } } public static void Prefix(Spawner __instance, ref List spawnSpots) { if (PluginConfig.EnableMultiplier.Value && PhotonNetwork.IsMasterClient) { string name = ((object)__instance).GetType().Name; if (CanApplyMultiplier(name)) { List collection = Plugin.AddMoreSlots(spawnSpots, Plugin.ItemMultiplier); spawnSpots.Clear(); spawnSpots.AddRange(collection); Plugin.Logger.LogInfo((object)$"[{name}] Multiplier applied: {spawnSpots.Count} spawn spots ({Plugin.ItemMultiplier}x)"); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }