Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of CommandItemCount v1.5.1
CommandItemCount.dll
Decompiled a month agousing System; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using On.RoR2.UI; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CommandItemCount")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f596f1901233011f9dd0de86c8b86f5d84727f0e")] [assembly: AssemblyProduct("CommandItemCount")] [assembly: AssemblyTitle("CommandItemCount")] [assembly: AssemblyVersion("1.0.0.0")] namespace CommandItemCount; public enum Position { TopRight, BottomRight, BottomLeft, TopLeft, Center } public enum Size { Small, Medium, Large } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("de.userstorm.commanditemcount", "CommandItemCount", "1.5.1")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class CommandItemCountPlugin : BaseUnityPlugin { public static ConfigEntry<bool> Show0 { get; set; } public static ConfigEntry<bool> ShowX { get; set; } public static ConfigEntry<Position> NumberPosition { get; set; } public static ConfigEntry<Size> NumberSize { get; set; } public static ConfigEntry<bool> EnableTooltip { get; set; } public static ConfigEntry<bool> EnableCloseDialogWithEscape { get; set; } public static ConfigEntry<bool> EnableCloseDialogWithWASD { get; set; } public static ConfigEntry<bool> EnableCloseDialogWithSpace { get; set; } public static ConfigEntry<bool> EnableCloseDialogWithShift { get; set; } private TextAlignmentOptions GetAlignment() { return (TextAlignmentOptions)(NumberPosition.Value switch { Position.TopRight => 260, Position.BottomRight => 1028, Position.BottomLeft => 1025, Position.TopLeft => 257, Position.Center => 514, _ => 260, }); } private Vector2 GetPosition() { //IL_0056: 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_0076: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) switch (NumberSize.Value) { case Size.Small: switch (NumberPosition.Value) { case Position.TopRight: return new Vector2(-5f, -1.5f); case Position.BottomRight: return new Vector2(-5f, 1.5f); case Position.BottomLeft: return new Vector2(5f, 1.5f); case Position.TopLeft: return new Vector2(5f, -1.5f); case Position.Center: return new Vector2(0f, 0f); } break; case Size.Medium: switch (NumberPosition.Value) { case Position.TopRight: return new Vector2(-5f, 0.5f); case Position.BottomRight: return new Vector2(-5f, 0.5f); case Position.BottomLeft: return new Vector2(5f, 0.5f); case Position.TopLeft: return new Vector2(5f, 0.5f); case Position.Center: return new Vector2(0f, 0f); } break; case Size.Large: switch (NumberPosition.Value) { case Position.TopRight: return new Vector2(-5f, 2.5f); case Position.BottomRight: return new Vector2(-5f, -2f); case Position.BottomLeft: return new Vector2(5f, -2f); case Position.TopLeft: return new Vector2(5f, 2.5f); case Position.Center: return new Vector2(0f, 0f); } break; } return new Vector2(-5f, -1.5f); } private float GetSize() { return NumberSize.Value switch { Size.Small => 18f, Size.Medium => 30f, Size.Large => 42f, _ => 18f, }; } private void CreateNumberLabel(Transform parent, ItemIndex itemIndex, int count) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected I4, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c6: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) string text = $"TextContainer_{(int)itemIndex}"; Transform val = parent.Find(text); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } if (Show0.Value || count != 0) { GameObject val2 = new GameObject(text); val2.transform.parent = parent; val2.AddComponent<CanvasRenderer>(); RectTransform val3 = val2.AddComponent<RectTransform>(); HGTextMeshProUGUI obj = val2.AddComponent<HGTextMeshProUGUI>(); ((TMP_Text)obj).text = (ShowX.Value ? "x" : "") + count; ((TMP_Text)obj).fontSize = GetSize(); ((Graphic)obj).color = Color.white; ((TMP_Text)obj).alignment = GetAlignment(); ((TMP_Text)obj).enableWordWrapping = false; ((Transform)val3).localPosition = Vector2.op_Implicit(Vector2.zero); val3.anchorMin = Vector2.zero; val3.anchorMax = Vector2.one; ((Transform)val3).localScale = Vector3.one; val3.sizeDelta = Vector2.zero; val3.anchoredPosition = GetPosition(); } } private void CreateTooltip(Transform parent, PickupDef pickupDefinition, int count) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0073: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(pickupDefinition.itemIndex); EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDefinition.equipmentIndex); bool flag = (Object)(object)itemDef != (Object)null; TooltipContent val = default(TooltipContent); val.titleColor = pickupDefinition.darkColor; val.titleToken = (flag ? itemDef.nameToken : equipmentDef.nameToken); val.bodyToken = (flag ? itemDef.descriptionToken : equipmentDef.descriptionToken); TooltipContent content = val; ((Component)parent).gameObject.AddComponent<TooltipProvider>().SetContent(content); } private void SetPickupOptionsHook(orig_SetPickupOptions orig, PickupPickerPanel self, Option[] options) { //IL_0055: 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_0068: 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_00a8: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, options); if (options.Length < 1) { return; } ReadOnlyCollection<MPButton> elements = Reflection.GetFieldValue<UIElementAllocator<MPButton>>((object)self, "buttonAllocator").elements; Inventory inventory = LocalUserManager.GetFirstLocalUser().cachedMasterController.master.inventory; for (int i = 0; i < options.Length; i++) { Transform transform = ((Component)elements[i]).transform; PickupDef pickupDef = PickupCatalog.GetPickupDef(options[i].pickup.pickupIndex); ItemIndex itemIndex = pickupDef.itemIndex; int count = ((!((object)(ItemIndex)(ref itemIndex)).Equals((object)(ItemIndex)(-1))) ? inventory.GetItemCountEffective(itemIndex) : 0); if (((object)(EquipmentIndex)(ref pickupDef.equipmentIndex)).Equals((object)(EquipmentIndex)(-1))) { CreateNumberLabel(transform, itemIndex, count); } if (EnableTooltip.Value) { CreateTooltip(transform, pickupDef, count); } } } private void HandleClosePickupPickerPanel() { if ((!EnableCloseDialogWithEscape.Value || !Input.GetKeyDown((KeyCode)27)) && (!EnableCloseDialogWithWASD.Value || !Input.GetKeyDown((KeyCode)119)) && (!EnableCloseDialogWithWASD.Value || !Input.GetKeyDown((KeyCode)97)) && (!EnableCloseDialogWithWASD.Value || !Input.GetKeyDown((KeyCode)115)) && (!EnableCloseDialogWithWASD.Value || !Input.GetKeyDown((KeyCode)100)) && (!EnableCloseDialogWithSpace.Value || !Input.GetKeyDown((KeyCode)32)) && (!EnableCloseDialogWithShift.Value || !Input.GetKeyDown((KeyCode)304))) { return; } PickupPickerPanel[] array = Object.FindObjectsOfType(typeof(PickupPickerPanel)) as PickupPickerPanel[]; if (array.Length != 0) { PickupPickerPanel[] array2 = array; for (int i = 0; i < array2.Length; i++) { Object.Destroy((Object)(object)((Component)array2[i]).gameObject); } if (Input.GetKeyDown((KeyCode)27)) { Console.instance.SubmitCmd((NetworkUser)null, "pause", false); } } } private void InitConfig() { Show0 = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Show0", true, "Display '0' or 'x0' if item count is 0"); ShowX = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShowX", true, "Display the 'x' in front of the number"); NumberPosition = ((BaseUnityPlugin)this).Config.Bind<Position>("Settings", "NumberPosition", Position.TopRight, "Number Position"); NumberSize = ((BaseUnityPlugin)this).Config.Bind<Size>("Settings", "NumberSize", Size.Small, "Number Size"); EnableTooltip = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableTooltip", true, "Show Item/Equipment Tooltip"); EnableCloseDialogWithEscape = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableCloseDialogWithEscape", true, "Closes the item picker dialog when Esc is pressed"); EnableCloseDialogWithWASD = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableCloseDialogWithWASD", true, "Closes the item picker dialog when W, A, S or D is pressed"); EnableCloseDialogWithSpace = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableCloseDialogWithSpace", true, "Closes the item picker dialog when Space is pressed"); EnableCloseDialogWithShift = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "EnableCloseDialogWithShift", true, "Closes the item picker dialog when Shift is pressed"); if (RiskOfOptionsMod.enabled) { RiskOfOptionsMod.Init("This mod shows the current item counts in the item selection dialog of the Artifact of Command and the Scrapper."); RiskOfOptionsMod.AddCheckboxOption(Show0); RiskOfOptionsMod.AddCheckboxOption(ShowX); RiskOfOptionsMod.AddChoiceOption<Position>(NumberPosition); RiskOfOptionsMod.AddChoiceOption<Size>(NumberSize); RiskOfOptionsMod.AddCheckboxOption(EnableTooltip); RiskOfOptionsMod.AddCheckboxOption(EnableCloseDialogWithEscape); RiskOfOptionsMod.AddCheckboxOption(EnableCloseDialogWithWASD); RiskOfOptionsMod.AddCheckboxOption(EnableCloseDialogWithSpace); RiskOfOptionsMod.AddCheckboxOption(EnableCloseDialogWithShift); } } public void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown InitConfig(); PickupPickerPanel.SetPickupOptions += new hook_SetPickupOptions(SetPickupOptionsHook); } public void Update() { HandleClosePickupPickerPanel(); } public void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown PickupPickerPanel.SetPickupOptions -= new hook_SetPickupOptions(SetPickupOptionsHook); } } internal static class RiskOfOptionsMod { private static bool? _enabled; internal static bool enabled { get { if (!_enabled.HasValue) { _enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Init(string description) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_005d: 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) ModSettingsManager.SetModDescription(description); using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("icon"); Texture2D val = new Texture2D(0, 0); byte[] array = new byte[stream.Length]; stream.Read(array, 0, (int)stream.Length); if (ImageConversion.LoadImage(val, array)) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f))); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void AddCheckboxOption(ConfigEntry<bool> configEntry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(configEntry)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void AddStepSliderOption(ConfigEntry<float> configEntry, float min, float max, float step) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown StepSliderConfig val = new StepSliderConfig(); ((SliderConfig)val).min = min; ((SliderConfig)val).max = max; val.increment = step; ModSettingsManager.AddOption((BaseOption)new StepSliderOption(configEntry, val)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void AddChoiceOption<T>(ConfigEntry<T> configEntry) where T : Enum { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)configEntry)); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void AddKeyBindOption(ConfigEntry<KeyboardShortcut> configEntry) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(configEntry)); } }