using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RarityWeightMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RarityWeightMod")] [assembly: AssemblyTitle("RarityWeightMod")] [assembly: AssemblyVersion("1.0.0.0")] [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 RarityWeightMod { public enum SpawnMode { Volume, All } public class ModConfig { public ConfigEntry Enabled; public ConfigEntry Mode; public ConfigEntry BoxCount; public ConfigEntry CommonWeight; public ConfigEntry UncommonWeight; public ConfigEntry RareWeight; public ConfigEntry UltraRareWeight; public ModConfig(ConfigFile cfg) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown Enabled = cfg.Bind("General", "Enabled", true, "เป\u0e34ด/ป\u0e34ด mod ท\u0e31\u0e49งหมด (true = เป\u0e34ด, false = ป\u0e34ด ใช\u0e49ค\u0e48าเกมปกต\u0e34)"); Mode = cfg.Bind("General", "Mode", SpawnMode.Volume, "Volume = จำก\u0e31ดตาม spawn volume ในด\u0e48าน | All = บ\u0e31งค\u0e31บ spawn ครบตาม BoxCount (compensation loop)"); BoxCount = cfg.Bind("General", "BoxCount", 3, new ConfigDescription("จำนวน Cosmetic Box ต\u0e48อด\u0e48าน (1-20)", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); CommonWeight = cfg.Bind("RarityWeights", "CommonWeight", 60, new ConfigDescription("Weight ของ Common (ค\u0e34ดจากส\u0e31ดส\u0e48วน เช\u0e48น 60:25:12:3 หร\u0e37อ 25:25:25:25 = เท\u0e48าก\u0e31นหมด)", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); UncommonWeight = cfg.Bind("RarityWeights", "UncommonWeight", 25, new ConfigDescription("Weight ของ Uncommon", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); RareWeight = cfg.Bind("RarityWeights", "RareWeight", 12, new ConfigDescription("Weight ของ Rare", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); UltraRareWeight = cfg.Bind("RarityWeights", "UltraRareWeight", 3, new ConfigDescription("Weight ของ UltraRare", (AcceptableValueBase)(object)new AcceptableValueRange(0, 100), Array.Empty())); } public Rarity PickRarity() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0083: 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_00a9: Unknown result type (might be due to invalid IL or missing references) int num = CommonWeight.Value + UncommonWeight.Value + RareWeight.Value + UltraRareWeight.Value; if (num <= 0) { return (Rarity)0; } int num2 = Random.Range(0, num); if (num2 < CommonWeight.Value) { return (Rarity)0; } num2 -= CommonWeight.Value; if (num2 < UncommonWeight.Value) { return (Rarity)1; } num2 -= UncommonWeight.Value; if (num2 < RareWeight.Value) { return (Rarity)2; } return (Rarity)3; } } [BepInPlugin("com.yourname.rarityweightmod", "RarityWeightMod", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ModConfig Cfg; private readonly Harmony _harmony = new Harmony("com.yourname.rarityweightmod"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Cfg = new ModConfig(((BaseUnityPlugin)this).Config); _harmony.PatchAll(); Log.LogInfo((object)"RarityWeightMod loaded!"); Log.LogInfo((object)$"Common={Cfg.CommonWeight.Value} Uncommon={Cfg.UncommonWeight.Value} Rare={Cfg.RareWeight.Value} UltraRare={Cfg.UltraRareWeight.Value}"); } } } namespace RarityWeightMod.Patches { [HarmonyPatch(typeof(ValuableDirector), "SetupHost")] public static class SetupHostPatch { public static void Prefix() { if (Plugin.Cfg.Enabled.Value && SemiFunc.RunIsLevel()) { BoxSpawnTracker.Reset(); Plugin.Log.LogInfo((object)$"[RarityWeightMod] Level start | Mode={Plugin.Cfg.Mode.Value} | Target={Plugin.Cfg.BoxCount.Value}"); } } } [HarmonyPatch(typeof(ValuableDirector), "SpawnCosmeticWorldObject")] public static class SpawnCosmeticWorldObjectPatch { public static bool Prefix(ValuableDirector __instance, ref Rarity _cosmeticRarity, int[] _volumeIndex, List[] _volumes) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected I4, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Cfg.Enabled.Value) { return true; } if (!SemiFunc.RunIsLevel()) { return true; } if (BoxSpawnTracker.SpawnedCount >= Plugin.Cfg.BoxCount.Value) { Plugin.Log.LogInfo((object)$"[RarityWeightMod] Limit reached ({BoxSpawnTracker.SpawnedCount}/{Plugin.Cfg.BoxCount.Value}), skipping."); return false; } Rarity val = _cosmeticRarity; _cosmeticRarity = (Rarity)(int)Plugin.Cfg.PickRarity(); BoxSpawnTracker.SpawnedCount++; Plugin.Log.LogInfo((object)$"[RarityWeightMod] Box {BoxSpawnTracker.SpawnedCount}/{Plugin.Cfg.BoxCount.Value} | {val} → {_cosmeticRarity}"); return true; } } [HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet")] public static class LoopsClampedPatch { public static void Postfix(ref int __result) { if (!Plugin.Cfg.Enabled.Value || !SemiFunc.RunIsLevel()) { return; } if (Plugin.Cfg.Mode.Value == SpawnMode.Volume) { int num = Plugin.Cfg.BoxCount.Value - 1; if (__result < num) { Plugin.Log.LogInfo((object)$"[RarityWeightMod] Volume loop: {__result} → {num}"); __result = num; } } else { int num2 = Plugin.Cfg.BoxCount.Value * 3 - 1; if (__result < num2) { Plugin.Log.LogInfo((object)$"[RarityWeightMod] All loop: {__result} → {num2}"); __result = num2; } } } } [HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsGet")] public static class LoopsGetPatch { public static void Postfix(ref int __result) { if (Plugin.Cfg.Enabled.Value && SemiFunc.RunIsLevel() && Plugin.Cfg.Mode.Value == SpawnMode.All && BoxSpawnTracker.SpawnedCount < Plugin.Cfg.BoxCount.Value) { __result = 9999; } } } public static class BoxSpawnTracker { public static int SpawnedCount; public static void Reset() { SpawnedCount = 0; } } }