using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; 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_Offline, All_Offline, AutoLevel_Online } public class ModConfig { public ConfigEntry Enabled; public ConfigEntry Mode; public ConfigEntry BoxCount; public ConfigEntry ShowHUD; public ConfigEntry ShowBoxMarkers; public ConfigEntry OpenSettingsKey; public ConfigEntry ToggleBoxMarkersKey; public ConfigEntry CommonWeight; public ConfigEntry UncommonWeight; public ConfigEntry RareWeight; public ConfigEntry UltraRareWeight; public SpawnMode ModeValue { get { SpawnMode result; return Enum.TryParse(Mode.Value, out result) ? result : SpawnMode.Volume_Offline; } } public ModConfig(ConfigFile cfg) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_012b: 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_014e: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown Enabled = cfg.Bind("General", "Enabled", true, "เป\u0e34ด/ป\u0e34ด mod ท\u0e31\u0e49งหมด"); Mode = cfg.Bind("General", "Mode", "Volume_Offline", new ConfigDescription("Volume_Offline = บ\u0e31งค\u0e31บ spawn ตาม BoxCount จำก\u0e31ดด\u0e49วย volume ในด\u0e48าน (ต\u0e49องลงท\u0e38กคน)\nAll_Offline = บ\u0e31งค\u0e31บ spawn ครบตาม BoxCount ด\u0e49วย compensation loop (ต\u0e49องลงท\u0e38กคน)\nAutoLevel_Online = spawn ตาม limit ของด\u0e48านน\u0e31\u0e49นๆ อ\u0e31ตโนม\u0e31ต\u0e34 (host ลงคนเด\u0e35ยวพอ)", (AcceptableValueBase)(object)new AcceptableValueList(new string[3] { "Volume_Offline", "All_Offline", "AutoLevel_Online" }), Array.Empty())); BoxCount = cfg.Bind("General", "BoxCount", 3, new ConfigDescription("จำนวน Cosmetic Box ต\u0e48อด\u0e48าน — ใช\u0e49เฉพาะโหมด Volume_Offline และ All_Offline", (AcceptableValueBase)(object)new AcceptableValueRange(1, 20), Array.Empty())); ShowHUD = cfg.Bind("Display", "ShowHUD", true, "เป\u0e34ด/ป\u0e34ด HUD แสดงข\u0e49อม\u0e39ล mod บนหน\u0e49าจอ (ม\u0e38มซ\u0e49ายบน)"); ShowBoxMarkers = cfg.Bind("Display", "ShowBoxMarkers", true, "เป\u0e34ด/ป\u0e34ด bracket ส\u0e35แสดงตำแหน\u0e48งกล\u0e48อง cosmetic บนหน\u0e49าจอ\n(สามารถกด hotkey หร\u0e37อเป\u0e34ดหน\u0e49า Settings เพ\u0e37\u0e48อ toggle ระหว\u0e48างเล\u0e48น)"); OpenSettingsKey = cfg.Bind("Hotkeys", "OpenSettingsKey", new KeyboardShortcut((KeyCode)286, Array.Empty()), new ConfigDescription("ค\u0e35ย\u0e4cล\u0e31ดสำหร\u0e31บเป\u0e34ด/ป\u0e34ดหน\u0e49าต\u0e48าง Settings ในเกม", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); ToggleBoxMarkersKey = cfg.Bind("Hotkeys", "ToggleBoxMarkersKey", new KeyboardShortcut((KeyCode)287, Array.Empty()), new ConfigDescription("ค\u0e35ย\u0e4cล\u0e31ดสำหร\u0e31บซ\u0e48อน/แสดง bracket กล\u0e48อง cosmetic ระหว\u0e48างเล\u0e48น\n(เปล\u0e35\u0e48ยนค\u0e35ย\u0e4cได\u0e49จากหน\u0e49า Settings ในเกม)", (AcceptableValueBase)null, new object[1] { "HideFromREPOConfig" })); CommonWeight = cfg.Bind("RarityWeights", "CommonWeight", 60, new ConfigDescription("Weight ของ Common (ค\u0e34ดจากส\u0e31ดส\u0e48วน เช\u0e48น 60:25:12:3)", (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.1")] public class Plugin : BaseUnityPlugin { private enum RebindTarget { None, OpenSettings, ToggleMarkers } internal static ManualLogSource Log = null; internal static ModConfig Cfg = null; private readonly Harmony _harmony = new Harmony("com.yourname.rarityweightmod"); private static readonly Color ColorCommon = new Color(0.4f, 1f, 0.4f); private static readonly Color ColorUncommon = new Color(0.4f, 0.7f, 1f); private static readonly Color ColorRare = new Color(0.8f, 0.4f, 1f); private static readonly Color ColorUltraRare = new Color(1f, 0.6f, 0.2f); private static readonly Color ColorOn = new Color(0.3f, 1f, 0.3f); private static readonly Color ColorOff = new Color(1f, 0.5f, 0.1f); private GUIStyle _styleLabel = null; private GUIStyle _styleShadow = null; private GUIStyle _styleToast = null; private GUIStyle _styleShadowToast = null; private GUIStyle _styleWindow = null; private Texture2D _winBgTex = null; private Texture2D _sectionBgTex = null; private GUIStyle _styleToggle = null; private GUIStyle _styleBtn = null; private GUIStyle _styleBtnRebind = null; private GUIStyle _stylePanelLabel = null; private GUIStyle _styleSectionHeader = null; private bool _stylesInit = false; private float _toastTimer = 0f; private bool _toastIsOn = false; private const float ToastDuration = 2.5f; private bool _showSettings = false; private RebindTarget _rebindTarget = RebindTarget.None; private Rect _settingsRect = new Rect(0f, 0f, 500f, 575f); private bool _settingsRectInit = false; private CursorLockMode _savedLockMode; private bool _savedCursorVisible; private static readonly string[] ModeOptions = new string[3] { "Volume_Offline", "All_Offline", "AutoLevel_Online" }; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Cfg = new ModConfig(((BaseUnityPlugin)this).Config); _harmony.PatchAll(); Log.LogInfo((object)"RarityWeightMod loaded!"); Log.LogInfo((object)($"Mode={Cfg.ModeValue} | Common={Cfg.CommonWeight.Value} " + $"Uncommon={Cfg.UncommonWeight.Value} Rare={Cfg.RareWeight.Value} " + $"UltraRare={Cfg.UltraRareWeight.Value}")); } private void Update() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (_toastTimer > 0f) { _toastTimer -= Time.deltaTime; } if (_showSettings) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.OverrideAimStop(); } } if (_rebindTarget != 0) { return; } if (_showSettings && Input.GetKeyDown((KeyCode)27)) { ClosePanel(); return; } KeyboardShortcut value = Cfg.OpenSettingsKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (_showSettings) { ClosePanel(); } else { OpenPanel(); } return; } value = Cfg.ToggleBoxMarkersKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ToggleMarkers(); } } private void OpenPanel() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!_showSettings) { _savedLockMode = Cursor.lockState; _savedCursorVisible = Cursor.visible; } _showSettings = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } private void ClosePanel() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) _showSettings = false; _rebindTarget = RebindTarget.None; Cursor.lockState = _savedLockMode; Cursor.visible = _savedCursorVisible; } private void InitStyles() { //IL_0011: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0148: 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_0174: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Expected O, but got Unknown //IL_0355: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInit) { _styleLabel = new GUIStyle { fontSize = 20, fontStyle = (FontStyle)1, richText = true }; _styleLabel.normal.textColor = Color.white; _styleShadow = new GUIStyle(_styleLabel); _styleShadow.normal.textColor = Color.black; _styleToast = new GUIStyle { fontSize = 22, fontStyle = (FontStyle)1, richText = true }; _styleToast.normal.textColor = Color.white; _styleToast.alignment = (TextAnchor)4; _styleShadowToast = new GUIStyle(_styleToast); _styleShadowToast.normal.textColor = Color.black; _winBgTex = new Texture2D(1, 1); _winBgTex.SetPixel(0, 0, new Color(0.08f, 0.08f, 0.12f, 0.97f)); _winBgTex.Apply(); _sectionBgTex = new Texture2D(1, 1); _sectionBgTex.SetPixel(0, 0, new Color(0.05f, 0.05f, 0.09f, 1f)); _sectionBgTex.Apply(); _styleWindow = new GUIStyle(GUI.skin.window); _styleWindow.fontSize = 15; _styleWindow.fontStyle = (FontStyle)1; _styleWindow.normal.background = _winBgTex; _styleWindow.onNormal.background = _winBgTex; _styleToggle = new GUIStyle(GUI.skin.toggle); _styleToggle.fontSize = 15; _styleToggle.normal.textColor = Color.white; _styleToggle.hover.textColor = Color.white; _styleToggle.onNormal.textColor = Color.white; _styleToggle.onHover.textColor = Color.white; _styleBtn = new GUIStyle(GUI.skin.button); _styleBtn.fontSize = 14; _styleBtn.fontStyle = (FontStyle)1; _styleBtnRebind = new GUIStyle(_styleBtn); _styleBtnRebind.normal.textColor = new Color(1f, 0.9f, 0.2f); _styleBtnRebind.hover.textColor = new Color(1f, 0.9f, 0.2f); _stylePanelLabel = new GUIStyle(GUI.skin.label); _stylePanelLabel.fontSize = 14; _stylePanelLabel.normal.textColor = new Color(0.88f, 0.88f, 0.88f); _styleSectionHeader = new GUIStyle(GUI.skin.label); _styleSectionHeader.fontSize = 13; _styleSectionHeader.fontStyle = (FontStyle)1; _styleSectionHeader.normal.textColor = new Color(0.55f, 0.85f, 1f); _stylesInit = true; } } private void OnGUI() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003a: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Expected I4, but got Unknown InitStyles(); if (_rebindTarget != 0 && (int)Event.current.type == 4) { KeyCode keyCode = Event.current.keyCode; if ((int)keyCode == 27) { _rebindTarget = RebindTarget.None; } else if ((int)keyCode > 0) { KeyboardShortcut value = default(KeyboardShortcut); ((KeyboardShortcut)(ref value))..ctor(keyCode, Array.Empty()); if (_rebindTarget == RebindTarget.OpenSettings) { Cfg.OpenSettingsKey.Value = value; } else if (_rebindTarget == RebindTarget.ToggleMarkers) { Cfg.ToggleBoxMarkersKey.Value = value; } _rebindTarget = RebindTarget.None; } Event.current.Use(); } if (_toastTimer > 0f) { float num = Mathf.Clamp01(_toastTimer); string text = (_toastIsOn ? ("ON") : ("OFF")); string text2 = "Box Markers : " + text; string text3 = Regex.Replace(text2, "<.*?>", ""); float num2 = 500f; float num3 = 36f; float num4 = ((float)Screen.width - num2) * 0.5f; float num5 = (float)Screen.height * 0.1f; Color color = GUI.color; GUI.color = new Color(1f, 1f, 1f, num); GUI.Label(new Rect(num4 - 1.5f, num5 - 1.5f, num2, num3), text3, _styleShadowToast); GUI.Label(new Rect(num4 + 1.5f, num5 - 1.5f, num2, num3), text3, _styleShadowToast); GUI.Label(new Rect(num4 - 1.5f, num5 + 1.5f, num2, num3), text3, _styleShadowToast); GUI.Label(new Rect(num4 + 1.5f, num5 + 1.5f, num2, num3), text3, _styleShadowToast); GUI.Label(new Rect(num4, num5, num2, num3), text2, _styleToast); GUI.color = color; } if (_showSettings) { if (!_settingsRectInit) { _settingsRect = new Rect(((float)Screen.width - ((Rect)(ref _settingsRect)).width) * 0.5f, ((float)Screen.height - ((Rect)(ref _settingsRect)).height) * 0.5f, ((Rect)(ref _settingsRect)).width, ((Rect)(ref _settingsRect)).height); _settingsRectInit = true; } _settingsRect = GUI.Window(42, _settingsRect, new WindowFunction(DrawSettingsWindow), " RarityWeightMod — Settings", _styleWindow); } if (!Cfg.ShowHUD.Value || !SemiFunc.RunIsLevel()) { return; } float x = (float)Screen.width * 0.05f; float num6 = (float)Screen.height * 0.2f; int num7 = 0; int num8 = 0; int num9 = 0; int num10 = 0; if ((Object)(object)RoundDirector.instance != (Object)null) { foreach (CosmeticWorldObject cosmeticWorldObject in RoundDirector.instance.cosmeticWorldObjects) { if (!((Object)(object)cosmeticWorldObject == (Object)null)) { Rarity rarity = cosmeticWorldObject.rarity; Rarity val = rarity; switch ((int)val) { case 0: num7++; break; case 1: num8++; break; case 2: num9++; break; case 3: num10++; break; } } } } string text4 = MakeOnOff(Cfg.Enabled.Value); string text5 = MakeOnOff(Cfg.ShowBoxMarkers.Value); KeyboardShortcut value2 = Cfg.OpenSettingsKey.Value; KeyCode mainKey = ((KeyboardShortcut)(ref value2)).MainKey; string text6 = ((object)(KeyCode)(ref mainKey)).ToString(); value2 = Cfg.ToggleBoxMarkersKey.Value; mainKey = ((KeyboardShortcut)(ref value2)).MainKey; string text7 = ((object)(KeyCode)(ref mainKey)).ToString(); string text8 = $"Mode : {Cfg.ModeValue}"; DrawLine("RarityWeightMod [Settings : " + text6 + "]", x, num6, 800f, 26f); DrawLine("MOD : " + text4, x, num6 + 26f, 800f, 26f); DrawLine(text8, x, num6 + 52f, 800f, 26f); DrawLine(BuildColorLine("Rate : ", $"{Cfg.CommonWeight.Value}", ColorCommon, $"{Cfg.UncommonWeight.Value}", ColorUncommon, $"{Cfg.RareWeight.Value}", ColorRare, $"{Cfg.UltraRareWeight.Value}", ColorUltraRare), x, num6 + 78f, 800f, 26f); DrawLine(BuildColorLine("Count : ", $"{num7}", ColorCommon, $"{num8}", ColorUncommon, $"{num9}", ColorRare, $"{num10}", ColorUltraRare), x, num6 + 104f, 800f, 26f); DrawLine("Markers : " + text5 + " [" + text7 + "]", x, num6 + 130f, 800f, 26f); } private void DrawSettingsWindow(int windowId) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0346: 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_03a6: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref _settingsRect)).width - 36f; float y = 35f; DrawSectionLabel("General", 18f, ref y, num); Cfg.Enabled.Value = GUI.Toggle(new Rect(18f, y, num, 28f), Cfg.Enabled.Value, " Mod Enabled", _styleToggle); y += 28f; GUI.Label(new Rect(18f, y + 5f, 115f, 20f), "Mode :", _stylePanelLabel); int num2 = Array.IndexOf(ModeOptions, Cfg.Mode.Value); if (num2 < 0) { num2 = 0; } if (GUI.Button(new Rect(136f, y, num - 118f, 28f), "◄ " + Cfg.Mode.Value + " ►", _styleBtn)) { num2 = (num2 + 1) % ModeOptions.Length; Cfg.Mode.Value = ModeOptions[num2]; } y += 32f; DrawIntSlider("Box Count", 18f, ref y, num, Cfg.BoxCount, 1, 20); y += 10f; DrawSectionLabel("Display", 18f, ref y, num); Cfg.ShowHUD.Value = GUI.Toggle(new Rect(18f, y, num, 28f), Cfg.ShowHUD.Value, " Show HUD", _styleToggle); y += 28f; bool flag = GUI.Toggle(new Rect(18f, y, num, 28f), Cfg.ShowBoxMarkers.Value, " Show Box Markers", _styleToggle); if (flag != Cfg.ShowBoxMarkers.Value) { Cfg.ShowBoxMarkers.Value = flag; _toastIsOn = flag; _toastTimer = 2.5f; } y += 28f; y += 10f; DrawSectionLabel("Rarity Weights", 18f, ref y, num); DrawIntSlider("Common", 18f, ref y, num, Cfg.CommonWeight, 0, 100); DrawIntSlider("Uncommon", 18f, ref y, num, Cfg.UncommonWeight, 0, 100); DrawIntSlider("Rare", 18f, ref y, num, Cfg.RareWeight, 0, 100); DrawIntSlider("Ultra Rare", 18f, ref y, num, Cfg.UltraRareWeight, 0, 100); y += 10f; DrawSectionLabel("Hotkeys", 18f, ref y, num); DrawRebindRow("Open Settings Key", 18f, ref y, num, Cfg.OpenSettingsKey, RebindTarget.OpenSettings); DrawRebindRow("Toggle Markers Key", 18f, ref y, num, Cfg.ToggleBoxMarkersKey, RebindTarget.ToggleMarkers); y += 8f; GUI.Box(new Rect(18f, y, num, 1f), GUIContent.none); y += 12f; if (GUI.Button(new Rect(18f, y, num, 30f), "Close", _styleBtn)) { ClosePanel(); } GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _settingsRect)).width, 25f)); } private void DrawSectionLabel(string text, float pad, ref float y, float iw) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(pad, y, iw, 20f), (Texture)(object)_sectionBgTex); GUI.Label(new Rect(pad + 4f, y + 1f, iw - 4f, 20f), text, _styleSectionHeader); y += 24f; } private void DrawIntSlider(string label, float pad, ref float y, float iw, ConfigEntry entry, int min, int max) { //IL_0029: 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_00a1: Unknown result type (might be due to invalid IL or missing references) float num = iw - 120f - 44f - 8f; GUI.Label(new Rect(pad, y + 5f, 120f, 20f), label, _stylePanelLabel); float num2 = GUI.HorizontalSlider(new Rect(pad + 120f, y + 9f, num, 14f), (float)entry.Value, (float)min, (float)max); entry.Value = Mathf.Clamp(Mathf.RoundToInt(num2), min, max); GUI.Label(new Rect(pad + 120f + num + 6f, y + 5f, 44f, 20f), entry.Value.ToString(), _stylePanelLabel); y += 28f; } private void DrawRebindRow(string label, float pad, ref float y, float iw, ConfigEntry entry, RebindTarget target) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) float num = iw - 160f - 5f; GUI.Label(new Rect(pad, y + 6f, 160f, 22f), label + " :", _stylePanelLabel); bool flag = _rebindTarget == target; object obj; if (!flag) { KeyboardShortcut value = entry.Value; obj = $"[ {((KeyboardShortcut)(ref value)).MainKey} ] Click to rebind"; } else { obj = "[ Press any key... (ESC = cancel) ]"; } string text = (string)obj; if (GUI.Button(new Rect(pad + 160f + 5f, y, num, 30f), text, flag ? _styleBtnRebind : _styleBtn)) { _rebindTarget = ((!flag) ? target : RebindTarget.None); } y += 32f; } private void ToggleMarkers() { Cfg.ShowBoxMarkers.Value = !Cfg.ShowBoxMarkers.Value; _toastIsOn = Cfg.ShowBoxMarkers.Value; _toastTimer = 2.5f; } private string MakeOnOff(bool value) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return value ? ("ON") : ("OFF"); } private void DrawLine(string text, float x, float y, float w, float h) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) string text2 = Regex.Replace(text, "<.*?>", ""); GUI.Label(new Rect(x - 1.5f, y - 1.5f, w, h), text2, _styleShadow); GUI.Label(new Rect(x + 1.5f, y - 1.5f, w, h), text2, _styleShadow); GUI.Label(new Rect(x - 1.5f, y + 1.5f, w, h), text2, _styleShadow); GUI.Label(new Rect(x + 1.5f, y + 1.5f, w, h), text2, _styleShadow); GUI.Label(new Rect(x, y, w, h), text, _styleLabel); } private string BuildColorLine(string prefix, string v1, Color c1, string v2, Color c2, string v3, Color c3, string v4, Color c4) { //IL_0017: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) return prefix + "" + v1 + "/" + v2 + "/" + v3 + "/" + v4 + ""; } private string ColorToHex(Color c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) return $"{ToByte(c.r):X2}{ToByte(c.g):X2}{ToByte(c.b):X2}"; } private int ToByte(float f) { return Mathf.Clamp(Mathf.RoundToInt(f * 255f), 0, 255); } } } namespace RarityWeightMod.Patches { [HarmonyPatch(typeof(CosmeticWorldObject), "Start")] public static class CosmeticWorldObjectStartPatch { public static void Postfix(CosmeticWorldObject __instance) { if (Plugin.Cfg.Enabled.Value && SemiFunc.RunIsLevel() && SemiFunc.IsMasterClientOrSingleplayer()) { CosmeticBoxTracker cosmeticBoxTracker = ((Component)__instance).gameObject.AddComponent(); cosmeticBoxTracker.Setup(__instance); } } } public class CosmeticBoxTracker : MonoBehaviour { private CosmeticWorldObject _box; private PhysGrabObject _physGrab; private ValuableDiscoverGraphic _activeGraphic; private static readonly Color ColorCommon = new Color(0.4f, 1f, 0.4f); private static readonly Color ColorUncommon = new Color(0.4f, 0.7f, 1f); private static readonly Color ColorRare = new Color(0.8f, 0.4f, 1f); private static readonly Color ColorUltraRare = new Color(1f, 0.6f, 0.2f); public void Setup(CosmeticWorldObject box) { _box = box; ref PhysGrabObject physGrab = ref _physGrab; object? value = AccessTools.Field(typeof(CosmeticWorldObject), "physGrabObject").GetValue(box); physGrab = (PhysGrabObject)((value is PhysGrabObject) ? value : null); } private void Update() { if (!Plugin.Cfg.Enabled.Value || !Plugin.Cfg.ShowBoxMarkers.Value) { HideAllBoxGraphics(); } else if (SemiFunc.RunIsLevel() && !((Object)(object)ValuableDiscover.instance == (Object)null) && !((Object)(object)_physGrab == (Object)null) && (Object)(object)_activeGraphic == (Object)null) { SpawnGraphic(); } } private void HideAllBoxGraphics() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown if ((Object)(object)_activeGraphic != (Object)null) { ((Component)_activeGraphic).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)_activeGraphic).gameObject); _activeGraphic = null; } if ((Object)(object)ValuableDiscover.instance == (Object)null || (Object)(object)_physGrab == (Object)null) { return; } List list = new List(); foreach (Transform item in ((Component)ValuableDiscover.instance).transform) { Transform val = item; if (!((Object)(object)val == (Object)null)) { ValuableDiscoverGraphic component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.target == (Object)(object)_physGrab) { list.Add(((Component)val).gameObject); } } } foreach (GameObject item2 in list) { if (!((Object)(object)item2 == (Object)null)) { item2.SetActive(false); Object.Destroy((Object)(object)item2); } } } private void SpawnGraphic() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_008e: 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_00bb: 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_00c3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ValuableDiscover.instance == (Object)null) && !((Object)(object)_physGrab == (Object)null)) { ValuableDiscoverCustom val = ((Component)_box).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)_box).gameObject.AddComponent(); } GetRarityColors(_box.rarity, out var corner, out var middle); float waitTime = val.waitTime; Color colorCorner = val.colorCorner; Color colorMiddle = val.colorMiddle; val.colorCorner = corner; val.colorMiddle = middle; val.waitTime = 99999f; ValuableDiscover.instance.New(_physGrab, (State)3, val); val.waitTime = waitTime; val.colorCorner = colorCorner; val.colorMiddle = colorMiddle; int childCount = ((Component)ValuableDiscover.instance).transform.childCount; if (childCount > 0) { _activeGraphic = ((Component)((Component)ValuableDiscover.instance).transform.GetChild(childCount - 1)).GetComponent(); } } } private void GetRarityColors(Rarity rarity, out Color corner, out Color middle) { //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_0017: Expected I4, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_005b: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) switch ((int)rarity) { case 0: corner = ColorCommon; middle = new Color(ColorCommon.r, ColorCommon.g, ColorCommon.b, 0.3f); break; case 1: corner = ColorUncommon; middle = new Color(ColorUncommon.r, ColorUncommon.g, ColorUncommon.b, 0.3f); break; case 2: corner = ColorRare; middle = new Color(ColorRare.r, ColorRare.g, ColorRare.b, 0.3f); break; default: corner = ColorUltraRare; middle = new Color(ColorUltraRare.r, ColorUltraRare.g, ColorUltraRare.b, 0.3f); break; } } } [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.ModeValue} | BoxCount={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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected I4, but got Unknown //IL_0134: 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 (Plugin.Cfg.ModeValue == SpawnMode.Volume_Offline || Plugin.Cfg.ModeValue == SpawnMode.All_Offline) { if (BoxSpawnTracker.SpawnedCount >= Plugin.Cfg.BoxCount.Value) { Plugin.Log.LogInfo((object)$"[RarityWeightMod] Limit reached ({BoxSpawnTracker.SpawnedCount}/{Plugin.Cfg.BoxCount.Value}), skipping."); return false; } BoxSpawnTracker.SpawnedCount++; } else { int num = BoxSpawnTracker.AutoLevelLimit + 1; if (BoxSpawnTracker.SpawnedCount >= num) { Plugin.Log.LogInfo((object)$"[RarityWeightMod] AutoLevel limit reached ({BoxSpawnTracker.SpawnedCount}/{num}), skipping."); return false; } BoxSpawnTracker.SpawnedCount++; } Rarity val = _cosmeticRarity; _cosmeticRarity = (Rarity)(int)Plugin.Cfg.PickRarity(); Plugin.Log.LogInfo((object)$"[RarityWeightMod] Box {BoxSpawnTracker.SpawnedCount} | {val} → {_cosmeticRarity}"); return true; } } [HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet")] public static class LoopsClampedPatch { public static void Postfix(ref int __result) { if (!Plugin.Cfg.Enabled.Value) { return; } switch (Plugin.Cfg.ModeValue) { case SpawnMode.Volume_Offline: { int num3 = Plugin.Cfg.BoxCount.Value - 1; if (__result < num3) { __result = num3; } break; } case SpawnMode.All_Offline: { int num2 = Plugin.Cfg.BoxCount.Value * 3 - 1; if (__result < num2) { __result = num2; } break; } case SpawnMode.AutoLevel_Online: { BoxSpawnTracker.AutoLevelLimit = __result; int num = (__result + 1) * 3 - 1; if (num < 0) { num = 0; } if (__result < num) { __result = num; } int cosmeticWorldObjectsLevelLoop = ValuableDirector.instance.cosmeticWorldObjectsLevelLoop; int cosmeticWorldObjectsLevelLoopsMax = ValuableDirector.instance.cosmeticWorldObjectsLevelLoopsMax; int levelsCompleted = RunManager.instance.levelsCompleted; Plugin.Log.LogInfo((object)$"[RarityWeightMod] AutoLevel | levelsCompleted={levelsCompleted} | LevelLoop={cosmeticWorldObjectsLevelLoop} | LoopsMax={cosmeticWorldObjectsLevelLoopsMax} | limit={BoxSpawnTracker.AutoLevelLimit} | canSell={BoxSpawnTracker.AutoLevelLimit + 1} | loop→{__result}"); break; } } } } [HarmonyPatch(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsGet")] public static class LoopsGetPatch { public static void Postfix(ref int __result) { if (!Plugin.Cfg.Enabled.Value || !SemiFunc.RunIsLevel()) { return; } if (Plugin.Cfg.ModeValue == SpawnMode.All_Offline) { if (BoxSpawnTracker.SpawnedCount < Plugin.Cfg.BoxCount.Value) { __result = 9999; } } else if (Plugin.Cfg.ModeValue == SpawnMode.AutoLevel_Online) { int num = BoxSpawnTracker.AutoLevelLimit + 1; if (BoxSpawnTracker.SpawnedCount < num) { __result = 9999; } } } } public static class BoxSpawnTracker { public static int SpawnedCount; public static int AutoLevelLimit; public static void Reset() { SpawnedCount = 0; AutoLevelLimit = 0; } } }