The current BepInExPack is broken due to the Oakveil update, and mods installed through a mod manager may not work. Join the modding Discord for more information.
Decompiled source of CrimsonDropRate v1.1.1
CrimsonDropRate.dll
Decompiled 2 weeks 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 BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using CrimsonDropRate.Configs; using CrimsonDropRate.Systems; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Shared; using Unity.Collections; using Unity.Entities; using Unity.Scenes; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CrimsonDropRate")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Modifies the item group drop rate, not the item quantity drop.")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+Branch.master.Sha.ecbef25a0040b908a4d41d0abf9c31d612fd9735.ecbef25a0040b908a4d41d0abf9c31d612fd9735")] [assembly: AssemblyProduct("CrimsonDropRate")] [assembly: AssemblyTitle("CrimsonDropRate")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 CrimsonDropRate { internal static class Core { public static bool hasInitialized = false; public static World Server { get; } = GetServerWorld() ?? throw new Exception("There is no Server world (yet)..."); public static SystemService SystemService { get; } = new SystemService(Server); public static void Initialize() { if (!hasInitialized) { DropRateSystem.ChangeDropRate(); hasInitialized = true; } } private static World GetServerWorld() { return ((IEnumerable<World>)World.s_AllWorlds.ToArray()).FirstOrDefault((Func<World, bool>)((World world) => world.Name == "Server")); } } [HarmonyPatch] internal static class InitializationPatch { [HarmonyPatch(typeof(SceneSystem), "ShutdownStreamingSupport")] [HarmonyPostfix] private static void ShutdownStreamingSupportPostfix() { Core.Initialize(); if (Core.hasInitialized) { Plugin.Harmony.Unpatch((MethodBase)typeof(SceneSystem).GetMethod("ShutdownStreamingSupport"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch")); } } } [BepInPlugin("CrimsonDropRate", "CrimsonDropRate", "1.1.1")] public class Plugin : BasePlugin { private Harmony _harmony; public static ManualLogSource Logger; internal static Plugin Instance { get; private set; } public static Harmony Harmony => Instance._harmony; public override void Load() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown Instance = this; Logger = ((BasePlugin)this).Log; DropRateConfig.Initialize(((BasePlugin)this).Config); _harmony = new Harmony("CrimsonDropRate"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("CrimsonDropRate"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); } public override bool Unload() { ((BasePlugin)this).Config.Clear(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CrimsonDropRate"; public const string PLUGIN_NAME = "CrimsonDropRate"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace CrimsonDropRate.Systems { internal static class DropRateSystem { internal static void ChangeDropRate() { //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) if (DropRateConfig.DropRateModifier.Value == 1f) { return; } ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Changing drop rate values. Modifier: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(DropRateConfig.DropRateModifier.Value); } logger.LogInfo(val); try { PrefabCollectionSystem prefabCollectionSystem = Core.SystemService.PrefabCollectionSystem; foreach (DropTableBuffer entitiesDropTable in GetEntitiesDropTables()) { try { Entity val2 = prefabCollectionSystem._PrefabGuidToEntityMap[entitiesDropTable.DropTableGuid]; if (((Entity)(ref val2)).Equals(Entity.Null)) { continue; } EntityManager entityManager = Core.Server.EntityManager; if (!((EntityManager)(ref entityManager)).HasComponent<DropTableDataBuffer>(val2)) { continue; } entityManager = Core.Server.EntityManager; DynamicBuffer<DropTableDataBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<DropTableDataBuffer>(val2, false); List<DropTableDataBuffer> list = new List<DropTableDataBuffer>(); Enumerator<DropTableDataBuffer> enumerator2 = buffer.GetEnumerator(); while (enumerator2.MoveNext()) { DropTableDataBuffer current2 = enumerator2.Current; ManualLogSource logger2 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(10, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("DropRate: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(current2.DropRate); } logger2.LogInfo(val); list.Add(new DropTableDataBuffer { DropRate = Math.Min(1f, current2.DropRate * DropRateConfig.DropRateModifier.Value), ItemGuid = current2.ItemGuid, ItemType = current2.ItemType, Quantity = current2.Quantity }); } buffer.RemoveRange(0, buffer.Length); foreach (DropTableDataBuffer item in list) { buffer.Add(item); } } catch (Exception ex) { ManualLogSource logger3 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error accessing dropTable: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\nStackTrace: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.StackTrace); } logger3.LogError(val3); } } } catch (Exception ex2) { ManualLogSource logger4 = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(45, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error Setting Drop Rate Values: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\nStackTrace: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.StackTrace); } logger4.LogError(val3); } finally { ManualLogSource logger5 = Plugin.Logger; val = new BepInExInfoLogInterpolatedStringHandler(37, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Drop rate values changed successfully"); } logger5.LogInfo(val); } } private static IList<DropTableBuffer> GetEntitiesDropTables() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0021: Expected O, but got Unknown //IL_002a: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00c3: Unknown result type (might be due to invalid IL or missing references) List<DropTableBuffer> list = new List<DropTableBuffer>(); EntityManager entityManager = Core.Server.EntityManager; EntityQueryDesc[] array = new EntityQueryDesc[1]; EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<DropTableBuffer>() }); val.Options = (EntityQueryOptions)195; array[0] = val; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array); Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; entityManager = Core.Server.EntityManager; Enumerator<DropTableBuffer> enumerator2 = ((EntityManager)(ref entityManager)).GetBuffer<DropTableBuffer>(current, false).GetEnumerator(); while (enumerator2.MoveNext()) { DropTableBuffer dropTable = enumerator2.Current; if (!list.Any((DropTableBuffer r) => r.DropTableGuid == dropTable.DropTableGuid)) { list.Add(dropTable); } } } return list; } } internal class SystemService { private World _world; private PrefabCollectionSystem _prefabCollectionSystem; public PrefabCollectionSystem PrefabCollectionSystem => _prefabCollectionSystem ?? (_prefabCollectionSystem = GetSystem<PrefabCollectionSystem>()); public SystemService() { } internal SystemService(World world) : this() { _world = world; _prefabCollectionSystem = GetSystem<PrefabCollectionSystem>(); } private T GetSystem<T>() where T : ComponentSystemBase { return _world.GetExistingSystemManaged<T>() ?? throw new InvalidOperationException("Failed to get " + Il2CppType.Of<T>().FullName + " from the Server..."); } } } namespace CrimsonDropRate.Configs { internal static class DropRateConfig { internal static ConfigEntry<float> DropRateModifier { get; private set; } internal static void Initialize(ConfigFile config) { DropRateModifier = config.Bind<float>("DropRateConfig", "DropRateModifier", 1f, "Drop rate modifer value"); } } }