diff --git a/BetterUI.cs b/BetterUI.cs index dca0de2c..9bec6d86 100644 --- a/BetterUI.cs +++ b/BetterUI.cs @@ -34,49 +34,14 @@ protected override void Awake() { base.Awake(); + instance = this; this.gameObject.hideFlags |= UnityEngine.HideFlags.HideAndDontSave; this.gameObject.AddComponent(); BetterUI.Language.LoadLanguages(); - if (ConfigManager.ComponentsItemSorting.Value) - ItemSorting.Hook(); - if (ConfigManager.ComponentsStatsDisplay.Value) - StatsDisplay.Hook(); - if (ConfigManager.ComponentsCommandImprovements.Value) - CommandImprovements.Hook(); - if (ConfigManager.ComponentsDPSMeter.Value) - DPSMeter.Initialize(); - if (ConfigManager.ComponentsBuffTimers.Value) - Buffs.Hook(); - if (ConfigManager.ComponentsAdvancedIcons.Value) - AdvancedIcons.Hook(); - if (ConfigManager.ComponentsItemCounters.Value) - ItemCounters.Hook(); - if (ConfigManager.ComponentsMisc.Value) - Misc.Hook(); BetterUIWindow.Init(); - RoR2.ItemCatalog.availability.CallWhenAvailable(ItemStats.Initialize); - } - - - protected override void OnEnable() - { - base.OnEnable(); - BetterAPIModIntegration = BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey("com.xoxfaby.BetterAPI"); - BetterUIPlugin.Hooks.Add("Awake", HUD_Awake); - } - - internal static void HUD_Awake(Action orig, RoR2.UI.HUD self) - { - orig(self); - hud = self; - objectivePanelController = self.GetComponentInChildren(true); - if (onHUDAwake != null) - { - onHUDAwake.Invoke(hud); - } } } } diff --git a/BetterUI.csproj b/BetterUI.csproj index 7bb310f6..7bd75c7c 100644 --- a/BetterUI.csproj +++ b/BetterUI.csproj @@ -50,4 +50,9 @@ Always + + + + + diff --git a/BetterUIWindow.cs b/BetterUIWindow.cs index 1df67a06..a89a451c 100644 --- a/BetterUIWindow.cs +++ b/BetterUIWindow.cs @@ -93,12 +93,10 @@ public void createWindow(GameObject prefab) if (!exists || instance == null) { spawnedGameObjects[prefab] = GameObject.Instantiate(prefab, BetterUIWindow.menuParent); - var button = spawnedGameObjects[prefab].transform.Find("Window/UpperLeftButtonPanel/DonateButton"); - if (button) - { - Destroy(button.gameObject); - } - + Destroy(spawnedGameObjects[prefab].transform.Find("Window/UpperLeftButtonPanel/DonateButton")?.gameObject); + Destroy(spawnedGameObjects[prefab].transform.Find("Window/UpperLeftButtonPanel/DiscordButton")?.gameObject); + Destroy(spawnedGameObjects[prefab].transform.Find("Window/SocialPanel/TwitterButton")?.gameObject); + } } } diff --git a/CHANGELOG.md b/CHANGELOG.md index a8ef1b98..4f5416cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +v3: core functionality only, stripped other useless features. + v2.something removed dono link from main menu button menu as per new rules diff --git a/ConfigManager.cs b/ConfigManager.cs deleted file mode 100644 index 742d1783..00000000 --- a/ConfigManager.cs +++ /dev/null @@ -1,553 +0,0 @@ -using BepInEx; -using BepInEx.Configuration; -using System; -using UnityEngine; -using System.Collections.Generic; -using System.Linq; -using RoR2; - -namespace BetterUI -{ - internal static class ConfigManager - { - // Files - - public static ConfigFile ConfigFileComponents; - public static ConfigFile ConfigFileMisc; - public static ConfigFile ConfigFileAdvancedIcons; - public static ConfigFile ConfigFileBuffs; - public static ConfigFile ConfigFileCommandImprovements; - public static ConfigFile ConfigFileDPSMeter; - public static ConfigFile ConfigFileItemCounters; - public static ConfigFile ConfigFileStatsDisplay; - public static ConfigFile ConfigFileSorting; - - // Components - - public static ConfigEntry ComponentsAdvancedIcons; - public static ConfigEntry ComponentsBuffTimers; - public static ConfigEntry ComponentsCommandImprovements; - public static ConfigEntry ComponentsDPSMeter; - public static ConfigEntry ComponentsItemCounters; - public static ConfigEntry ComponentsItemSorting; - public static ConfigEntry ComponentsMisc; - public static ConfigEntry ComponentsStatsDisplay; - - // Misc - - public static ConfigEntry MiscShowHidden; - public static ConfigEntry MiscAdvancedPickupNotificationsItems; - public static ConfigEntry MiscAdvancedPickupNotificationsEquipements; - public static ConfigEntry MiscHidePickupNotificiationsItems; - public static ConfigEntry MiscHidePickupNotificiationsEquipements; - public static ConfigEntry MiscHidePickupNotificiationsArtifacts; - public static ConfigEntry MiscShowPickupDescription; - public static ConfigEntry MiscPickupDescriptionAdvanced; - - // AdvancedIcons - - public static ConfigEntry AdvancedIconsItemAdvancedDescriptions; - public static ConfigEntry AdvancedIconsItemItemStatsIntegration; - public static ConfigEntry AdvancedIconsEquipementShowCooldownStacks; - public static ConfigEntry AdvancedIconsEquipementAdvancedDescriptions; - public static ConfigEntry AdvancedIconsEquipementShowBaseCooldown; - public static ConfigEntry AdvancedIconsEquipementShowCalculatedCooldown; - public static ConfigEntry AdvancedIconsSkillShowCooldownStacks; - public static ConfigEntry AdvancedIconsSkillShowBaseCooldown; - public static ConfigEntry AdvancedIconsSkillShowCalculatedCooldown; - public static ConfigEntry AdvancedIconsSkillShowProcCoefficient; - public static ConfigEntry AdvancedIconsSkillCalculateSkillProcEffects; - - // Buffs - - public static ConfigEntry BuffTimers; - public static ConfigEntry BuffTimersDecimal; - public static ConfigEntry BuffTooltips; - public static ConfigEntry BuffTimersPosition; - public static TMPro.TextAlignmentOptions BuffTimersTextAlignmentOption; - public static ConfigEntry BuffTimersFontSize; - - // CommandImprovements - - public static ConfigEntry CommandResizeCommandWindow; - public static ConfigEntry CommandRemoveBackgroundBlur; - public static ConfigEntry CommandCloseOnEscape; - public static ConfigEntry CommandCloseOnWASD; - public static ConfigEntry CommandCloseOnCustom; - public static ConfigEntry CommandTooltipsShow; - public static ConfigEntry CommandTooltipsItemStatsBeforeAfter; - public static ConfigEntry CommandCountersShow; - public static ConfigEntry CommandCountersHideOnZero; - public static ConfigEntry CommandCountersPosition; - public static TMPro.TextAlignmentOptions CommandCountersTextAlignmentOption; - public static ConfigEntry CommandCountersFontSize; - public static ConfigEntry CommandCountersPrefix; - - // DPSMeter - - public static ConfigEntry DPSMeterTimespan; - public static ConfigEntry DPSMeterWindowShow; - public static ConfigEntry DPSMeterWindowIncludeMinions; - public static ConfigEntry DPSMeterWindowBackground; - public static ConfigEntry DPSMeterWindowHideWhenTyping; - public static ConfigEntry DPSMeterWindowAnchorMin; - public static ConfigEntry DPSMeterWindowAnchorMax; - public static ConfigEntry DPSMeterWindowPosition; - public static ConfigEntry DPSMeterWindowPivot; - public static ConfigEntry DPSMeterWindowSize; - public static ConfigEntry DPSMeterWindowAngle; - - // ItemCounters - - public static ConfigEntry ItemCountersShowItemCounters; - public static ConfigEntry ItemCountersShowItemScore; - public static ConfigEntry ItemCountersItemScoreFromTier; - public static ConfigEntry ItemCountersShowItemSum; - public static ConfigEntry ItemCountersItemSumTiersString; - public static List ItemCountersItemSumTiers; - public static ConfigEntry ItemCountersShowItemsByTier; - public static ConfigEntry ItemCountersItemsByTierOrderString; - public static List ItemCountersItemsByTierOrder; - public static ConfigEntry ItemCountersTierScoreTier1; - public static ConfigEntry ItemCountersTierScoreTier2; - public static ConfigEntry ItemCountersTierScoreTier3; - public static ConfigEntry ItemCountersTierScoreLunar; - public static ConfigEntry ItemCountersTierScoreBoss; - public static ConfigEntry ItemCountersTierScoreNoTier; - public static Dictionary ItemCountersTierScores; - public static Dictionary ItemCountersItemScores; - - // StatsDisplay - - public static ConfigEntry StatsDisplayEnable; - public static ConfigEntry StatsDisplayStatString; - public static ConfigEntry StatsDisplayStatStringCustomBind; - public static ConfigEntry StatsDisplayCustomBind; - public static ConfigEntry StatsDisplayShowCustomBindOnly; - public static ConfigEntry StatsDisplayToggleOnBind; - public static ConfigEntry StatsDisplayPanelBackground; - public static ConfigEntry StatsDisplayAttachToObjectivePanel; - public static ConfigEntry StatsDisplayWindowAnchorMin; - public static ConfigEntry StatsDisplayWindowAnchorMax; - public static ConfigEntry StatsDisplayWindowPosition; - public static ConfigEntry StatsDisplayWindowPivot; - public static ConfigEntry StatsDisplayWindowSize; - public static ConfigEntry StatsDisplayWindowAngle; - - // Sorting - - public static ConfigEntry SortingSortItemsInventory; - public static ConfigEntry SortingSortItemsCommand; - public static ConfigEntry SortingSortItemsScrapper; - public static ConfigEntry SortingTierOrderString; - public static int[] SortingTierOrder; - public static ConfigEntry SortingSortOrder; - public static ConfigEntry SortingSortOrderCommand; - public static ConfigEntry SortingSortOrderScrapper; - - // Internal - - /* - * NOTE: - * When renaming a config entry within the same config file, place both the new Section + Key - * and the old Section + Key in the dictionary below. - * - * By creating a rename mapping, we're able to - * 1) transfer the old entry's value to the new entry's value. - * 2) remove the old entry from the config file. - * - * This let's us update config files without users' configs suddenly changing. - */ - static IReadOnlyDictionary<(string, string), (string, string)> previousEntryMap = new Dictionary<(string, string), (string, string)>() - { - // Current config section & key pairs. Previous config section & key pairs. - { ("Components", "AdvancedIcons"), ("Components", "AdvanedIcons") }, - { ("Misc", "AdvancedPickupNotificationsEquipment"), ("Misc", "AdvancedPickupNotificationsEquipements") }, - { ("Misc", "HidePickupNotificationsItems"), ("Misc", "HidePickupNotificiationsItems") }, - { ("Misc", "HidePickupNotificationsEquipment"), ("Misc", "HidePickupNotificiationsEquipements") }, - { ("Misc", "HidePickupNotificationsArtifacts"), ("Misc", "HidePickupNotificiationsArtifacts") }, - { ("Equipment Improvements", "ShowCooldownStacks"), ("Equipement Improvements", "ShowCooldownStacks") }, - { ("Equipment Improvements", "AdvancedDescriptions"), ("Equipement Improvements", "AdvancedDescriptions") }, - { ("Equipment Improvements", "BaseCooldown"), ("Equipement Improvements", "BaseCooldown") }, - { ("Equipment Improvements", "CalculatedCooldown"), ("Equipement Improvements", "CalculatedCooldown") }, - { ("Components", "Buffs"), ("Components", "BuffTimers") }, - }; - - static ConfigManager() - { - ConfigFileComponents = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Components.cfg", true); - ConfigFileMisc = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Misc.cfg", true); - ConfigFileAdvancedIcons = new ConfigFile(Paths.ConfigPath + "\\BetterUI-AdvancedIcons.cfg", true); - ConfigFileBuffs = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Buffs.cfg", true); - ConfigFileCommandImprovements = new ConfigFile(Paths.ConfigPath + "\\BetterUI-CommandImprovements.cfg", true); - ConfigFileDPSMeter = new ConfigFile(Paths.ConfigPath + "\\BetterUI-DPSMeter.cfg", true); - ConfigFileItemCounters = new ConfigFile(Paths.ConfigPath + "\\BetterUI-ItemCounters.cfg", true); - ConfigFileStatsDisplay = new ConfigFile(Paths.ConfigPath + "\\BetterUI-StatsDisplay.cfg", true); - ConfigFileSorting = new ConfigFile(Paths.ConfigPath + "\\BetterUI-Sorting.cfg", true); - - // Components - - ComponentsAdvancedIcons = Bind(ConfigFileComponents, "Components", "AdvancedIcons", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsBuffTimers = Bind(ConfigFileComponents, "Components", "Buffs", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsCommandImprovements = Bind(ConfigFileComponents, "Components", "CommandImprovements", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsDPSMeter = Bind(ConfigFileComponents, "Components", "DPSMeter", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsItemCounters = Bind(ConfigFileComponents, "Components", "ItemCounters", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsItemSorting = Bind(ConfigFileComponents, "Components", "ItemSorting", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsMisc = Bind(ConfigFileComponents, "Components", "Misc", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - ComponentsStatsDisplay = Bind(ConfigFileComponents, "Components", "StatsDisplay", true, "Enable/Disable the component entirely, stopping it from hooking any game functions."); - - // Misc - - MiscShowHidden = Bind(ConfigFileMisc, "Misc", "ShowHidden", false, "Show hidden items in the item inventory."); - - MiscAdvancedPickupNotificationsItems = Bind(ConfigFileMisc, "Misc", "AdvancedPickupNotificationsItems", false, "Show advanced descriptions when picking up an item."); - - MiscAdvancedPickupNotificationsEquipements = Bind(ConfigFileMisc, "Misc", "AdvancedPickupNotificationsEquipment", false, "Show advanced descriptions when picking up equipment."); - - MiscHidePickupNotificiationsItems = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsItems", false, "Hide pickup notifications for items."); - - MiscHidePickupNotificiationsEquipements = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsEquipment", false, "Hide pickup notifications for equipment."); - - MiscHidePickupNotificiationsArtifacts = Bind(ConfigFileMisc, "Misc", "HidePickupNotificationsArtifacts", false, "Hide pickup notifications for artifacts."); - - MiscShowPickupDescription = Bind(ConfigFileMisc, "Misc", "ShowPickupDescription", true, "Show the item description on the interaction pop-up."); - - MiscPickupDescriptionAdvanced = Bind(ConfigFileMisc, "Misc", "PickupDescriptionAdvanced", false, "Show advanced descriptions for the interaction pop-up."); - - // Advanced Icons - - AdvancedIconsItemAdvancedDescriptions = Bind(ConfigFileAdvancedIcons, "Item Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over an item."); - - AdvancedIconsItemItemStatsIntegration = Bind(ConfigFileAdvancedIcons, "Item Improvements", "ItemStatsIntegration", true, "Show ItemStats where applicable."); - - AdvancedIconsEquipementShowCooldownStacks = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "ShowCooldownStacks", true, "Show the cooldown for your equipment when charging multiple stacks."); - - AdvancedIconsEquipementAdvancedDescriptions = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "AdvancedDescriptions", true, "Show advanced descriptions when hovering over equipment."); - - AdvancedIconsEquipementShowBaseCooldown = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over equipment."); - - AdvancedIconsEquipementShowCalculatedCooldown = Bind(ConfigFileAdvancedIcons, "Equipment Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over equipment."); - - AdvancedIconsSkillShowCooldownStacks = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "ShowCooldownStacks", true, "Show the cooldown for skills when charging multiple stacks."); - - AdvancedIconsSkillShowBaseCooldown = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "BaseCooldown", true, "Show the base cooldown when hovering over a skill."); - - AdvancedIconsSkillShowCalculatedCooldown = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "CalculatedCooldown", true, "Show the calculated cooldown based on your items when hovering over a skill."); - - AdvancedIconsSkillShowProcCoefficient = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "ShowProcCoefficient", true, "Show the proc coefficient when hovering over a skill."); - - AdvancedIconsSkillCalculateSkillProcEffects = Bind(ConfigFileAdvancedIcons, "Skill Improvements", "CalculateProcEffects", true, "Show the effects of carried items, adjusted for each skill's proc coefficient."); - - // Buffs - - BuffTimers = Bind(ConfigFileBuffs, "Buffs", "BuffTimers", true, "Show buff timers (host only)."); - - BuffTimersDecimal = Bind(ConfigFileBuffs, "Buffs", "BuffTimersDecimal", true, "Show 1 decimal point when timer is below 10."); - - BuffTooltips = Bind(ConfigFileBuffs, "Buffs", "BuffTooltips", true, "Show buff tooltips."); - - BuffTimersPosition = Bind(ConfigFileBuffs, "Buffs", "CountersPosition", "TopRight", - "Location of buff timer text.\n" + - "Valid options:\n" + - "TopLeft\n" + - "TopRight\n" + - "BottomLeft\n" + - "BottomRight\n" + - "Center\n"); - - BuffTimersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), BuffTimersPosition.Value, true); - - BuffTimersFontSize = Bind(ConfigFileBuffs, "Buffs", "CountersFontSize", 23f, "Size of the buff timer text."); - - // Command / Scrapper Improvements - - CommandResizeCommandWindow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "ResizeCommandWindow", true, "Resize the command window depending on the number of items."); - - CommandRemoveBackgroundBlur = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "RemoveBackgroundBlur", true, "Remove the blur behind the command window that hides the rest of the UI."); - - CommandCloseOnEscape = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnEscape", true, "Close the command/scrapper window when you press escape."); - - CommandCloseOnWASD = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnWASD", true, "Close the command/scrapper window when you press W, A, S, or D."); - - CommandCloseOnCustom = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CloseOnCustom", "", "Close the command/scrapper window when you press the key selected here.\n" + - "Example: space\n" + - "Must be lowercase. Leave blank to disable."); - - CommandTooltipsShow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "TooltipsShow", true, "Show tooltips in the command and scrapper windows."); - - CommandTooltipsItemStatsBeforeAfter = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "TooltipsItemStatsBeforeAfter", true, "Show the ItemStats before and after picking up the item."); - - CommandCountersShow = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersShow", true, "Show counters in the command and scrapper windows."); - - CommandCountersHideOnZero = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersHideOnZero", false, "Hide counters when they are zero."); - - CommandCountersPosition = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersPosition", "TopRight", - "Location of the command item counter.\n" + - "Valid options:\n" + - "TopLeft\n" + - "TopRight\n" + - "BottomLeft\n" + - "BottomRight\n" + - "Center\n"); - - CommandCountersTextAlignmentOption = (TMPro.TextAlignmentOptions)Enum.Parse(typeof(TMPro.TextAlignmentOptions), CommandCountersPosition.Value, true); - - CommandCountersFontSize = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersFontSize", 20f, "Size of the command item counter text."); - - CommandCountersPrefix = Bind(ConfigFileCommandImprovements, "Command / Scrapper Improvements", "CountersPrefix", "x", "Prefix for the command item counter. Example 'x' will show x0, x1, x2, etc.\nCan be empty."); - - // DPSMeter - - DPSMeterTimespan = Bind(ConfigFileDPSMeter, "DPSMeter", "Timespan", 5f, "Calculate DPS across this many seconds."); - - DPSMeterWindowShow = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowShow", true, "Show a dedicated DPSMeter."); - - DPSMeterWindowIncludeMinions = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowIncludeMinions", true, "Include minions such as turrets and drones in the DPS meter."); - - DPSMeterWindowBackground = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowBackground", true, "Whether or not the DPS window should have a background."); - - DPSMeterWindowHideWhenTyping = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowHideWhenTyping", true, "Whether or not the DPS window should be hidden when typing into the chat box."); - - DPSMeterWindowAnchorMin = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAnchorMin", new Vector2(0, 0), - "Screen position the lower left window corner is anchored to.\n" + - "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + - "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); - - DPSMeterWindowAnchorMax = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAnchorMax", new Vector2(0, 0f), - "Screen position the upper right window corner is anchored to.\n" + - "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + - "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); - - DPSMeterWindowPosition = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowPosition", new Vector2(120, 240), "Position of the DPSMeter window relative to the anchor."); - - DPSMeterWindowPivot = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowPivot", new Vector2(0, 1), "Pivot of the DPSMeter window.\n" + - "Window Position is from the anchor to the pivot."); - - DPSMeterWindowSize = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowSize", new Vector2(350, 45), "Size of the DPSMeter window."); - - DPSMeterWindowAngle = Bind(ConfigFileDPSMeter, "DPSMeter", "WindowAngle", new Vector3(0, -6, 0), "Angle of the DPSMeter window."); - - // ItemCounters - - ItemCountersShowItemCounters = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemCounters", true, "Enable/Disable ItemCounters entirely."); - - ItemCountersShowItemScore = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemScore", true, "Show your item score."); - - ItemCountersItemScoreFromTier = Bind(ConfigFileItemCounters, "ItemCounters", "ItemScoreFromTier", true, "Whether or not the ItemScore should be based on tier. If disabled, the per-item settings will be used."); - - ItemCountersShowItemSum = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemSum", true, "Show the how many items you have."); - - ItemCountersItemSumTiersString = Bind(ConfigFileItemCounters, "ItemCounters", "ItemSumTiersString", "01234", "Which tiers to include in the ItemSum.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); - - ItemCountersItemSumTiers = ItemCountersItemSumTiersString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); - - - ItemCountersShowItemsByTier = Bind(ConfigFileItemCounters, "ItemCounters", "ShowItemsByTier", true, "Show how many items you have, by tier."); - - ItemCountersItemsByTierOrderString = Bind(ConfigFileItemCounters, "ItemCounters", "ItemsByTierOrderString", "43210", "Which tiers to include in the ItemsByTier, in order.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); - - ItemCountersItemsByTierOrder = ItemCountersItemsByTierOrderString.Value.ToCharArray().Select(c => (ItemTier)char.GetNumericValue(c)).ToList(); - - ItemCountersTierScoreTier1 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier1", 1f, "Score for Tier 1 items."); - ItemCountersTierScoreTier2 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier2", 3f, "Score for Tier 2 items."); - ItemCountersTierScoreTier3 = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Tier3", 12f, "Score for Tier 3 items."); - ItemCountersTierScoreLunar = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Lunar", 0f, "Score for Lunar items."); - ItemCountersTierScoreBoss = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "Boss", 4f, "Score for Boss items."); - ItemCountersTierScoreNoTier = Bind(ConfigFileItemCounters, "ItemCounters Tier Score", "NoTier", 0f, "Score for items without a tier."); - - ItemCountersTierScores = new Dictionary() - { - { ItemTier.Tier1, ItemCountersTierScoreTier1.Value }, - { ItemTier.VoidTier1, ItemCountersTierScoreTier1.Value }, - { ItemTier.Tier2, ItemCountersTierScoreTier2.Value}, - { ItemTier.VoidTier2, ItemCountersTierScoreTier2.Value}, - { ItemTier.Tier3, ItemCountersTierScoreTier3.Value}, - { ItemTier.VoidTier3, ItemCountersTierScoreTier3.Value}, - { ItemTier.Lunar, ItemCountersTierScoreLunar.Value}, - { ItemTier.Boss, ItemCountersTierScoreBoss.Value}, - { ItemTier.VoidBoss, ItemCountersTierScoreBoss.Value}, - { ItemTier.NoTier, ItemCountersTierScoreNoTier.Value}, - }; - - - ItemCountersItemScores = new Dictionary(); - - - // StatsDisplay - - StatsDisplayEnable = Bind(ConfigFileStatsDisplay, "StatsDisplay", "Enable", true, "Enable/Disable the StatsDisplay entirely."); - - StatsDisplayStatString = Bind(ConfigFileStatsDisplay, "StatsDisplay", "StatString", - "" + - "Stats\n" + - "Luck: $luck\n" + - "Base Damage: $dmg\n" + - "Crit Chance: $luckcrit%\n" + - "Attack Speed: $atkspd\n" + - "Armor: $armor | $armordmgreduction%\n" + - "Regen: $regen\n" + - "Speed: $velocity\n" + - "Jumps: $jumps/$maxjumps\n" + - "Kills: $killcount\n" + - "Mountain Shrines: $mountainshrines\n", - "You may format the StatString using formatting tags such as color, size, bold, underline, italics. See Readme for more.\n" + - "Valid Parameters:\n" + - string.Join(" ", StatsDisplay.regexmap.Keys)); - - StatsDisplayStatStringCustomBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "StatStringCustomBind", - "" + - "Stats\n" + - "Luck: $luck\n" + - "Experience: $exp/$maxexp\n" + - "Base Damage: $dmg\n" + - "Crit Chance: $crit%\n" + - "Crit w/ Luck: $luckcrit%\n" + - "Crit Damage: $critdamage\n" + - "Attack Speed: $atkspd\n" + - "Armor: $armor | $armordmgreduction%\n" + - "Regen: $regen\n" + - "Speed: $velocity\n" + - "Jumps: $jumps/$maxjumps\n" + - "Kills: $killcount\n" + - "Mountain Shrines: $mountainshrines\n" + - "Difficulty: $difficulty\n" + - "Blue Portal: $blueportal\n" + - "Gold Portal: $goldportal\n" + - "Celestial Portal: $celestialportal\n" + - "Void Portal: $voidportal\n", - "StatDisplay string to show when the custom bind is being pressed. This can be the same or different from the normal StatString."); - - StatsDisplayCustomBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "CustomBind", "tab", "Bind to show secondary StatsDisplay string.\n" + - "Example: space\n" + - "Must be lowercase. Leave blank to disable."); - - StatsDisplayShowCustomBindOnly = Bind(ConfigFileStatsDisplay, "StatsDisplay", "ShowCustomBindOnly", false, "Only show the StatsDisplay when the scoreboard is open."); - - StatsDisplayToggleOnBind = Bind(ConfigFileStatsDisplay, "StatsDisplay", "ToggleOnBind", false, "Toggle the StatsDisplay when the bind is pressed rather than showing it when it is held."); - - StatsDisplayPanelBackground = Bind(ConfigFileStatsDisplay, "StatsDisplay", "PanelBackground", true, "Whether or not the StatsDisplay panel should have a background."); - - StatsDisplayAttachToObjectivePanel = Bind(ConfigFileStatsDisplay, "StatsDisplay", "AttachToObjectivePanel", true, "Whether to attach the stats display to the objective panel.\n" + - "If not, it will be a free-floating window that can be moved with the options below."); - - StatsDisplayWindowAnchorMin = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAnchorMin", new Vector2(1, 0.5f), - "Screen position the lower left window corner is anchored to.\n" + - "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + - "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); - - StatsDisplayWindowAnchorMax = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAnchorMax", new Vector2(1, 0.5f), - "Screen position the upper right window corner is anchored to.\n" + - "X & Y can be any number from 0.0 to 1.0 (inclusive).\n" + - "Screen position starts at the bottom-left (0.0, 0.0) and increases toward the top-right (1.0, 1.0)."); - - StatsDisplayWindowPosition = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowPosition", new Vector2(-210, 100), "Position of the StatsDisplay window relative to the anchor."); - - StatsDisplayWindowPivot = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowPivot", new Vector2(0, 0.5f), "Pivot of the StatsDisplay window.\n" + - "Window Position is from the anchor to the pivot."); - - StatsDisplayWindowSize = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowSize", new Vector2(200, 600), "Size of the StatsDisplay window."); - - StatsDisplayWindowAngle = Bind(ConfigFileStatsDisplay, "StatsDisplay", "WindowAngle", new Vector3(0, 6, 0), "Angle of the StatsDisplay window."); - - // Sorting - - SortingSortItemsInventory = Bind(ConfigFileSorting, "Sorting", "SortItemsInventory", true, "Sort items in the inventory and scoreboard."); - - SortingSortItemsCommand = Bind(ConfigFileSorting, "Sorting", "SortItemsCommand", true, "Sort items in the command window."); - - SortingSortItemsScrapper = Bind(ConfigFileSorting, "Sorting", "SortItemsScrapper", true, "Sort items in the scrapper window."); - - SortingTierOrderString = Bind(ConfigFileSorting, "Sorting", "TierOrder", "012345", "Tiers in ascending order, left to right.\n0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier"); - - SortingTierOrder = new int[] - { - SortingTierOrderString.Value.IndexOf('0'), - SortingTierOrderString.Value.IndexOf('1'), - SortingTierOrderString.Value.IndexOf('2'), - SortingTierOrderString.Value.IndexOf('3'), - SortingTierOrderString.Value.IndexOf('4'), - SortingTierOrderString.Value.IndexOf('5'), - }; - - SortingSortOrder = Bind(ConfigFileSorting, "Sorting", "SortOrder", "S134", - "What to sort the items by, most important to least important.\n" + - "Find the full details and an example in the Readme on Thunderstore/Github.\n" + - "0 = Tier Ascending\n" + - "1 = Tier Descending\n" + - "2 = Stack Size Ascending\n" + - "3 = Stack Size Descending\n" + - "4 = Pickup Order\n" + - "5 = Pickup Order Reversed\n" + - "6 = Alphabetical\n" + - "7 = Alphabetical Reversed\n" + - "8 = Random\n" + - "i = ItemIndex\n" + - "I = ItemIndex Descending\n" + - "\n" + - "Tag Based:\n" + - "s = Scrap First\n" + - "S = Scrap Last\n" + - "d = Damage First\n" + - "D = Damage Last\n" + - "h = Healing First\n" + - "H = Healing Last\n" + - "u = Utility First\n" + - "U = Utility Last\n" + - "o = On Kill Effect First\n" + - "O = On Kill Effect Last\n" + - "e = Equipment Related First\n" + - "E = Equipment Related Last\n" + - "p = Sprint Related First\n" + - "P = Sprint Related Last"); - - SortingSortOrderCommand = Bind(ConfigFileSorting, "Sorting", "SortOrderCommand", "6", - "Sort order for the command window.\n" + - "The command window has a special sort option \"C\" which will place the last selected item in the middle.\n" + - "Note: This option must be the last one in the SortOrderCommand option."); - - SortingSortOrderScrapper = Bind(ConfigFileSorting, "Sorting", "SortOrderScrapper", "134", - "Sort order for the scrapper window."); - - } - - /// - /// Automatically transfers the value of old config entries to new config entries based on - /// . Old config entries are deleted after their value has - /// been transferred.
- /// Wraps . - ///
- /// File containing the config entry.. - /// Section/category/group of the setting. Settings are grouped by this. - /// Name of the setting. - /// Value of the setting if the setting was not created yet. - /// Simple description of the setting shown to the user. - /// Type of the value contained in this setting. - static ConfigEntry Bind(ConfigFile config, string section, string key, T defaultValue, string description) - { - var currentEntry = config.Bind(section, key, defaultValue, description); - - if (previousEntryMap.ContainsKey((section, key))) - { - var previousTuple = previousEntryMap[(section, key)]; - var previousDefinition = new ConfigDefinition(previousTuple.Item1, previousTuple.Item2); - // ConfigFile has to Bind to a Section + Key before it knows that it's in the file. - var previousEntry = config.Bind(previousDefinition, "If you ever set your config option to this, it's your own fault", new ConfigDescription(description)); - if(previousEntry.Value != "If you ever set your config option to this, it's your own fault") - { - // Let ConfigBaseEntry deal with type parsing. - currentEntry.SetSerializedValue(previousEntry.GetSerializedValue()); - } - config.Remove(previousDefinition); - } - - return currentEntry; - } - } -} diff --git a/ModComponents/AdvancedIcons.cs b/ModComponents/AdvancedIcons.cs deleted file mode 100644 index 757eb03f..00000000 --- a/ModComponents/AdvancedIcons.cs +++ /dev/null @@ -1,356 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using RoR2; -using RoR2.UI; -using RoR2.Skills; -using UnityEngine; -using Mono.Cecil.Cil; -using MonoMod.Cil; - -namespace BetterUI -{ - static class AdvancedIcons - { - static Dictionary EquipmentIconDirty = new Dictionary(); - static Dictionary lastEquipment = new Dictionary(); - - static Dictionary SkillIconDirty = new Dictionary(); - static Dictionary lastSkill = new Dictionary(); - - static List procCoefficientInfos; - static Inventory inventory; - static CharacterBody targetbody; - - static AdvancedIcons() - { - BetterUIPlugin.onHUDAwake += onHUDAwake; - RoR2Application.onLoad += onRoR2ApplicationLoad; - } - internal static void Hook() - { - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value || - ConfigManager.AdvancedIconsSkillCalculateSkillProcEffects.Value || - ConfigManager.AdvancedIconsSkillShowBaseCooldown.Value || - ConfigManager.AdvancedIconsEquipementShowCalculatedCooldown.Value) - { - BetterUIPlugin.Hooks.Add("FromSkillSlot", LoadoutPanelController_Row_FromSkillSlot); - BetterUIPlugin.Hooks.Add("AddButton", (LoadoutPanelController_Row_AddButton_Delegate)LoadoutPanelController_Row_AddButton); - BetterUIPlugin.Hooks.Add("Update", SkillIcon_Update); - BetterUIPlugin.Hooks.Add("OnInventoryChanged", CharacterMaster_OnInventoryChanged); - } - if (ConfigManager.AdvancedIconsItemAdvancedDescriptions.Value) - { - BetterUIPlugin.Hooks.Add("SetItemIndex", ItemIcon_SetItemIndex); - BetterUIPlugin.Hooks.Add("UpdateDisplay", ItemInventoryDisplay_UpdateDisplay); - } - if (ConfigManager.AdvancedIconsEquipementAdvancedDescriptions.Value || - ConfigManager.AdvancedIconsEquipementShowBaseCooldown.Value || - ConfigManager.AdvancedIconsEquipementShowCalculatedCooldown.Value) - { - BetterUIPlugin.Hooks.Add("Update", EquipmentIcon_Update); - } - } - - private static void onHUDAwake(HUD self) - { - EquipmentIconDirty.Clear(); - lastEquipment.Clear(); - SkillIconDirty.Clear(); - lastSkill.Clear(); - } - - private static void onRoR2ApplicationLoad() - { - SkillCatalog.GetSkillDef(Utils.TheREALFindSkillIndexByName("FireCorruptBeam")).skillDescriptionToken = "VOIDSURVIVOR_PRIMARY_ALT_DESCRIPTION"; - SkillCatalog.GetSkillDef(Utils.TheREALFindSkillIndexByName("FireCorruptDisk")).skillDescriptionToken = "VOIDSURVIVOR_SECONDARY_ALT_DESCRIPTION"; - SkillCatalog.GetSkillDef(Utils.TheREALFindSkillIndexByName("VoidBlinkDown")).skillDescriptionToken = "VOIDSURVIVOR_UTILITY_ALT_DESCRIPTION"; - SkillCatalog.GetSkillDef(Utils.TheREALFindSkillIndexByName("CrushHealth")).skillDescriptionToken = "VOIDSURVIVOR_SPECIAL_ALT_DESCRIPTION"; - } - - public static CharacterMaster updateDisplayMaster; - - internal static void ItemInventoryDisplay_UpdateDisplay(Action orig, ItemInventoryDisplay self) - { - updateDisplayMaster = self?.inventory?.gameObject.GetComponent(); - orig(self); - updateDisplayMaster = null; - } - - private static void ItemIcon_SetItemIndex(Action orig, RoR2.UI.ItemIcon self, ItemIndex itemIndex, int itemCount) - { - orig(self, itemIndex, itemCount); - - if (ConfigManager.AdvancedIconsItemItemStatsIntegration.Value && updateDisplayMaster != null) - { - var itemDef = ItemCatalog.GetItemDef(itemIndex); - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append( - RoR2.Language.GetString(itemDef.descriptionToken ?? itemDef.pickupToken ?? "") - ); - BetterUIPlugin.sharedStringBuilder.Append("\n"); - ItemStats.GetItemStats(BetterUIPlugin.sharedStringBuilder, itemDef, itemCount, updateDisplayMaster); - self.tooltipProvider.overrideBodyText = BetterUIPlugin.sharedStringBuilder.ToString(); - } - else - { - self.tooltipProvider.bodyToken = ItemCatalog.GetItemDef(itemIndex).descriptionToken; - } - } - - private static void CharacterMaster_OnInventoryChanged(Action orig, CharacterMaster self) - { - orig(self); - - if (self.inventory) - { - foreach (EquipmentIcon equipment in new List(EquipmentIconDirty.Keys)) - { - if (equipment && equipment.targetInventory == self.inventory) - { - EquipmentIconDirty[equipment] = true; - } - } - foreach (SkillIcon skill in new List(SkillIconDirty.Keys)) - { - if (skill && skill.playerCharacterMasterController && skill.playerCharacterMasterController.master == self) - { - SkillIconDirty[skill] = true; - } - } - } - } - - internal static SkillDef skillDef; - - internal static void LoadoutPanelController_Row_FromSkillSlot(ILContext il) - { - var c = new ILCursor(il); - bool matchFound = c.TryGotoNext(MoveType.After, - x => x.MatchLdfld(nameof(SkillFamily.Variant.skillDef)) - ); - if (matchFound) - { - c.Emit(OpCodes.Dup); - c.EmitDelegate>(x => skillDef = x); - } - } - - internal delegate void LoadoutPanelController_Row_AddButton_Delegate(Action orig, - RoR2.UI.LoadoutPanelController.Row self, LoadoutPanelController owner, Sprite icon, string titleToken, string bodyToken, Color tooltipColor, UnityEngine.Events.UnityAction callback, string unlockableName, ViewablesCatalog.Node viewableNode, bool isWIP = false); - internal static void LoadoutPanelController_Row_AddButton(Action orig, - RoR2.UI.LoadoutPanelController.Row self, LoadoutPanelController owner, Sprite icon, string titleToken, string bodyToken, Color tooltipColor, UnityEngine.Events.UnityAction callback, string unlockableName, ViewablesCatalog.Node viewableNode, bool isWIP = false) - { - orig(self, owner, icon, titleToken, bodyToken, tooltipColor, callback, unlockableName, viewableNode, isWIP); - - LoadoutPanelController.Row selfRow = (LoadoutPanelController.Row)self; - UserProfile userProfile = selfRow.userProfile; - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value || ConfigManager.AdvancedIconsSkillShowBaseCooldown.Value) - { - if (userProfile != null && userProfile.HasUnlockable(unlockableName)) - { - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append(RoR2.Language.GetString(bodyToken)); - if (ConfigManager.AdvancedIconsSkillShowBaseCooldown.Value && skillDef != null) - { - BetterUIPlugin.sharedStringBuilder.Append("\n\n") - .Append(RoR2.Language.GetString("BETTERUI_COOLDOWN")) - .Append(": ") - .Append(skillDef.baseRechargeInterval) - .Append(" ") - .Append(RoR2.Language.GetString(BetterUI.Language.GetPluralToken("BETTERUI_SECOND", skillDef.baseRechargeInterval))); - } - - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value && skillDef != null) - { - List procCoefficientInfos = ProcCoefficientCatalog.GetProcCoefficientInfo(SkillCatalog.GetSkillName(skillDef.skillIndex)); - - if (procCoefficientInfos != null) - { - foreach (var info in procCoefficientInfos) - { - BetterUIPlugin.sharedStringBuilder.Append("\n\n") - .Append(RoR2.Language.GetString(info.name)) - .Append(":"); - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n ") - .Append(RoR2.Language.GetString("BETTERUI_PROCCOEFFICIENT")) - .Append(": ") - .Append(info.procCoefficient) - .Append(""); - } - } - - - } - } - TooltipProvider tooltipProvider = selfRow.buttons[selfRow.buttons.Count - 1].GetComponent(); - if (tooltipProvider != null) - { - tooltipProvider.overrideBodyText = BetterUIPlugin.sharedStringBuilder.ToString(); - } - } - } - skillDef = null; - } - internal static void SkillIcon_Update(Action orig, SkillIcon self) - { - orig(self); - - if (!SkillIconDirty.ContainsKey(self)) - { - SkillIconDirty.Add(self, true); - lastSkill.Add(self, null); - } - if (self.targetSkill && (self.targetSkill.skillDef != lastSkill[self] || SkillIconDirty[self])) - { - lastSkill[self] = self.targetSkill.skillDef; - SkillIconDirty[self] = false; - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append(RoR2.Language.GetString(self.targetSkill.skillDescriptionToken)); - if (ConfigManager.AdvancedIconsSkillShowBaseCooldown.Value || ConfigManager.AdvancedIconsSkillShowCalculatedCooldown.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n"); - } - if (ConfigManager.AdvancedIconsSkillShowBaseCooldown.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n") - .Append(RoR2.Language.GetString("BETTERUI_BASECOOLDOWN")) - .Append(": ") - .Append(self.targetSkill.baseRechargeInterval) - .Append(" ") - .Append(RoR2.Language.GetString(BetterUI.Language.GetPluralToken("BETTERUI_SECOND", self.targetSkill.baseRechargeInterval))); - } - if (ConfigManager.AdvancedIconsSkillShowCalculatedCooldown.Value && self.targetSkill.baseRechargeInterval > self.targetSkill.finalRechargeInterval) - { - BetterUIPlugin.sharedStringBuilder.Append("\n") - .Append(RoR2.Language.GetString("BETTERUI_EFFECTIVECOOLDOWN")) - .Append(": ") - .Append(self.targetSkill.finalRechargeInterval) - .Append(" ") - .Append(RoR2.Language.GetString(BetterUI.Language.GetPluralToken("BETTERUI_SECOND", self.targetSkill.baseRechargeInterval))); - } - - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value || ConfigManager.AdvancedIconsSkillCalculateSkillProcEffects.Value) - { - procCoefficientInfos = ProcCoefficientCatalog.GetProcCoefficientInfo(SkillCatalog.GetSkillName(self.targetSkill.skillDef.skillIndex)); - - if (procCoefficientInfos != null) - { - foreach (var info in procCoefficientInfos) - { - BetterUIPlugin.sharedStringBuilder.Append("\n\n") - .Append(RoR2.Language.GetString(info.name)) - .Append(""); - if (ConfigManager.AdvancedIconsSkillShowProcCoefficient.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n ") - .Append(RoR2.Language.GetString("BETTERUI_PROCCOEFFICIENT")) - .Append(": ") - .Append(info.procCoefficient) - .Append(""); - } - if (info.procCoefficient > 0 && ConfigManager.AdvancedIconsSkillCalculateSkillProcEffects.Value) - { - foreach (var item in ItemStats.itemProcInfos) - { - int stacks = self.targetSkill.characterBody.inventory.GetItemCount(item.Key); - if (stacks > 0) - { - BetterUIPlugin.sharedStringBuilder.Append("\n ") - .Append(RoR2.Language.GetString(item.Key.nameToken)) - .Append(": "); - item.Value.GetOutputString(BetterUIPlugin.sharedStringBuilder, stacks, self.targetSkill.characterBody.master, info.procCoefficient); - } - } - } - } - } - } - - self.tooltipProvider.overrideBodyText = BetterUIPlugin.sharedStringBuilder.ToString(); - } - - if (ConfigManager.AdvancedIconsSkillShowCooldownStacks.Value && self.targetSkill && self.targetSkill.cooldownRemaining > 0) - { - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.AppendInt(Mathf.CeilToInt(self.targetSkill.cooldownRemaining), 0U, uint.MaxValue); - self.cooldownText.SetText(BetterUIPlugin.sharedStringBuilder); - self.cooldownText.gameObject.SetActive(true); - } - } - - internal static void EquipmentIcon_Update(Action orig, EquipmentIcon self) - { - orig(self); - - if (!EquipmentIconDirty.ContainsKey(self)) - { - EquipmentIconDirty.Add(self, true); - lastEquipment.Add(self, null); - } - if ((ConfigManager.AdvancedIconsEquipementAdvancedDescriptions.Value || - ConfigManager.AdvancedIconsEquipementShowBaseCooldown.Value || - ConfigManager.AdvancedIconsEquipementShowCalculatedCooldown.Value) && - (self.currentDisplayData.equipmentDef != lastEquipment[self] || EquipmentIconDirty[self]) && - self.currentDisplayData.hasEquipment && self.tooltipProvider) - { - lastEquipment[self] = self.currentDisplayData.equipmentDef; - EquipmentIconDirty[self] = false; - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append(RoR2.Language.GetString(ConfigManager.AdvancedIconsEquipementAdvancedDescriptions.Value ? self.currentDisplayData.equipmentDef.descriptionToken : self.currentDisplayData.equipmentDef.pickupToken)); - if (ConfigManager.AdvancedIconsEquipementShowBaseCooldown.Value || ConfigManager.AdvancedIconsEquipementShowCalculatedCooldown.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n"); - } - if (ConfigManager.AdvancedIconsEquipementShowBaseCooldown.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n") - .Append(RoR2.Language.GetString("BETTERUI_BASECOOLDOWN")) - .Append(": ") - .Append(self.currentDisplayData.equipmentDef.cooldown) - .Append(" ") - .Append(RoR2.Language.GetString(BetterUI.Language.GetPluralToken("BETTERUI_SECOND", self.currentDisplayData.equipmentDef.cooldown))); - } - if (ConfigManager.AdvancedIconsEquipementShowCalculatedCooldown.Value) - { - inventory = self.targetInventory; - if (!inventory && BetterUIPlugin.hud.targetBodyObject) - { - targetbody = BetterUIPlugin.hud.targetBodyObject.GetComponent(); - if (targetbody) - { - inventory = targetbody.inventory; - } - } - if (inventory) - { - float reduction = (float)Math.Pow(0.85, inventory.GetItemCount(RoR2.RoR2Content.Items.EquipmentMagazine)); - if (inventory.GetItemCount(RoR2.RoR2Content.Items.AutoCastEquipment.itemIndex) > 0) - { - reduction *= 0.5f * (float)Math.Pow(0.85, inventory.GetItemCount(RoR2.RoR2Content.Items.AutoCastEquipment.itemIndex) - 1); - } - if (reduction < 1) - { - BetterUIPlugin.sharedStringBuilder.Append("\n") - .Append(RoR2.Language.GetString("BETTERUI_EFFECTIVECOOLDOWN")) - .Append(": ") - .Append((self.currentDisplayData.equipmentDef.cooldown * reduction).ToString("0.###")) - .Append(" ") - .Append(RoR2.Language.GetString(BetterUI.Language.GetPluralToken("BETTERUI_SECOND", self.currentDisplayData.equipmentDef.cooldown))); - } - } - } - - - self.tooltipProvider.overrideBodyText = BetterUIPlugin.sharedStringBuilder.ToString(); - } - - if (ConfigManager.AdvancedIconsEquipementShowCooldownStacks.Value && self.cooldownText && self.currentDisplayData.cooldownValue > 0) - { - self.cooldownText.gameObject.SetActive(true); - } - } - } -} diff --git a/ModComponents/Buffs.cs b/ModComponents/Buffs.cs deleted file mode 100644 index e9ba861d..00000000 --- a/ModComponents/Buffs.cs +++ /dev/null @@ -1,261 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; - -using UnityEngine; -using RoR2; -using BetterUI.ModCompatibility; - -namespace BetterUI -{ - public static class Buffs - { - static IEnumerable timedBuffs; - static CharacterBody.TimedBuff thisBuff; - static readonly Dictionary buffInfos = new Dictionary(); - - static Buffs() - { - ItemCatalog.availability.CallWhenAvailable(() => - { - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixRed, "BUFF_AFFIXRED_NAME", "BUFF_AFFIXRED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixBlue, "BUFF_AFFIXBLUE_NAME", "BUFF_AFFIXBLUE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixWhite, "BUFF_AFFIXWHITE_NAME", "BUFF_AFFIXWHITE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixPoison, "BUFF_AFFIXPOISON_NAME", "BUFF_AFFIXPOISON_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixHaunted, "BUFF_AFFIXHAUNTED_NAME", "BUFF_AFFIXHAUNTED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixLunar, "BUFF_AFFIXLUNAR_NAME", "BUFF_AFFIXLUNAR_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.ArmorBoost, "BUFF_ARMORBOOST_NAME", "BUFF_ARMORBOOST_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AttackSpeedOnCrit, "BUFF_ATTACKSPEEDONCRIT_NAME", "BUFF_ATTACKSPEEDONCRIT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.BugWings, "BUFF_BUGWINGS_NAME", "BUFF_BUGWINGS_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Cloak, "BUFF_CLOAK_NAME", "BUFF_CLOAK_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.CloakSpeed, "BUFF_CLOAKSPEED_NAME", "BUFF_CLOAKSPEED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.AffixHauntedRecipient, "BUFF_AFFIXHAUNTEDRECIPIENT_NAME", "BUFF_AFFIXHAUNTEDRECIPIENT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.ElephantArmorBoost, "BUFF_ELEPHANTARMORBOOST_NAME", "BUFF_ELEPHANTARMORBOOST_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Energized, "BUFF_ENERGIZED_NAME", "BUFF_ENERGIZED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.FullCrit, "BUFF_FULLCRIT_NAME", "BUFF_FULLCRIT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.HiddenInvincibility, "BUFF_HIDDENINVINCIBILITY_NAME", "BUFF_HIDDENINVINCIBILITY_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Immune, "BUFF_IMMUNE_NAME", "BUFF_IMMUNE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.CrocoRegen, "BUFF_CROCOREGEN_NAME", "BUFF_CROCOREGEN_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.MedkitHeal, "BUFF_MEDKITHEAL_NAME", "BUFF_MEDKITHEAL_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.NoCooldowns, "BUFF_NOCOOLDOWNS_NAME", "BUFF_NOCOOLDOWNS_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.TeslaField, "BUFF_TESLAFIELD_NAME", "BUFF_TESLAFIELD_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.TonicBuff, "BUFF_TONICBUFF_NAME", "BUFF_TONICBUFF_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Warbanner, "BUFF_WARBANNER_NAME", "BUFF_WARBANNER_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.WarCryBuff, "BUFF_WARCRYBUFF_NAME", "BUFF_WARCRYBUFF_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.TeamWarCry, "BUFF_TEAMWARCRY_NAME", "BUFF_TEAMWARCRY_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.WhipBoost, "BUFF_WHIPBOOST_NAME", "BUFF_WHIPBOOST_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.LifeSteal, "BUFF_LIFESTEAL_NAME", "BUFF_LIFESTEAL_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.PowerBuff, "BUFF_POWERBUFF_NAME", "BUFF_POWERBUFF_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.ElementalRingsReady, "BUFF_ELEMENTALRINGSREADY_NAME", "BUFF_ELEMENTALRINGSREADY_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.BanditSkull, "BUFF_BANDITSKULL_NAME", "BUFF_BANDITSKULL_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.LaserTurbineKillCharge, "BUFF_LASERTURBINEKILLCHARGE_NAME", "BUFF_LASERTURBINEKILLCHARGE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.OnFire, "BUFF_ONFIRE_NAME", "BUFF_ONFIRE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Bleeding, "BUFF_BLEEDING_NAME", "BUFF_BLEEDING_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.SuperBleed, "BUFF_SUPERBLEED_NAME", "BUFF_SUPERBLEED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Poisoned, "BUFF_POISONED_NAME", "BUFF_POISONED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Blight, "BUFF_BLIGHT_NAME", "BUFF_BLIGHT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.MercExpose, "BUFF_MERCEXPOSE_NAME", "BUFF_MERCEXPOSE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.DeathMark, "BUFF_DEATHMARK_NAME", "BUFF_DEATHMARK_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.PulverizeBuildup, "BUFF_PULVERIZEBUILDUP_NAME", "BUFF_PULVERIZEBUILDUP_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Pulverized, "BUFF_PULVERIZED_NAME", "BUFF_PULVERIZED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Cripple, "BUFF_CRIPPLE_NAME", "BUFF_CRIPPLE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Weak, "BUFF_WEAK_NAME", "BUFF_WEAK_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.BeetleJuice, "BUFF_BEETLEJUICE_NAME", "BUFF_BEETLEJUICE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.ClayGoo, "BUFF_CLAYGOO_NAME", "BUFF_CLAYGOO_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Slow50, "BUFF_SLOW50_NAME", "BUFF_SLOW50_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Slow60, "BUFF_SLOW60_NAME", "BUFF_SLOW60_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Slow80, "BUFF_SLOW80_NAME", "BUFF_SLOW80_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.NullifyStack, "BUFF_NULLIFYSTACK_NAME", "BUFF_NULLIFYSTACK_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Nullified, "BUFF_NULLIFIED_NAME", "BUFF_NULLIFIED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Entangle, "BUFF_ENTANGLE_NAME", "BUFF_ENTANGLE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Fruiting, "BUFF_FRUITING_NAME", "BUFF_FRUITING_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.HealingDisabled, "BUFF_HEALINGDISABLED_NAME", "BUFF_HEALINGDISABLED_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.ElementalRingsCooldown, "BUFF_ELEMENTALRINGSCOOLDOWN_NAME", "BUFF_ELEMENTALRINGSCOOLDOWN_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.PermanentCurse, "BUFF_PERMANENTCURSE_NAME", "BUFF_PERMANENTCURSE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.Overheat, "BUFF_OVERHEAT_NAME", "BUFF_OVERHEAT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.LunarSecondaryRoot, "BUFF_LUNARSECONDARYROOT_NAME", "BUFF_LUNARSECONDARYROOT_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.LunarDetonationCharge, "BUFF_LUNARDETONATIONCHARGE_NAME", "BUFF_LUNARDETONATIONCHARGE_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.EngiShield, "BUFF_ENGISHIELD_NAME", "BUFF_ENGISHIELD_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.LunarShell, "BUFF_LUNARSHELL_NAME", "BUFF_LUNARSHELL_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.VoidFogMild, "BUFF_VOIDFOGMILD_NAME", "BUFF_VOIDFOGMILD_DESC"); - RegisterBuffInfo(RoR2.RoR2Content.Buffs.VoidFogStrong, "BUFF_VOIDFOGSTRONG_NAME", "BUFF_VOIDFOGSTRONG_DESC"); - - RegisterBuffInfo(RoR2.JunkContent.Buffs.BodyArmor, "BUFF_BODYARMOR_NAME", "BUFF_BODYARMOR_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.Deafened, "BUFF_DEAFENED_NAME", "BUFF_DEAFENED_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.EngiTeamShield, "BUFF_ENGITEAMSHIELD_NAME", "BUFF_ENGITEAMSHIELD_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.EnrageAncientWisp, "BUFF_ENRAGEANCIENTWISP_NAME", "BUFF_ENRAGEANCIENTWISP_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.GoldEmpowered, "BUFF_GOLDEMPOWERED_NAME", "BUFF_GOLDEMPOWERED_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.LightningShield, "BUFF_LIGHTNINGSHIELD_NAME", "BUFF_LIGHTNINGSHIELD_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.LoaderOvercharged, "BUFF_LOADEROVERCHARGED_NAME", "BUFF_LOADEROVERCHARGED_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.LoaderPylonPowered, "BUFF_LOADERPYLONPOWERED_NAME", "BUFF_LOADERPYLONPOWERED_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.MeatRegenBoost, "BUFF_MEATREGENBOOST_NAME", "BUFF_MEATREGENBOOST_DESC"); - RegisterBuffInfo(RoR2.JunkContent.Buffs.Slow30, "BUFF_SLOW30_NAME", "BUFF_SLOW30_DESC"); - - - RegisterBuffInfo(RoR2.DLC1Content.Buffs.BearVoidCooldown, "BUFF_BEARVOIDCOOLDOWN_NAME", "BUFF_BEARVOIDCOOLDOWN_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.BearVoidReady, "BUFF_BEARVOIDREADY_NAME", "BUFF_BEARVOIDREADY_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.Blinded, "BUFF_BLINDED_NAME", "BUFF_BLINDED_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.ElementalRingVoidCooldown, "BUFF_ELEMENTALRINGVOIDCOOLDOWN_NAME", "BUFF_ELEMENTALRINGVOIDCOOLDOWN_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.ElementalRingVoidReady, "BUFF_ELEMENTALRINGVOIDREADY_NAME", "BUFF_ELEMENTALRINGVOIDREADY_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.EliteEarth, "BUFF_ELITEEARTH_NAME", "BUFF_ELITEEARTH_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.EliteVoid, "BUFF_ELITEVOID_NAME", "BUFF_ELITEVOID_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.Fracture, "BUFF_FRACTURE_NAME", "BUFF_FRACTURE_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.JailerSlow, "BUFF_JAILERSLOW_NAME", "BUFF_JAILERSLOW_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.JailerTether, "BUFF_JAILERTETHER_NAME", "BUFF_JAILERTETHER_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.KillMoveSpeed, "BUFF_KILLMOVESPEED_NAME", "BUFF_KILLMOVESPEED_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.MushroomVoidActive, "BUFF_MUSHROOMVOIDACTIVE_NAME", "BUFF_MUSHROOMVOIDACTIVE_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.OutOfCombatArmorBuff, "BUFF_OUTOFCOMBATARMORBUFF_NAME", "BUFF_OUTOFCOMBATARMORBUFF_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.PermanentDebuff, "BUFF_PERMANENTDEBUFF_NAME", "BUFF_PERMANENTDEBUFF_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.PrimarySkillShurikenBuff, "BUFF_PRIMARYSKILLSHURIKENBUFF_NAME", "BUFF_PRIMARYSKILLSHURIKENBUFF_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.StrongerBurn, "BUFF_STRONGERBURN_NAME", "BUFF_STRONGERBURN_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.VoidRaidCrabWardWipeFog, "BUFF_VOIDRAIDCRABWARDWIPEFOG_NAME", "BUFF_VOIDRAIDCRABWARDWIPEFOG_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.VoidSurvivorCorruptMode, "BUFF_VOIDSURVIVORCORRUPTMODE_NAME", "BUFF_VOIDSURVIVORCORRUPTMODE_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.ImmuneToDebuffReady, "BUFF_RAINCOATREADY_NAME", "BUFF_RAINCOATREADY_DESC"); - RegisterBuffInfo(RoR2.DLC1Content.Buffs.ImmuneToDebuffCooldown, "BUFF_RAINCOATCOOLDOWN_NAME", "BUFF_RAINCOATCOOLDOWN_DESC"); - }); - } - - public static void RegisterName(BuffDef buffDef, string nameToken) - { - RegisterBuffInfo(buffDef, nameToken: nameToken); - } - - public static void RegisterDescription(BuffDef buffDef, string descriptionToken) - { - RegisterBuffInfo(buffDef, descriptionToken: descriptionToken); - } - - public static void RegisterBuffInfo(BuffDef buffDef, string nameToken = null, string descriptionToken = null) - { - if (buffDef == null) - { - UnityEngine.Debug.LogError($"Unable to register BuffInfo for {RoR2.Language.GetString(nameToken)}"); - return; - } - buffInfos.TryGetValue(buffDef, out BuffInfo buffInfo); - buffInfo.nameToken = buffInfo.nameToken ?? nameToken; - buffInfo.descriptionToken = buffInfo.descriptionToken ?? descriptionToken; - RegisterBuffInfo(buffDef, buffInfo); - } - public static void RegisterBuffInfo(BuffDef buffDef, BuffInfo buffInfo) - { - if (buffDef == null) - { - UnityEngine.Debug.LogError($"Unable to register BuffInfo for {RoR2.Language.GetString("nameToken")}"); - return; - } - if (BetterUIPlugin.BetterAPIModIntegration) - { - ModCompatibility.BetterAPICompatibility.Buffs.AddInfo(buffDef, buffInfo); - return; - } - buffInfos[buffDef] = buffInfo; - } - public static string GetName(BuffDef buffDef) - { - if (BetterUIPlugin.BetterAPIModIntegration) - { - return ModCompatibility.BetterAPICompatibility.Buffs.GetName(buffDef); - } - buffInfos.TryGetValue(buffDef, out BuffInfo buffInfo); - return string.IsNullOrEmpty(buffInfo.nameToken) ? buffDef.name : RoR2.Language.GetString(buffInfo.nameToken); - } - public static string GetDescription(BuffDef buffDef) - { - if (BetterUIPlugin.BetterAPIModIntegration) - { - return ModCompatibility.BetterAPICompatibility.Buffs.GetDescription(buffDef); - } - buffInfos.TryGetValue(buffDef, out BuffInfo buffInfo); - return string.IsNullOrEmpty(buffInfo.descriptionToken) ? String.Empty : RoR2.Language.GetString(buffInfo.descriptionToken); - } - - internal static void Hook() - { - if (ConfigManager.BuffTimers.Value || ConfigManager.BuffTooltips.Value) - { - BetterUIPlugin.Hooks.Add("Awake", BuffIcon_Awake); - BetterUIPlugin.Hooks.Add("UpdateIcon", BuffIcon_UpdateIcon); - } - } - internal static void BuffIcon_Awake(Action orig, RoR2.UI.BuffIcon self) - { - orig(self); - if (self.transform.parent.name == "BuffDisplayRoot") - { - if (ConfigManager.BuffTooltips.Value) - { - UnityEngine.UI.GraphicRaycaster raycaster = self.transform.parent.GetComponent(); - if (raycaster == null) - { - self.transform.parent.gameObject.AddComponent(); - } - self.gameObject.AddComponent(); - } - if (ConfigManager.BuffTimers.Value) - { - GameObject TimerText = new GameObject("TimerText"); - RectTransform timerRect = TimerText.AddComponent(); - RoR2.UI.HGTextMeshProUGUI timerTextMesh = TimerText.AddComponent(); - TimerText.transform.SetParent(self.transform); - - timerTextMesh.enableWordWrapping = false; - timerTextMesh.alignment = ConfigManager.BuffTimersTextAlignmentOption; - timerTextMesh.fontSize = ConfigManager.BuffTimersFontSize.Value; - timerTextMesh.faceColor = Color.white; - timerTextMesh.text = ""; - - timerRect.localPosition = Vector3.zero; - timerRect.anchorMin = new Vector2(1, 0); - timerRect.anchorMax = new Vector2(1, 0); - timerRect.localScale = Vector3.one; - timerRect.sizeDelta = new Vector2(48, 48); - timerRect.anchoredPosition = new Vector2(-24, 24); - } - } - } - - internal static void BuffIcon_UpdateIcon(Action orig, RoR2.UI.BuffIcon self) - { - orig(self); - if (self.buffDef && self.transform.parent.name == "BuffDisplayRoot") - { - if (ConfigManager.BuffTooltips.Value) - { - RoR2.UI.TooltipProvider tooltipProvider = self.GetComponent(); - tooltipProvider.titleToken = GetName(self.buffDef); - tooltipProvider.bodyToken = GetDescription(self.buffDef); - tooltipProvider.titleColor = self.buffDef.buffColor; - } - if (ConfigManager.BuffTimers.Value) - { - Transform timerText = self.transform.Find("TimerText"); - if (timerText != null) - { - if (BetterUIPlugin.hud != null) - { - CharacterBody characterBody = BetterUIPlugin.hud.targetBodyObject ? BetterUIPlugin.hud.targetBodyObject.GetComponent() : null; - if (characterBody != null && characterBody.timedBuffs.Count > 0) - { - timedBuffs = characterBody.timedBuffs.Where(b => b.buffIndex == self.buffDef.buffIndex); - if (timedBuffs.Any()) - { - thisBuff = timedBuffs.OrderByDescending(b => b.timer).First(); - timerText.GetComponent().text = thisBuff.timer < 10 && ConfigManager.BuffTimersDecimal.Value ? thisBuff.timer.ToString("N1") : thisBuff.timer.ToString("N0"); - return; - } - } - } - timerText.GetComponent().text = ""; - } - } - } - } - public struct BuffInfo - { - public string nameToken; - public string descriptionToken; - } - } -} diff --git a/ModComponents/CommandImprovements.cs b/ModComponents/CommandImprovements.cs deleted file mode 100644 index 6df5f09f..00000000 --- a/ModComponents/CommandImprovements.cs +++ /dev/null @@ -1,293 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -using RoR2; -using RoR2.UI; -using UnityEngine; - -namespace BetterUI -{ - static class CommandImprovements - { - static CommandImprovements() - { - BetterUIPlugin.onStart += onStart; - BetterUIPlugin.onUpdate += onUpdate; - } - internal static void Hook() - { - if (ConfigManager.CommandResizeCommandWindow.Value || - ConfigManager.SortingSortItemsCommand.Value || - ConfigManager.SortingSortItemsScrapper.Value) - { - BetterUIPlugin.Hooks.Add("SetPickupOptions", PickupPickerPanel_SetPickupOptions); - } - if (ConfigManager.CommandCloseOnEscape.Value || - ConfigManager.CommandCloseOnWASD.Value || - ConfigManager.CommandCloseOnCustom.Value != "") - { - BetterUIPlugin.Hooks.Add("Awake", PickupPickerPanel_Awake); - } - - if (ConfigManager.CommandTooltipsShow.Value || - ConfigManager.CommandCountersShow.Value) - { - BetterUIPlugin.Hooks.Add("OnCreateButton", PickupPickerPanel_OnCreateButton); - } - } - private static void onStart() - { - ItemCatalog.availability.CallWhenAvailable(Init); - EquipmentCatalog.availability.CallWhenAvailable(Init); - } - - private static void onUpdate() - { - if (currentPanel && currentPanel.gameObject) - { - if (ConfigManager.CommandCloseOnEscape.Value && Input.GetKeyDown("escape") || - ConfigManager.CommandCloseOnWASD.Value && (Input.GetKeyDown("w") || Input.GetKeyDown("a") || Input.GetKeyDown("s") || Input.GetKeyDown("d")) || - ConfigManager.CommandCloseOnCustom.Value != "" && Input.GetKeyDown(ConfigManager.CommandCloseOnCustom.Value)) - { - if (Input.GetKeyDown("escape")) - { - RoR2.Console.instance.SubmitCmd(null, "pause", false); - } - UnityEngine.Object.Destroy(currentPanel.gameObject); - } - } - } - - - private static void Init() - { - if (ItemCatalog.availability.available && EquipmentCatalog.availability.available) - { - var maxOptions = ItemCatalog.itemCount + EquipmentCatalog.equipmentCount; - optionMap = new int[maxOptions]; - optionMap[0] = -1; - availableIndex = new bool[maxOptions]; - sortedOptions = new PickupPickerController.Option[maxOptions]; - } - } - - private static PickupPickerPanel currentPanel; - private static int[] optionMap; - private static bool[] availableIndex; - private static PickupPickerController.Option[] sortedOptions; - private static String sortOrder; - - internal static ItemIndex[] lastItem = new ItemIndex[] { - ItemIndex.None, - ItemIndex.None, - ItemIndex.None, - ItemIndex.None, - ItemIndex.None, - ItemIndex.None, - }; - public static void PickupPickerPanel_Awake(Action orig, PickupPickerPanel self) - { - currentPanel = self; - orig(self); - } - public static void PickupPickerController_SubmitChoice(Action orig, RoR2.PickupPickerController self, int index) - { - orig(self, index); - - ItemDef itemDef = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(self.options[index].pickupIndex).itemIndex); - if (itemDef.itemIndex != ItemIndex.None) - { - lastItem[(int)itemDef.tier] = itemDef.itemIndex; - } - } - - public static void PickupPickerPanel_SetPickupOptions(Action orig, RoR2.UI.PickupPickerPanel self, RoR2.PickupPickerController.Option[] options) - { - if (options == null || options.Length == 0) - { - orig(self, options); - return; - } - - - self.buttonAllocator.AllocateElements(0); - optionMap[0] = -1; - switch (self.pickerController.contextString) - { - case "ARTIFACT_COMMAND_CUBE_INTERACTION_PROMPT": - if (ConfigManager.CommandResizeCommandWindow.Value) - { - var mainPanelRectTransform = self.transform.Find("MainPanel").GetComponent(); - var mainContainerRectTransform = self.transform.parent.GetComponent(); - int columns = (int)Math.Ceiling(Math.Sqrt(options.Length)); ; - int defaultPanelHeight = 166 + (82 * (int)Math.Ceiling(options.Length / (float)columns)); - - if (defaultPanelHeight > mainContainerRectTransform.rect.height - 120) - { - columns = (int)Math.Ceiling(options.Length / Math.Floor((mainContainerRectTransform.rect.height - 286) / 82)); - } - - self.gridlayoutGroup.constraintCount = self.maxColumnCount = columns; - mainPanelRectTransform.sizeDelta = new Vector2(166 + 82 * columns, 166 + (82 * (float)Math.Ceiling(options.Length / (float)columns))); - } - - if (ConfigManager.CommandRemoveBackgroundBlur.Value) - { - self.transform.GetComponent().enabled = false; - } - if (ConfigManager.SortingSortItemsCommand.Value) - { - sortOrder = ConfigManager.SortingSortOrderCommand.Value; - break; - } - goto default; - case "SCRAPPER_CONTEXT": - if (ConfigManager.SortingSortItemsScrapper.Value) - { - sortOrder = ConfigManager.SortingSortOrderScrapper.Value; - break; - } - goto default; - default: - orig(self, options); - return; - } - - - Inventory inventory = LocalUserManager.GetFirstLocalUser().cachedMasterController.master.inventory; - - if (options.All(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex != EquipmentIndex.None)) - { - foreach (RoR2.PickupPickerController.Option option in options) - { - availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex] = option.available; - } - - List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).equipmentIndex).ToList(), sortOrder); - - sortedItems.Select(equipemntIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(equipemntIndex), available = availableIndex[(int)equipemntIndex] }).ToArray().CopyTo(sortedOptions, 0); ; - sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); - options = sortedOptions.Take(options.Length).ToArray(); - } - else if (options.All(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex != ItemIndex.None)) - { - foreach (RoR2.PickupPickerController.Option option in options) - { - availableIndex[(int)PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex] = option.available; - } - - List sortedItems = ItemSorting.sortItems(options.Select(option => PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex).ToList(), inventory, sortOrder); - - sortedItems.Select(itemIndex => new RoR2.PickupPickerController.Option { pickupIndex = PickupCatalog.FindPickupIndex(itemIndex), available = availableIndex[(int)itemIndex] }).ToArray().CopyTo(sortedOptions, 0); - sortedOptions.Select(option => Array.IndexOf(options, option)).ToArray().CopyTo(optionMap, 0); - options = sortedOptions.Take(options.Length).ToArray(); - } - - orig(self, options); - } - - public static void PickupPickerPanel_OnCreateButton(Action orig, RoR2.UI.PickupPickerPanel self, int index, MPButton button) - { - orig(self, optionMap[0] >= 0 ? optionMap[index] : index, button); - - if (ConfigManager.CommandTooltipsShow.Value || ConfigManager.CommandCountersShow.Value) - { - CharacterMaster master = LocalUserManager.GetFirstLocalUser().cachedMasterController.master; - PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickerController.options[optionMap[0] >= 0 ? optionMap[index] : index].pickupIndex); - - if (pickupDef.itemIndex != ItemIndex.None && ConfigManager.CommandCountersShow.Value) - { - int count = master.inventory.itemStacks[(int)pickupDef.itemIndex]; - if (!ConfigManager.CommandCountersHideOnZero.Value || count > 0) - { - GameObject textGameObject = new GameObject("StackText"); - textGameObject.transform.SetParent(button.transform); - textGameObject.layer = 5; - - RectTransform counterRect = textGameObject.AddComponent(); - - HGTextMeshProUGUI counterText = textGameObject.AddComponent(); - counterText.enableWordWrapping = false; - counterText.alignment = ConfigManager.CommandCountersTextAlignmentOption; - counterText.fontSize = ConfigManager.CommandCountersFontSize.Value; - counterText.faceColor = Color.white; - counterText.outlineWidth = 0.2f; - counterText.text = ConfigManager.CommandCountersPrefix.Value + count; - - counterRect.localPosition = Vector3.zero; - counterRect.anchorMin = Vector2.zero; - counterRect.anchorMax = Vector2.one; - counterRect.localScale = Vector3.one; - counterRect.sizeDelta = new Vector2(-10, -4); - counterRect.anchoredPosition = Vector2.zero; - } - } - - if (ConfigManager.CommandTooltipsShow.Value) - { - TooltipProvider tooltipProvider = button.gameObject.AddComponent(); - - if (pickupDef.itemIndex != ItemIndex.None) - { - ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); - - if (ConfigManager.AdvancedIconsItemItemStatsIntegration.Value) // TODO: Replace with config option - { - int count = master.inventory.itemStacks[(int)pickupDef.itemIndex]; - var stringBuilder = BetterUIPlugin.sharedStringBuilder; - stringBuilder.Clear(); - stringBuilder.Append(RoR2.Language.GetString(itemDef.descriptionToken)); - stringBuilder.Append("\n"); - if (self.pickerController.contextString == "ARTIFACT_COMMAND_CUBE_INTERACTION_PROMPT" && ConfigManager.CommandTooltipsItemStatsBeforeAfter.Value && count > 0) - { - stringBuilder.Append("\n"); - stringBuilder.AppendFormat( - count > 1 ? - RoR2.Language.GetString("BETTERUI_BEFORE_SINGULAR") : - RoR2.Language.GetString("BETTERUI_BEFORE_PLURAL"), count - ); - ItemStats.GetItemStats(stringBuilder, itemDef, count, master); - - stringBuilder.Append("\n\n"); - stringBuilder.AppendFormat( - count > 1 ? - RoR2.Language.GetString("BETTERUI_AFTER_SINGULAR") : - RoR2.Language.GetString("BETTERUI_AFTER_PLURAL"), count + 1 - ); - ItemStats.GetItemStats(stringBuilder, itemDef, count + 1, master); - } - else - { - if (self.pickerController.contextString == "ARTIFACT_COMMAND_CUBE_INTERACTION_PROMPT") - { - count += 1; - } - ItemStats.GetItemStats(stringBuilder, itemDef, count, master); - } - - tooltipProvider.overrideBodyText = stringBuilder.ToString(); - } - else - { - tooltipProvider.bodyToken = itemDef.descriptionToken; - } - - tooltipProvider.titleToken = itemDef.nameToken; - tooltipProvider.titleColor = ColorCatalog.GetColor(itemDef.darkColorIndex); ; - tooltipProvider.bodyColor = new Color(0.6f, 0.6f, 0.6f, 1f); - } - else if (pickupDef.equipmentIndex != EquipmentIndex.None) - { - EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); - - tooltipProvider.titleToken = equipmentDef.nameToken; - tooltipProvider.bodyToken = equipmentDef.descriptionToken; - tooltipProvider.titleColor = ColorCatalog.GetColor(equipmentDef.colorIndex); - tooltipProvider.bodyColor = Color.gray; - } - } - } - } - } -} diff --git a/ModComponents/DPSMeter.cs b/ModComponents/DPSMeter.cs deleted file mode 100644 index 9a8ff79a..00000000 --- a/ModComponents/DPSMeter.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text; -using System.Linq; - -using BepInEx; -using RoR2; -using RoR2.UI; -using UnityEngine; -using UnityEngine.UI; - - -namespace BetterUI -{ - - static class DPSMeter - { - - private static readonly Queue characterDamageLog = new Queue(); - private static float characterDamageSum = 0; - private static readonly Queue minionDamageLog = new Queue(); - private static float minionDamageSum = 0; - - private static GameObject DPSMeterPanel; - private static RoR2.UI.ChatBox chatBox; - - private static HGTextMeshProUGUI textMesh; - public static float DPS { get => MinionDPS + CharacterDPS; } - public static float CharacterDPS { get => characterDamageLog.Count > 0 ? characterDamageSum / Clamp(Time.time - characterDamageLog.Peek().time) : 0; } - public static float MinionDPS { get => minionDamageLog.Count > 0 ? minionDamageSum / Clamp(Time.time - minionDamageLog.Peek().time) : 0; } - internal struct DamageLog - { - public float damage; - public float time; - public DamageLog(float dmg) - { - damage = dmg; - time = Time.time; - } - } - - internal static void Initialize() - { - BetterUIPlugin.Hooks.Add("ClientDamageNotified", DamageDealtMessage_ClientDamageNotified); - - BetterUIPlugin.onEnable += () => BetterUIPlugin.onUpdate += onUpdate; - BetterUIPlugin.onDisable += () => BetterUIPlugin.onUpdate -= onUpdate; - - if (ConfigManager.DPSMeterWindowShow.Value) - { - BetterUIPlugin.onEnable += () => BetterUIPlugin.onHUDAwake += onHUDAwake; - BetterUIPlugin.onDisable += () => BetterUIPlugin.onHUDAwake -= onHUDAwake; - - if (ConfigManager.DPSMeterWindowHideWhenTyping.Value) BetterUIPlugin.Hooks.Add(nameof(RoR2.UI.ChatBox.Awake), ChatBox_Awake); - } - } - - public static float Clamp(float value) - { - return Math.Min(Math.Max(1, value), ConfigManager.DPSMeterTimespan.Value); - } - - - private static void onUpdate() - { - while (characterDamageLog.Count > 0 && characterDamageLog.Peek().time < Time.time - ConfigManager.DPSMeterTimespan.Value) - { - characterDamageSum -= characterDamageLog.Dequeue().damage; - } - while (minionDamageLog.Count > 0 && minionDamageLog.Peek().time < Time.time - ConfigManager.DPSMeterTimespan.Value) - { - minionDamageSum -= minionDamageLog.Dequeue().damage; - } - if (textMesh != null) - { - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append(RoR2.Language.GetString("BETTERUI_DPS")); - BetterUIPlugin.sharedStringBuilder.Append(": "); - BetterUIPlugin.sharedStringBuilder.Append((ConfigManager.DPSMeterWindowIncludeMinions.Value ? DPS : CharacterDPS).ToString("N0")); - - textMesh.SetText(BetterUIPlugin.sharedStringBuilder); - } - if (chatBox != null && DPSMeterPanel != null) DPSMeterPanel.gameObject.SetActive(!chatBox.showInput); - } - - public static void ChatBox_Awake(Action orig, RoR2.UI.ChatBox self) - { - orig(self); - chatBox = self; - } - public static void DamageDealtMessage_ClientDamageNotified(Action orig, DamageDealtMessage dmgMsg) - { - orig(dmgMsg); - - CharacterMaster localMaster = LocalUserManager.GetFirstLocalUser().cachedMasterController.master; - - if (dmgMsg.attacker && dmgMsg.victim) - { - var victimBody = dmgMsg.victim.gameObject.GetComponent(); - if (victimBody && victimBody.teamComponent.teamIndex != TeamIndex.Player) - { - if (dmgMsg.attacker == localMaster.GetBodyObject()) - { - characterDamageSum += dmgMsg.damage; - characterDamageLog.Enqueue(new DamageLog(dmgMsg.damage)); - } - else - { - var attackerBody = dmgMsg.attacker.GetComponent(); - if (attackerBody && attackerBody.master && attackerBody.master.minionOwnership && attackerBody.master.minionOwnership.ownerMasterId == localMaster.netId) - { - minionDamageSum += dmgMsg.damage; - minionDamageLog.Enqueue(new DamageLog(dmgMsg.damage)); - } - } - } - } - } - - - - private static void onHUDAwake(HUD self) - { - if (DPSMeterPanel == null) - { - - DPSMeterPanel = new GameObject("DPSMeterPanel"); - RectTransform rectTransform = DPSMeterPanel.AddComponent(); - - DPSMeterPanel.transform.SetParent(BetterUIPlugin.hud.mainContainer.transform); - DPSMeterPanel.transform.SetAsFirstSibling(); - - - - GameObject DPSMeterText = new GameObject("DPSMeterText"); - RectTransform rectTransform2 = DPSMeterText.AddComponent(); - textMesh = DPSMeterText.AddComponent(); - - DPSMeterText.transform.SetParent(DPSMeterPanel.transform); - - - rectTransform.localPosition = Vector3.zero; - rectTransform.anchorMin = ConfigManager.DPSMeterWindowAnchorMin.Value; - rectTransform.anchorMax = ConfigManager.DPSMeterWindowAnchorMax.Value; - rectTransform.localScale = Vector3.one; - rectTransform.pivot = ConfigManager.DPSMeterWindowPivot.Value; - rectTransform.sizeDelta = ConfigManager.DPSMeterWindowSize.Value; - rectTransform.anchoredPosition = ConfigManager.DPSMeterWindowPosition.Value; - rectTransform.eulerAngles = ConfigManager.DPSMeterWindowAngle.Value; - - - DPSMeterPanel.transform.SetParent(BetterUIPlugin.hud.mainUIPanel.transform); - - rectTransform2.localPosition = Vector3.zero; - rectTransform2.anchorMin = Vector2.zero; - rectTransform2.anchorMax = Vector2.one; - rectTransform2.localScale = Vector3.one; - rectTransform2.sizeDelta = new Vector2(-12, -12); - rectTransform2.anchoredPosition = Vector2.zero; - - if (ConfigManager.DPSMeterWindowBackground.Value) - { - Image copyImage = BetterUIPlugin.hud.itemInventoryDisplay.gameObject.GetComponent(); - if (copyImage != null) - { - Image image = DPSMeterPanel.AddComponent(); - image.sprite = copyImage.sprite; - image.color = copyImage.color; - image.type = Image.Type.Sliced; - } - } - - textMesh.enableAutoSizing = true; - textMesh.fontSizeMax = 256; - textMesh.faceColor = Color.white; - textMesh.alignment = TMPro.TextAlignmentOptions.MidlineLeft; - } - } - } -} diff --git a/ModComponents/ItemCounters.cs b/ModComponents/ItemCounters.cs deleted file mode 100644 index 9ee6876e..00000000 --- a/ModComponents/ItemCounters.cs +++ /dev/null @@ -1,192 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Linq; - -using RoR2; -using RoR2.UI; -using BepInEx.Configuration; - -namespace BetterUI -{ - public static class ItemCounters - { - static string[] tierColorMap = new string[] - { - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.Tier1Item), - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.Tier2Item), - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.Tier3Item), - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.LunarItem), - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.BossItem), - ColorCatalog.GetColorHexString(ColorCatalog.ColorIndex.Error), - }; - - static ItemCounters() - { - RoR2.Language.onCurrentLanguageChanged += GenerateItemScores; - ItemCatalog.availability.CallWhenAvailable(GenerateItemScores); - } - internal static void Hook() - { - if (ConfigManager.ItemCountersShowItemCounters.Value) - { - BetterUIPlugin.Hooks.Add("SetMaster", ScoreboardStrip_SetMaster); - BetterUIPlugin.Hooks.Add("Update", ScoreboardStrip_Update); - } - } - - private static void GenerateItemScores() - { - char[] bad_characters = new char[] { '\n', '\t', '\\', '"', '\'', '[', ']' }; - bool first = true; - foreach (var itemIndex in RoR2.ItemCatalog.allItems) - { - ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex); - string safe_name = String.Join("", itemDef.name.Split(bad_characters)); - if (String.IsNullOrWhiteSpace(safe_name)) - { - UnityEngine.Debug.LogError($"BetterUI: Unable to generate ItemScore config option for item {itemDef.name}: name is empty or null! ItemScores may be unreliable."); - continue; - } - string title = itemDef.nameToken != null ? RoR2.Language.GetString(itemDef.nameToken) : itemDef.name; - float itemValue = GetTierScore(itemDef.tier); - ConfigEntry itemScore; - if (first) - { - itemScore = ConfigManager.ConfigFileItemCounters.Bind("ItemScores", safe_name, itemValue, $"Score of each item for the ItemScore.\n{title}"); - first = false; - } - else - { - itemScore = ConfigManager.ConfigFileItemCounters.Bind("ItemScores", safe_name, itemValue, title); - } - - ConfigManager.ItemCountersItemScores[itemDef] = itemScore.Value; - } - } - internal static void ScoreboardStrip_SetMaster(Action orig, ScoreboardStrip self, CharacterMaster master) - { - orig(self, master); - - self.nameLabel.lineSpacing = -20; - self.nameLabel.overflowMode = TMPro.TextOverflowModes.Truncate; - self.nameLabel.enableWordWrapping = false; - self.moneyText.overflowMode = TMPro.TextOverflowModes.Overflow; - } - - static int itemSum; - static float itemScore; - internal static void ScoreboardStrip_Update(Action orig, ScoreboardStrip self) - { - orig(self); - - if (self.master && self.master.inventory) - { - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append(Util.GetBestMasterName(self.master)); - BetterUIPlugin.sharedStringBuilder.Append("\n<#F8FC97>"); - BetterUIPlugin.sharedStringBuilder.Append(self.master.money); - BetterUIPlugin.sharedStringBuilder.Append(""); - - self.nameLabel.text = BetterUIPlugin.sharedStringBuilder.ToString(); - BetterUIPlugin.sharedStringBuilder.Clear(); - BetterUIPlugin.sharedStringBuilder.Append("<#FFFFFF>"); - - - - if (ConfigManager.ItemCountersShowItemSum.Value) - { - itemSum = 0; - foreach (var tier in ConfigManager.ItemCountersItemSumTiers) - { - itemSum += self.master.inventory.GetTotalItemCountOfTier(tier); - if (tier == ItemTier.Tier1) - { - itemSum += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier1); - } - else if (tier == ItemTier.Tier2) - { - itemSum += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier2); - } - else if (tier == ItemTier.Tier3) - { - itemSum += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier3); - } - else if (tier == ItemTier.Boss) - { - itemSum += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidBoss); - } - } - BetterUIPlugin.sharedStringBuilder.Append(itemSum); - if (ConfigManager.ItemCountersShowItemScore.Value) - { - BetterUIPlugin.sharedStringBuilder.Append(" | "); - } - } - if (ConfigManager.ItemCountersShowItemScore.Value) - { - itemScore = 0; - foreach (var item in self.master.inventory.itemAcquisitionOrder) - { - itemScore += GetItemScore(ItemCatalog.GetItemDef(item)) * self.master.inventory.GetItemCount(item); - } - BetterUIPlugin.sharedStringBuilder.AppendFormat("{0:0.#}", itemScore); - } - - if (ConfigManager.ItemCountersShowItemsByTier.Value) - { - BetterUIPlugin.sharedStringBuilder.Append("\n"); - foreach (var tier in ConfigManager.ItemCountersItemsByTierOrder) - { - int tierCount = self.master.inventory.GetTotalItemCountOfTier(tier); - if (tier == ItemTier.Tier1) - { - tierCount += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier1); - } - else if (tier == ItemTier.Tier2) - { - tierCount += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier2); - } - else if (tier == ItemTier.Tier3) - { - tierCount += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidTier3); - } - else if (tier == ItemTier.Boss) - { - tierCount += self.master.inventory.GetTotalItemCountOfTier(ItemTier.VoidBoss); - } - BetterUIPlugin.sharedStringBuilder.Append(" <#"); - BetterUIPlugin.sharedStringBuilder.Append(tierColorMap[(int)tier]); - BetterUIPlugin.sharedStringBuilder.Append(">"); - BetterUIPlugin.sharedStringBuilder.Append(tierCount); - BetterUIPlugin.sharedStringBuilder.Append(""); - } - } - - BetterUIPlugin.sharedStringBuilder.Append(""); - - self.moneyText.text = BetterUIPlugin.sharedStringBuilder.ToString(); - } - } - - public static float GetTierScore(ItemTierDef itemTierDef) - { - float tierValue = 0; - ConfigManager.ItemCountersTierScores.TryGetValue(itemTierDef.tier, out tierValue); - return tierValue; - } - public static float GetTierScore(ItemTier tier) - { - float tierValue = 0; - ConfigManager.ItemCountersTierScores.TryGetValue(tier, out tierValue); - return tierValue; - } - public static float GetItemScore(ItemDef itemDef) - { - float itemValue = 0; - ConfigManager.ItemCountersItemScores.TryGetValue(itemDef, out itemValue); - return itemValue; - } - } -} diff --git a/ModComponents/ItemSorting.cs b/ModComponents/ItemSorting.cs deleted file mode 100644 index c3c4e20b..00000000 --- a/ModComponents/ItemSorting.cs +++ /dev/null @@ -1,379 +0,0 @@ -using System; -using RoR2; -using System.Linq; -using System.Text; -using System.Collections.Generic; - -namespace BetterUI -{ - static class ItemSorting - { - internal static void Hook() - { - if (ConfigManager.SortingSortItemsInventory.Value) - { - BetterUIPlugin.Hooks.Add("OnInventoryChanged", ItemInventoryDisplay_OnInventoryChanged); - } - if (ConfigManager.SortingSortItemsCommand.Value && ConfigManager.SortingSortOrderCommand.Value.Contains("C")) - { - BetterUIPlugin.Hooks.Add("SubmitChoice", CommandImprovements.PickupPickerController_SubmitChoice); - } - } - - public static List sortItems(List equipmentList, String sortOrder) - { - IOrderedEnumerable finalOrder = equipmentList.OrderBy(a => 1); - foreach (char c in sortOrder.ToCharArray()) - { - switch (c) - { - case '6': // Alphabetical - finalOrder = finalOrder.ThenBy(equipment => RoR2.Language.GetString(EquipmentCatalog.GetEquipmentDef(equipment).nameToken)); - break; - case '7': // Alphabetical Reversed - finalOrder = finalOrder.ThenByDescending(equipment => RoR2.Language.GetString(EquipmentCatalog.GetEquipmentDef(equipment).nameToken)); - break; - case '8': // Random" - Random random = new Random(); - finalOrder = finalOrder.ThenBy(equipment => random.Next()); - break; - } - } - return equipmentList; - } - - private delegate IOrderedEnumerable DirectSorter(IOrderedEnumerable order); - private delegate bool ItemFilter(ItemIndex item); - private delegate T ItemSorter(IOrderedEnumerable order, Inventory inventory, ItemIndex item); - - private static ItemFilter scrapFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Scrap); - private static ItemFilter damageFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Damage); - private static ItemFilter healingFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Healing); - private static ItemFilter utilityFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.Utility); - private static ItemFilter onKillEffectFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.OnKillEffect); - private static ItemFilter equipmentRelatedFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.EquipmentRelated); - private static ItemFilter sprintRelatedFilter = item => ItemCatalog.GetItemDef(item).ContainsTag(ItemTag.SprintRelated); - private static Dictionary tierFilters = new Dictionary() - { - { '1', item => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier1 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier1 }, - { '2', item => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier2 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier2 }, - { '3', item => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier3 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier3 }, - { 'L', item => ItemCatalog.GetItemDef(item).tier == ItemTier.Lunar }, - { 'B', item => ItemCatalog.GetItemDef(item).tier == ItemTier.Boss || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidBoss }, - { 'N', item => ItemCatalog.GetItemDef(item).tier == ItemTier.NoTier}, - }; - - //0 = White, 1 = Green, 2 = Red, 3 = Lunar, 4 = Boss, 5 = NoTier - private static Dictionary tierMap = new Dictionary() - { - { ItemTier.Tier1, 0 }, - { ItemTier.VoidTier1, 0 }, - { ItemTier.Tier2, 1 }, - { ItemTier.VoidTier2, 1 }, - { ItemTier.Tier3, 2 }, - { ItemTier.VoidTier3, 2 }, - { ItemTier.Lunar, 3 }, - { ItemTier.Boss, 4 }, - { ItemTier.VoidBoss, 4 }, - { ItemTier.NoTier, 5 }, - }; - - - private static ItemSorter scrapSorter = (order, inventory, item) => scrapFilter(item); - private static ItemSorter damageSorter = (order, inventory, item) => damageFilter(item); - private static ItemSorter healingSorter = (order, inventory, item) => healingFilter(item); - private static ItemSorter utilitySorter = (order, inventory, item) => utilityFilter(item); - private static ItemSorter onKillEffectSorter = (order, inventory, item) => onKillEffectFilter(item); - private static ItemSorter equipmentRelatedSorter = (order, inventory, item) => equipmentRelatedFilter(item); - private static ItemSorter sprintRelatedSorter = (order, inventory, item) => sprintRelatedFilter(item); - private static ItemSorter tierSorter = (order, inventory, item) => - { - if (tierMap.TryGetValue(ItemCatalog.GetItemDef(item).tier, out int value)) - { - return ConfigManager.SortingTierOrder[value]; - } - return ConfigManager.SortingTierOrder[5]; - }; - private static ItemSorter stackSorter = (order, inventory, item) => inventory.itemStacks[(int)item]; - private static ItemSorter pickupSorter = (order, inventory, item) => inventory.itemAcquisitionOrder.IndexOf(item); - private static ItemSorter alphabeticalSorter = (order, inventory, item) => RoR2.Language.GetString(ItemCatalog.GetItemDef(item).nameToken); - private static ItemSorter indexSorter = (order, inventory, item) => (int)item; - private static ItemSorter randomSorter = (order, inventory, item) => - { - Random random = new Random(); - return random.Next(); - }; - - private static Dictionary> tierSorters = new Dictionary>() - { - { '1', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier1 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier1 }, - { '2', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier2 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier2 }, - { '3', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.Tier3 || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidTier3 }, - { 'L', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.Lunar }, - { 'B', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.Boss || ItemCatalog.GetItemDef(item).tier == ItemTier.VoidBoss }, - { 'N', (list, inv, item) => ItemCatalog.GetItemDef(item).tier == ItemTier.NoTier }, - }; - - private static DirectSorter commandSorter = (IOrderedEnumerable order) => - { - ItemDef firstItemDef = ItemCatalog.GetItemDef(order.First()); - if (firstItemDef != null && CommandImprovements.lastItem[(int)firstItemDef.tier] != ItemIndex.None && order.Contains(CommandImprovements.lastItem[(int)firstItemDef.tier])) - { - int roundUp = (int)Math.Ceiling((double)order.Count() / 5) * 5; - int offset; - if (roundUp == 5) - { - offset = order.Count() / 2; - } - else if (roundUp % 10 == 0) - { - offset = (roundUp / 2) - 3; - } - else - { - offset = roundUp / 2; - } - List finalOrderList = order.ToList(); - finalOrderList.Remove(CommandImprovements.lastItem[(int)firstItemDef.tier]); - finalOrderList.Insert(offset, CommandImprovements.lastItem[(int)firstItemDef.tier]); - order = finalOrderList.OrderBy(a => 1); - } - return order; - }; - - - private static IOrderedEnumerable filteredSort(IOrderedEnumerable list, Inventory inventory, ItemSorter sorter, ItemFilter filter = null, bool reversed = false) - { - - if (filter != null) - { - List filteredIndexes = list.Select((x, i) => new { Value = x, Index = i }).Where(x => filter(x.Value)).Select(x => x.Index).ToList(); - List filteredItems = list.Select((x, i) => new { Value = x, Index = i }).Where(x => filter(x.Value)).Select(x => x.Value).ToList(); - List tempList = list.ToList(); - if (reversed) - { - filteredItems = filteredItems.OrderByDescending(item => sorter(list, inventory, item)).ToList(); - } - else - { - filteredItems = filteredItems.OrderBy(item => sorter(list, inventory, item)).ToList(); - } - foreach (var x in filteredIndexes.Select((x, i) => new { Value = x, Index = i })) - { - tempList[x.Value] = filteredItems[x.Index]; - } - return tempList.OrderBy(x => 1); - } - else - { - if (reversed) - { - return list.OrderByDescending(item => sorter(list, inventory, item)); - } - else - { - return list.OrderBy(item => sorter(list, inventory, item)); - } - } - } - struct SortStep - { - public ItemFilter filter; - public ItemSorter intSorter; - public ItemSorter boolSorter; - public ItemSorter stringSorter; - public DirectSorter directSorter; - public bool reversed; - } - - public static List sortItems(List itemList, Inventory inventory, String sortOrder) - { - List steps = new List(); - bool filtering = false; - bool tierSelect = false; - bool sortReversed = false; - bool nameParsing = false; - ItemFilter nextFilter = null; - IOrderedEnumerable finalOrder = itemList.OrderBy(a => 1); - foreach (char c in sortOrder.ToCharArray()) - { - - if (nameParsing) - { - if (c == '(') - { - continue; - } - if (c == ')') - { - - ItemIndex indexed = ItemCatalog.FindItemIndex(BetterUIPlugin.sharedStringBuilder.ToString()); - if (indexed != ItemIndex.None) - { - ItemSorter sorter = (order, inventor, item) => item.Equals(indexed); - steps.Add(new SortStep { filter = null, boolSorter = sorter, reversed = sortReversed }); - } - BetterUIPlugin.sharedStringBuilder.Clear(); - - nameParsing = false; - sortReversed = false; - continue; - } - else - { - BetterUIPlugin.sharedStringBuilder.Append(c); - } - continue; - } - if (tierSelect) - { - if (filtering) - { - tierFilters.TryGetValue(Char.ToUpper(c), out nextFilter); - filtering = false; - } - else - { - if (tierSorters.TryGetValue(Char.ToUpper(c), out var tierSorter)) - { - steps.Add(new SortStep { filter = nextFilter, boolSorter = tierSorter, reversed = sortReversed }); - } - } - tierSelect = false; - continue; - } - - if (filtering) - { - switch (c) - { - case 's': - case 'S': // Scrap Only - nextFilter = scrapFilter; - break; - case 'd': - case 'D': // Damage Only - nextFilter = damageFilter; - break; - case 'h': - case 'H': // Healing Only - nextFilter = healingFilter; - break; - case 'u': - case 'U': // Utility Only - nextFilter = utilityFilter; - break; - case 'o': - case 'O': // OnKillEffect Only - nextFilter = onKillEffectFilter; - break; - case 'e': - case 'E': // EquipmentRelated Only - nextFilter = equipmentRelatedFilter; - break; - case 'p': - case 'P': // SprintRelated Only - nextFilter = sprintRelatedFilter; - break; - } - filtering = false; - continue; - } - - switch (c) - { - case '<': - case '>': - nameParsing = true; - sortReversed = (c == '<'); - BetterUIPlugin.sharedStringBuilder.Clear(); - break; - case '#': - filtering = true; - continue; - - case 't': - case 'T': - tierSelect = true; - sortReversed = Char.IsLower(c); - continue; - case '0': - case '1': // Tier - steps.Add(new SortStep { filter = nextFilter, intSorter = tierSorter, reversed = c == '1' }); - break; - case '2': - case '3': // Stack Size - steps.Add(new SortStep { filter = nextFilter, intSorter = stackSorter, reversed = c == '3' }); - break; - case '4': - case '5':// Pickup Order - steps.Add(new SortStep { filter = nextFilter, intSorter = pickupSorter, reversed = c == '5' }); - break; - case '6': - case '7': // Alphabetical - steps.Add(new SortStep { filter = nextFilter, stringSorter = alphabeticalSorter, reversed = c == '7' }); - break; - case '8': // Random" - steps.Add(new SortStep { filter = nextFilter, intSorter = randomSorter }); - break; - case 'C': - case 'c': // Special Command Centered - steps.Add(new SortStep { filter = nextFilter, directSorter = commandSorter }); - break; - case 'i': - case 'I': // ItemIndex - steps.Add(new SortStep { filter = nextFilter, intSorter = indexSorter, reversed = Char.IsUpper(c) }); - break; - case 's': - case 'S': // Scrap Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = scrapSorter, reversed = Char.IsLower(c) }); - break; - case 'd': - case 'D': // Damage Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = damageSorter, reversed = Char.IsLower(c) }); - break; - case 'h': - case 'H': // Healing Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = healingSorter, reversed = Char.IsLower(c) }); - break; - case 'u': - case 'U': // Utility Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = utilitySorter, reversed = Char.IsLower(c) }); - break; - case 'o': - case 'O': // OnKillEffect Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = onKillEffectSorter, reversed = Char.IsLower(c) }); - break; - case 'e': - case 'E': // EquipmentRelated Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = equipmentRelatedSorter, reversed = Char.IsLower(c) }); - break; - case 'p': - case 'P': // SprintRelated Only - steps.Add(new SortStep { filter = nextFilter, boolSorter = sprintRelatedSorter, reversed = Char.IsLower(c) }); - break; - } - nextFilter = null; - } - steps.Reverse(); - foreach (var step in steps) - { - if (step.boolSorter != null) finalOrder = filteredSort(finalOrder, inventory, step.boolSorter, step.filter, step.reversed); - else if (step.intSorter != null) finalOrder = filteredSort(finalOrder, inventory, step.intSorter, step.filter, step.reversed); - else if (step.stringSorter != null) finalOrder = filteredSort(finalOrder, inventory, step.stringSorter, step.filter, step.reversed); - else if (step.directSorter != null) finalOrder = step.directSorter(finalOrder); - } - return finalOrder.ToList(); - } - - public static void ItemInventoryDisplay_OnInventoryChanged(Action orig, RoR2.UI.ItemInventoryDisplay self) - { - orig(self); - - if (self.itemOrder != null && self.inventory && self.inventory.itemAcquisitionOrder.Any()) - { - sortItems(self.inventory.itemAcquisitionOrder, self.inventory, ConfigManager.SortingSortOrder.Value).ToList().CopyTo(self.itemOrder); - } - } - } -} diff --git a/ModComponents/ItemStats.cs b/ModComponents/ItemStats.cs deleted file mode 100644 index aec4e4c0..00000000 --- a/ModComponents/ItemStats.cs +++ /dev/null @@ -1,844 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using RoR2; - -namespace BetterUI -{ - public static class ItemStats - { - - internal static Dictionary> itemStats = new Dictionary>(); - internal static Dictionary> itemTags = new Dictionary>(); - internal static Dictionary> itemModifiers = new Dictionary>(); - public static readonly Dictionary itemProcInfos = new Dictionary(); - - - public static void Initialize() - { - RegisterStat(RoR2Content.Items.AlienHead, "BETTERUI_COOLDOWNREDUCTION", 0.25f, NegativeExponentialStacking, StatFormatter.Percent, itemTag: ItemTag.SkillCooldown); - RegisterModifier(ItemTag.SkillCooldown, RoR2Content.Items.AlienHead, ItemModifier.ExponentialBonus, 0.25f); - RegisterStat(RoR2Content.Items.ArmorPlate, "BETTERUI_DAMAGEREDUCTION", 5f, LinearStacking, StatFormatter.Damage); - RegisterStat(RoR2Content.Items.ArmorReductionOnHit, "BETTERUI_DURATION", 8, LinearStacking, StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.AttackSpeedOnCrit, "BETTERUI_MAXIMUMATTACKSPEED", 0.36f, 0.24f, LinearStacking, StatFormatter.Percent); - RegisterStat(RoR2Content.Items.AutoCastEquipment, "BETTERUI_COOLDOWNREDUCTION", 0.5f, 0.15f, NegativeExponentialStacking, StatFormatter.Percent, ItemTag.EquipmentCooldown); - RegisterModifier(ItemTag.EquipmentCooldown, RoR2Content.Items.AutoCastEquipment, ItemModifier.ExponentialBonus, 0.5f, 0.15f); - RegisterStat(RoR2Content.Items.Bandolier, "BETTERUI_DROPCHANCE", 0.18f, 0.10f, itemTag: ItemTag.Luck); - RegisterStat(RoR2Content.Items.BarrierOnKill, "BETTERUI_BARRIER", 15, statFormatter: StatFormatter.HP); - RegisterStat(RoR2Content.Items.BarrierOnOverHeal, "BETTERUI_HEALINGCONVERTED", 0.5f); - RegisterStat(RoR2Content.Items.Bear, "BETTERUI_TOUGHERTIMES", 0.15f, HyperbolicStacking); - RegisterStat(RoR2Content.Items.BeetleGland, "BETTERUI_BEETLEGUARDS", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.Behemoth, "BETTERUI_EXPLOSIONRADIUS", 4, 2.5f, statFormatter: StatFormatter.Range); - RegisterProc(RoR2Content.Items.Behemoth, 4f, 2.5f, statFormatter: StatFormatter.Range, stackingFormula: LinearStacking); - RegisterStat(RoR2Content.Items.BleedOnHit, "BETTERUI_BLEEDCHANCE", 0.1f, LinearStacking, StatFormatter.Chance, ItemTag.Luck); - RegisterProc(RoR2Content.Items.BleedOnHit, 0.1f, capFormula: LinearCap); - RegisterStat(RoR2Content.Items.BleedOnHitAndExplode, "BETTERUI_EXPLOSIONBASEDAMAGE", 4); - RegisterStat(RoR2Content.Items.BleedOnHitAndExplode, "BETTERUI_EXPLOSIONMAXHPDAMAGE", 0.15f); - RegisterStat(RoR2Content.Items.BonusGoldPackOnKill, "BETTERUI_DROPCHANCE", 0.04f, itemTag: ItemTag.Luck); - RegisterStat(RoR2Content.Items.BossDamageBonus, "BETTERUI_DAMAGE", 0.2f); - RegisterStat(RoR2Content.Items.BounceNearby, "BETTERUI_CHANCE", 0.25f, HyperbolicStacking, itemTag: ItemTag.Luck); - RegisterStat(RoR2Content.Items.BounceNearby, "BETTERUI_TARGETS", 10, 5, statFormatter: StatFormatter.Charges); - RegisterProc(RoR2Content.Items.BounceNearby, 0.2f, stackingFormula: HyperbolicStacking); - RegisterStat(RoR2Content.Items.CaptainDefenseMatrix, "BETTERUI_PROJECTILESSHOT", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.ChainLightning, "BETTERUI_TARGETS", 3, 2, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.ChainLightning, "BETTERUI_RADIUS", 20, 2, statFormatter: StatFormatter.Range); - RegisterProc(RoR2Content.Items.ChainLightning, 0.25f, stackingFormula: NoStacking); - RegisterStat(RoR2Content.Items.Clover, "BETTERUI_LUCK", 1, statFormatter: StatFormatter.Charges, itemTag: ItemTag.LuckStat); - RegisterStat(RoR2Content.Items.CritGlasses, "BETTERUI_CHANCE", 0.10f); - RegisterStat(RoR2Content.Items.Crowbar, "BETTERUI_DAMAGE", 0.75f); - RegisterStat(RoR2Content.Items.Dagger, "BETTERUI_DAMAGE", 1.5f); - RegisterStat(RoR2Content.Items.DeathMark, "BETTERUI_DEBUFFDURATION", 7, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.EnergizedOnEquipmentUse, "BETTERUI_DURATION", 8, 4, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.EquipmentMagazine, "BETTERUI_EQUIPMENTCHARGES", 1f, LinearStacking, StatFormatter.Charges); - RegisterStat(RoR2Content.Items.EquipmentMagazine, "BETTERUI_COOLDOWNREDUCTION", 0.15f, 0.15f, NegativeExponentialStacking, StatFormatter.Percent, ItemTag.EquipmentCooldown); - RegisterModifier(ItemTag.EquipmentCooldown, RoR2Content.Items.EquipmentMagazine, ItemModifier.ExponentialBonus, 0.15f); - RegisterStat(RoR2Content.Items.ExecuteLowHealthElite, "BETTERUI_THRESHOLD", 0.13f, HyperbolicStacking); - RegisterStat(RoR2Content.Items.ExplodeOnDeath, "BETTERUI_DAMAGE", 3.5f, 2.8f, LinearStacking); - RegisterStat(RoR2Content.Items.ExplodeOnDeath, "BETTERUI_RADIUS", 12, 2.4f, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.ExtraLife, "BETTERUI_USES", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.FallBoots, "BETTERUI_COOLDOWN", 10, DivideByStacks, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.Feather, "BETTERUI_EXTRAJUMPS", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.FireRing, "BETTERUI_DAMAGE", 3); - RegisterStat(RoR2Content.Items.FireballsOnHit, "BETTERUI_DAMAGE", 3); - RegisterProc(RoR2Content.Items.FireballsOnHit, 0.1f, stackingFormula: NoStacking); - RegisterStat(RoR2Content.Items.Firework, "BETTERUI_FIREWORKS", 8, 4, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.FlatHealth, "BETTERUI_HEALTH", 25, statFormatter: StatFormatter.HP); - RegisterStat(RoR2Content.Items.FocusConvergence, "BETTERUI_CHARGESPEED", 0.30f, 0.30f, 3); - RegisterStat(RoR2Content.Items.FocusConvergence, "BETTERUI_TELEPORTERZONE", 2, 2, 3, stackingFormula: FocusedConvergenceStacking); - RegisterStat(RoR2Content.Items.GhostOnKill, "BETTERUI_GHOSTDURATION", 30, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.GoldOnHit, "BETTERUI_GOLDGAINED", 2, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.GoldOnHit, "BETTERUI_GOLDLOST", 1); - RegisterProc(RoR2Content.Items.GoldOnHit, 0.3f, stackingFormula: NoStacking); - RegisterStat(RoR2Content.Items.HeadHunter, "BETTERUI_DURATION", 8, 5, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.HealOnCrit, "BETTERUI_HEAL", 8, 4, statFormatter: StatFormatter.HP); - RegisterProc(RoR2Content.Items.HealOnCrit, 8f, 4f, statFormatter: StatFormatter.HP, stackingFormula: LinearStacking); - RegisterStat(RoR2Content.Items.HealWhileSafe, "BETTERUI_REGEN", 3, statFormatter: StatFormatter.Regen); - RegisterStat(RoR2Content.Items.Hoof, "BETTERUI_MOVEMENTSPEED", 0.14f, itemTag: ItemTag.MovementSpeed); - RegisterStat(RoR2Content.Items.IceRing, "BETTERUI_SLOWDURATION", 3, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.IceRing, "BETTERUI_DAMAGE", 2.5f); - RegisterStat(RoR2Content.Items.Icicle, "BETTERUI_MAXIMUMRADIUS", 18, 12, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.IgniteOnKill, "BETTERUI_RADIUS", 12, 4, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.IgniteOnKill, "BETTERUI_DAMAGE", 1.5f, 0.75f); - RegisterStat(RoR2Content.Items.IncreaseHealing, "BETTERUI_HEALING", 1); - RegisterModifier(ItemTag.Healing, RoR2Content.Items.IncreaseHealing, ItemModifier.PercentBonus, 100); - RegisterStat(RoR2Content.Items.Infusion, "BETTERUI_MAXIMUMHEALTH", 100, statFormatter: StatFormatter.HP, itemTag: ItemTag.MaxHealth); - RegisterStat(RoR2Content.Items.Infusion, "BETTERUI_HEALTHPERKILL", 1, statFormatter: StatFormatter.HP); - RegisterStat(RoR2Content.Items.JumpBoost, "BETTERUI_BOOST", 10, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.KillEliteFrenzy, "BETTERUI_DURATION", 4, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.Knurl, "BETTERUI_HEALTH", 40f, LinearStacking, StatFormatter.HP); - RegisterStat(RoR2Content.Items.Knurl, "BETTERUI_REGEN", 1.6f, LinearStacking, StatFormatter.Regen, ItemTag.Healing); - RegisterStat(RoR2Content.Items.LaserTurbine, "BETTERUI_DAMAGE", 3); - RegisterStat(RoR2Content.Items.LaserTurbine, "BETTERUI_EXPLOSION", 10); - RegisterStat(RoR2Content.Items.LightningStrikeOnHit, "BETTERUI_DAMAGE", 5); - RegisterProc(RoR2Content.Items.LightningStrikeOnHit, 0.1f, stackingFormula: NoStacking); - RegisterStat(RoR2Content.Items.LunarBadLuck, "BETTERUI_LUCK", -1, statFormatter: StatFormatter.Charges, itemTag: ItemTag.LuckStat); - RegisterStat(RoR2Content.Items.LunarDagger, "BETTERUI_DAMAGE", 2, ExponentialStacking); - RegisterModifier(ItemTag.Damage, RoR2Content.Items.LunarDagger, ItemModifier.PositiveExponentialBonus, 2); - RegisterStat(RoR2Content.Items.LunarDagger, "BETTERUI_HEALTH", 0.5f, ExponentialStacking); - RegisterStat(RoR2Content.Items.LunarPrimaryReplacement, "BETTERUI_CHARGES", 12, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.LunarPrimaryReplacement, "BETTERUI_RELOAD", 2, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.LunarSecondaryReplacement, "BETTERUI_ROOTDURATION", 3, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.LunarSecondaryReplacement, "BETTERUI_COOLDOWN", 5, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.LunarSpecialReplacement, "BETTERUI_RUINDURATION", 10, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.LunarSpecialReplacement, "BETTERUI_COOLDOWN", 8, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.LunarUtilityReplacement, "BETTERUI_HEAL", 0.182f); - RegisterStat(RoR2Content.Items.LunarUtilityReplacement, "BETTERUI_DURATION", 3, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.Medkit, "BETTERUI_HEAL", 0.05f); - RegisterStat(RoR2Content.Items.Missile, "BETTERUI_DAMAGE", 3); - RegisterProc(RoR2Content.Items.Missile, 0.1f, stackingFormula: NoStacking); - RegisterStat(RoR2Content.Items.MonstersOnShrineUse, "BETTERUI_ENEMYDIFFICULTY", 1f); - RegisterStat(RoR2Content.Items.Mushroom, "BETTERUI_HEALTHPERSECOND", 0.045f, 0.0225f); - RegisterStat(RoR2Content.Items.Mushroom, "BETTERUI_RADIUS", 3, 1.5f, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.NearbyDamageBonus, "BETTERUI_DAMAGE", 0.2f); - RegisterStat(RoR2Content.Items.NovaOnHeal, "BETTERUI_DAMAGE", 1); - RegisterStat(RoR2Content.Items.NovaOnLowHealth, "BETTERUI_RECHARGESPEED", 30, DivideByStacksPlusOne, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.ParentEgg, "BETTERUI_HEATH", 15, statFormatter: StatFormatter.HP); - RegisterStat(RoR2Content.Items.Pearl, "BETTERUI_HEALTH", 0.1f); - RegisterModifier(ItemTag.MaxHealth, RoR2Content.Items.Pearl, ItemModifier.PercentBonus, 10); - RegisterStat(RoR2Content.Items.PersonalShield, "BETTERUI_SHIELD", 0.08f); - RegisterStat(RoR2Content.Items.Phasing, "BETTERUI_COOLDOWN", 30, 0.5f, ExponentialStacking, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.Plant, "BETTERUI_RADIUS", 5, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.RandomDamageZone, "BETTERUI_RANGE", 16, 1.5f, ExponentialStacking, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.RepeatHeal, "BETTERUI_HEALING", 1, itemTag: ItemTag.Healing); - RegisterStat(RoR2Content.Items.RepeatHeal, "BETTERUI_MAXIMUM", 0.1f, DivideByStacks, itemTag: ItemTag.Healing); - RegisterModifier(ItemTag.Healing, RoR2Content.Items.RepeatHeal, ItemModifier.PercentBonus, 100); - RegisterStat(RoR2Content.Items.RoboBallBuddy, "BETTERUI_DAMAGE", 1f, itemTag: ItemTag.Allies); - RegisterStat(RoR2Content.Items.SecondarySkillMagazine, "BETTERUI_CHARGES", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.Seed, "BETTERUI_HEAL", 1, statFormatter: StatFormatter.HP, itemTag: ItemTag.Healing); - RegisterProc(RoR2Content.Items.Seed, 1f, statFormatter: StatFormatter.HP, stackingFormula: LinearStacking); - RegisterStat(RoR2Content.Items.ShieldOnly, "BETTERUI_MAXIMUMHEALTH", 0.5f, 0.25f); - RegisterModifier(ItemTag.MaxHealth, RoR2Content.Items.ShieldOnly, ItemModifier.PercentBonus, 50, 25); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_HEALTH", 0.1f); - RegisterModifier(ItemTag.MaxHealth, RoR2Content.Items.ShinyPearl, ItemModifier.PercentBonus, 10); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_REGEN", 0.1f, statFormatter: StatFormatter.Regen, itemTag: ItemTag.Healing); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_MOVEMENTSPEED", 0.1f, itemTag: ItemTag.MovementSpeed); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_DAMAGE", 0.1f); - RegisterModifier(ItemTag.Damage, RoR2Content.Items.ShinyPearl, ItemModifier.PercentBonus, 10); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_ATTACKSPEED", 0.1f); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_CRITCHANCE", 0.1f); - RegisterStat(RoR2Content.Items.ShinyPearl, "BETTERUI_ARMOR", 0.1f); - RegisterStat(RoR2Content.Items.ShockNearby, "BETTERUI_TARGETS", 3, 2, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.SiphonOnLowHealth, "BETTERUI_TETHEREDENEMIES", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.SlowOnHit, "BETTERUI_SLOWDURATION", 2, 2, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.SprintArmor, "BETTERUI_ARMOR", 30, statFormatter: StatFormatter.Armor); - RegisterStat(RoR2Content.Items.SprintBonus, "BETTERUI_SPRINTSPEED", 0.25f); - RegisterStat(RoR2Content.Items.SprintOutOfCombat, "BETTERUI_MOVEMENTSPEED", 0.3f, itemTag: ItemTag.MovementSpeed); - RegisterStat(RoR2Content.Items.SprintWisp, "BETTERUI_DAMAGE", 3f, itemTag: ItemTag.Damage); - RegisterStat(RoR2Content.Items.Squid, "BETTERUI_ATTACKSPEED", 1f); - RegisterStat(RoR2Content.Items.StickyBomb, "BETTERUI_CHANCE", 0.05f, itemTag: ItemTag.Luck); - RegisterProc(RoR2Content.Items.StickyBomb, 0.05f, stackingFormula: LinearStacking, capFormula: LinearCap); - RegisterStat(RoR2Content.Items.StunChanceOnHit, "BETTERUI_CHANCE", 0.05f, HyperbolicStacking, itemTag: ItemTag.Luck); - RegisterProc(RoR2Content.Items.StunChanceOnHit, 0.05f, stackingFormula: HyperbolicStacking); - RegisterStat(RoR2Content.Items.Syringe, "BETTERUI_ATTACKSPEED", 0.15f); - RegisterStat(RoR2Content.Items.TPHealingNova, "BETTERUI_HEALINGNOVA", 1, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.Talisman, "BETTERUI_COOLDOWNREDUCTION", 4, 2, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.Thorns, "BETTERUI_TARGETS", 5, 2, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.Thorns, "BETTERUI_RADIUS", 25, 10, statFormatter: StatFormatter.Range); - RegisterStat(RoR2Content.Items.TitanGoldDuringTP, "BETTERUI_DAMAGE", 1, 0.5f); - RegisterStat(RoR2Content.Items.TitanGoldDuringTP, "BETTERUI_HEALTH", 1); - RegisterModifier(ItemTag.TitanDamage, RoR2Content.Items.TitanGoldDuringTP, ItemModifier.FlatBonus, 0.5f, modificationChecker: ItemModifier.TeamItemChecker, modificationCounter: ItemModifier.TeamItemCounter); - RegisterModifier(ItemTag.TitanHealth, RoR2Content.Items.TitanGoldDuringTP, ItemModifier.FlatBonus, 1f, modificationChecker: ItemModifier.TeamItemChecker, modificationCounter: ItemModifier.TeamItemCounter); - RegisterStat(RoR2Content.Items.Tooth, "BETTERUI_HEALTHPERORB", 0.02f, itemTag: ItemTag.Healing); - RegisterStat(RoR2Content.Items.UtilitySkillMagazine, "BETTERUI_CHARGES", 2, statFormatter: StatFormatter.Charges); - RegisterStat(RoR2Content.Items.WarCryOnMultiKill, "BETTERUI_FRENZYDURATION", 6, 4, statFormatter: StatFormatter.Seconds); - RegisterStat(RoR2Content.Items.WardOnLevel, "BETTERUI_RADIUS", 16, 8, statFormatter: StatFormatter.Range); - - RegisterStat(DLC1Content.Items.AttackSpeedAndMoveSpeed, "BETTERUI_ATTACKSPEED", 0.075f); - RegisterStat(DLC1Content.Items.AttackSpeedAndMoveSpeed, "BETTERUI_MOVEMENTSPEED", 0.07f, itemTag: ItemTag.MovementSpeed); - RegisterStat(DLC1Content.Items.BearVoid, "BETTERUI_RECHARGETIME", 15, 0.9f, 65, ExponentialStackingPlusOne, StatFormatter.Seconds); - RegisterStat(DLC1Content.Items.BleedOnHitVoid, "BETTERUI_CHANCE", 0.1f, itemTag: ItemTag.Luck); - RegisterProc(DLC1Content.Items.BleedOnHitVoid, 0.1f, stackingFormula: LinearStacking, capFormula: LinearCap); - RegisterStat(DLC1Content.Items.ChainLightningVoid, "BETTERUI_HITS", 3, statFormatter: StatFormatter.Charges); - RegisterProc(DLC1Content.Items.ChainLightningVoid, 0.25f, stackingFormula: NoStacking); - RegisterStat(DLC1Content.Items.CloverVoid, "BETTERUI_ITEMSUPGRADED", 3, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.CritDamage, "BETTERUI_DAMAGE", 1f); - RegisterStat(DLC1Content.Items.CritGlassesVoid, "BETTERUI_CHANCE", 0.005f, itemTag: ItemTag.Luck); - RegisterProc(DLC1Content.Items.CritGlassesVoid, 0.005f, stackingFormula: LinearStacking, capFormula: LinearCap); - RegisterStat(DLC1Content.Items.DroneWeapons, "BETTERUI_ATTACKSPEED", 0.5f); - RegisterStat(DLC1Content.Items.ElementalRingVoid, "BETTERUI_DAMAGE", 1f); - RegisterStat(DLC1Content.Items.EquipmentMagazineVoid, "BETTERUI_CHARGES", 1f, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.ExplodeOnDeathVoid, "BETTERUI_DAMAGE", 2.6f, 1.56f, LinearStacking); - RegisterStat(DLC1Content.Items.ExplodeOnDeathVoid, "BETTERUI_RADIUS", 12, 2.4f, statFormatter: StatFormatter.Range); - RegisterStat(DLC1Content.Items.ExtraLifeVoid, "BETTERUI_USES", 1f, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.FragileDamageBonus, "BETTERUI_DAMAGE", 0.2f); - RegisterModifier(ItemTag.Damage, DLC1Content.Items.FragileDamageBonus, ItemModifier.PercentBonus, 20); - // RegisterStat(DLC1Content.Items.FreeChest, "BETTERUI_SHIPPINGREQUESTFORM"; - RegisterStat(DLC1Content.Items.GoldOnHurt, "BETTERUI_BASEGOLD", 3, statFormatter: StatFormatter.Gold); - RegisterStat(DLC1Content.Items.HalfAttackSpeedHalfCooldowns, "BETTERUI_SKILLCOOLDOWNS", 0.5f, ExponentialStacking, itemTag: ItemTag.SkillCooldown); - RegisterModifier(ItemTag.SkillCooldown, DLC1Content.Items.HalfAttackSpeedHalfCooldowns, ItemModifier.ExponentialBonus, 0.5f); - RegisterStat(DLC1Content.Items.HalfAttackSpeedHalfCooldowns, "BETTERUI_ATTACKSPEED", 1, DivideByStacksPlusOne); - RegisterStat(DLC1Content.Items.HalfSpeedDoubleHealth, "BETTERUI_MAXHEALTH", 1); - RegisterModifier(ItemTag.MaxHealth, DLC1Content.Items.HalfSpeedDoubleHealth, ItemModifier.PercentBonus, 100); - RegisterStat(DLC1Content.Items.HalfSpeedDoubleHealth, "BETTERUI_MOVEMENTSPEED", 1, DivideByStacks); - RegisterModifier(ItemTag.MovementSpeed, DLC1Content.Items.HalfSpeedDoubleHealth, ItemModifier.ExponentialBonus, 0.5f); - RegisterStat(DLC1Content.Items.HealingPotion, "BETTERUI_USES", 1f, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.ImmuneToDebuff, "BETTERUI_DEBUFFSPREVENTED", 1f, stackingFormula: LinearStacking, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.LunarSun, "BETTERUI_CHARGETIME", 3f, DivideByStacks, statFormatter: StatFormatter.Seconds); - RegisterStat(DLC1Content.Items.LunarSun, "BETTERUI_BOMBS", 3f, 1f, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.MinorConstructOnKill, "BETTERUI_MAXCONSTRUCTS", 4, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.MissileVoid, "BETTERUI_DAMAGE", 0.4f); - RegisterStat(DLC1Content.Items.MoreMissile, "BETTERUI_DAMAGE", 0f, 0.5f); - RegisterStat(DLC1Content.Items.MoveSpeedOnKill, "BETTERUI_DURATION", 1, 0.5f, statFormatter: StatFormatter.Seconds); - RegisterStat(DLC1Content.Items.MushroomVoid, "BETTERUI_HPPERSECOND", 0.02f); - RegisterStat(DLC1Content.Items.OutOfCombatArmor, "BETTERUI_ARMOR", 100, statFormatter: StatFormatter.Armor); - RegisterStat(DLC1Content.Items.PermanentDebuffOnHit, "BETTERUI_ARMORREDUCTION", 2, statFormatter: StatFormatter.Armor); - RegisterStat(DLC1Content.Items.PrimarySkillShuriken, "BETTERUI_DAMAGE", 4, 1); - RegisterStat(DLC1Content.Items.PrimarySkillShuriken, "BETTERUI_SHURIKEN", 3, 1, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.RandomEquipmentTrigger, "BETTERUI_EFFECTS", 1, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.RandomlyLunar, "BETTERUI_CHANCE", 0.05f, itemTag: ItemTag.Luck); - RegisterStat(DLC1Content.Items.RegeneratingScrap, "BETTERUI_USES", 1, statFormatter: StatFormatter.Charges); - RegisterStat(DLC1Content.Items.SlowOnHitVoid, "BETTERUI_CHANCE", 0.05f, itemTag: ItemTag.Luck); - RegisterStat(DLC1Content.Items.SlowOnHitVoid, "BETTERUI_DURATION", 1, statFormatter: StatFormatter.Seconds); - RegisterProc(DLC1Content.Items.SlowOnHitVoid, 0.05f, stackingFormula: LinearStacking, capFormula: LinearCap); - RegisterStat(DLC1Content.Items.StrengthenBurn, "BETTERUI_DAMAGE", 3f); - //RegisterStat(DLC1Content.Items.TreasureCacheVoid, "BETTERUI_ENCRUSTEDKEY", , , ); - RegisterStat(DLC1Content.Items.VoidMegaCrabItem, "BETTERUI_COOLDOWN", 60, DivideByStacks, statFormatter: StatFormatter.Seconds); - RegisterStat(DLC1Content.Items.VoidMegaCrabItem, "BETTERUI_MAXALLIES", 1, statFormatter: StatFormatter.Charges); - - - RegisterModifier(ItemTag.Luck, "BETTERUI_LUCK", ItemModifier.LuckBonus, ItemModifier.LuckLocator, ItemModifier.LuckChecker, ItemModifier.LuckCounter, "BETTERUI_LUCK"); - RegisterModifier(ItemTag.Allies, "BETTERUI_ALLY", ItemModifier.AlliesBonus, ItemModifier.AlliesLocator, ItemModifier.AlliesChecker, ItemModifier.AlliesCounter, "BETTERUI_ALLIES"); - - - - } - - public static List GetItemStats(ItemDef itemDef) - { - if (itemStats.TryGetValue(itemDef, out var stats)) return stats; - return null; - } - - public static List GetItemTags(ItemStat itemStat) - { - if (itemTags.TryGetValue(itemStat, out var tags)) return tags; - return null; - } - - public static List GetItemModifers(ItemTag itemTag) - { - if (itemModifiers.TryGetValue(itemTag, out var modifiers)) return modifiers; - return null; - } - - public static ItemStat RegisterStat(ItemDef itemDef, string nameToken, float value, StackingFormula stackingFormula = null, StatFormatter statFormatter = null, ItemTag itemTag = null) - { - return RegisterStat(itemDef, nameToken, value, value, stackingFormula, statFormatter, itemTag); - } - - public static ItemStat RegisterStat( - ItemDef itemDef, - string nameToken, - float value, - float stackValue, - StackingFormula stackingFormula = null, - StatFormatter statFormatter = null, - ItemTag itemTag = null - ) - { - return RegisterStat(itemDef, nameToken, value, stackValue, int.MaxValue, stackingFormula, statFormatter, itemTag); - } - - public static ItemStat RegisterStat( - ItemDef itemDef, - string nameToken, - float value, - float stackValue, - int stackLimit, - StackingFormula stackingFormula = null, - StatFormatter statFormatter = null, - ItemTag itemTag = null - ) - { - ItemStat itemStat = new ItemStat() - { - nameToken = nameToken, - value = value, - stackValue = stackValue, - stackLimit = stackLimit, - stackingFormula = stackingFormula ?? LinearStacking, - statFormatter = statFormatter ?? StatFormatter.Percent - }; - return RegisterStat(itemDef, itemStat, itemTag); - } - - public static ItemStat RegisterStat(ItemDef itemDef, ItemStat itemStat, ItemTag itemTag) - { - if (itemStats.TryGetValue(itemDef, out var stats)) - { - stats.Add(itemStat); - } - else - { - itemStats[itemDef] = new List() { itemStat }; - } - if (itemTag != null) RegisterTag(itemStat, itemTag); - return itemStat; - } - - - public static ItemModifier RegisterModifier( - ItemTag itemTag, - ItemDef itemDef, - ItemModifier.ModificationFormula modificationFormula, - float modifier, - float? stackModifier = null, - string nameToken = null, - string pluralNameToken = null, - ItemModifier.ModificationLocator modificationLocator = null, - ItemModifier.ModificationChecker modificationChecker = null, - ItemModifier.ModificationCounter modificationCounter = null - ) - { - ItemModifier itemModfier = new ItemModifier() - { - nameToken = nameToken ?? itemDef.nameToken, - pluralNameToken = pluralNameToken, - modificationFormula = modificationFormula, - itemDef = itemDef, - modifier = modifier, - stackModifier = stackModifier ?? modifier, - modificationLocator = modificationLocator, - modificationChecker = modificationChecker ?? ItemModifier.ItemChecker, - modificationCounter = modificationCounter ?? ItemModifier.ItemCounter - }; - return RegisterModifier(itemTag, itemModfier); - } - - public static ItemModifier RegisterModifier( - ItemTag itemTag, - string nameToken, - ItemModifier.ModificationFormula modificationFormula, - ItemModifier.ModificationLocator modificationLocator, - ItemModifier.ModificationChecker modificationChecker, - ItemModifier.ModificationCounter modificationCounter, - string pluralNameToken = null) - { - ItemModifier itemModfier = new ItemModifier() - { - nameToken = nameToken, - pluralNameToken = pluralNameToken, - modificationFormula = modificationFormula, - modificationLocator = modificationLocator, - modificationChecker = modificationChecker, - modificationCounter = modificationCounter - }; - return RegisterModifier(itemTag, itemModfier); - } - - public static ItemModifier RegisterModifier(ItemTag itemTag, ItemModifier itemModfier) - { - if (itemModifiers.TryGetValue(itemTag, out var modifers)) - { - modifers.Add(itemModfier); - } - else - { - itemModifiers[itemTag] = new List() { itemModfier }; - } - return itemModfier; - } - - public static ItemTag RegisterTag(ItemStat itemStat, ItemTag itemTag) - { - if (itemTags.TryGetValue(itemStat, out var tags)) - { - tags.Add(itemTag); - } - else - { - itemTags[itemStat] = new List() { itemTag }; - } - return itemTag; - } - - public static void GetItemStats(StringBuilder stringBuilder, ItemDef itemDef, int stacks, CharacterMaster master) - { - if (itemStats.TryGetValue(itemDef, out var stats)) - { - foreach (var itemStat in stats) - { - int limitedStacks = Math.Min(stacks, itemStat.stackLimit); - float baseValue = itemStat.stackingFormula(itemStat.value, itemStat.stackValue, limitedStacks); - float totalValue = baseValue; - if (itemTags.TryGetValue(itemStat, out var tags)) - { - foreach (var itemTag in tags) - { - if (itemModifiers.TryGetValue(itemTag, out var modifiers)) - { - foreach (var itemModifier in modifiers) - { - if (itemModifier.itemDef == itemDef) continue; - if (itemModifier.GetModificationActive(master)) - { - float count = itemModifier.GetModificationCount(master); - float modifiedValue = itemModifier.GetModifiedValue(baseValue, master, count); - totalValue += modifiedValue; - } - } - } - } - } - - stringBuilder.Append("\n"); - stringBuilder.Append(RoR2.Language.GetString(itemStat.nameToken)); - stringBuilder.Append(": "); - itemStat.statFormatter.FormatString(stringBuilder, totalValue, master); - bool first = true; - if (tags != null) - { - foreach (var itemTag in tags) - { - if (itemModifiers.TryGetValue(itemTag, out var modifiers)) - { - foreach (var itemModifier in modifiers) - { - if (itemModifier.GetModificationActive(master)) - { - if (itemModifier.itemDef == itemDef) continue; - if (first) - { - var itemCount = master.inventory.GetItemCount(itemDef); - stringBuilder.Append("\n "); - stringBuilder.Append(itemCount); - stringBuilder.Append(" "); - stringBuilder.Append(RoR2.Language.GetString(itemDef.nameToken)); - if (itemCount > 1) - { - stringBuilder.Append("s"); - } - stringBuilder.Append(": "); - itemStat.statFormatter.FormatString(stringBuilder, baseValue, master); - first = false; - } - float count = itemModifier.GetModificationCount(master); - float modifiedValue = itemModifier.GetModifiedValue(baseValue, master, count); - totalValue += modifiedValue; - stringBuilder.Append("\n "); - stringBuilder.Append(count); - stringBuilder.Append(" "); - if (Math.Abs(count) != 1) - { - if (!String.IsNullOrEmpty(itemModifier.pluralNameToken)) - { - stringBuilder.Append(RoR2.Language.GetString(itemModifier.pluralNameToken)); - } - else - { - stringBuilder.Append(RoR2.Language.GetString(itemModifier.nameToken)); - stringBuilder.Append("s"); - } - } - else - { - stringBuilder.Append(RoR2.Language.GetString(itemModifier.nameToken)); - } - stringBuilder.Append(": "); - itemStat.statFormatter.FormatString(stringBuilder, modifiedValue, master); - } - } - } - } - } - } - } - } - - - - public class StatFormatter - { - public delegate void Formatter(StringBuilder stringBuilder, float value, CharacterMaster master); - public Formatter statFormatter; - public string style; - public string color; - public string customFormatTag; - public string customFormatClosingTag; - public string prefix; - public string suffix; - public string pluralSuffix; - public string format = "{0:0.##}"; - public bool bold; - public bool italic; - public bool underline; - public bool strikethrough; - - public static StatFormatter LuckChance = new StatFormatter() - { - suffix = "BETTERUI_LUCKCHANCE_SUFFIX", - style = Styles.Damage, - statFormatter = (sb, value, master) => - { - sb.Append(Math.Min(100, 100 * Utils.LuckCalc(value, master.luck)).ToString("0.##")); - } - }; - - public static StatFormatter Chance = new StatFormatter() - { - suffix = "BETTERUI_CHANCE_SUFFIX", - style = Styles.Damage, - statFormatter = (sb, value, master) => { sb.AppendFormat("{0:0.##}", value * 100); } - }; - - public static StatFormatter Gold = new StatFormatter() - { - prefix = "BETTERUI_GOLD_PREFIX", - style = Styles.Damage, - }; - - public static StatFormatter Charges = new StatFormatter() - { - }; - - public static StatFormatter Percent = new StatFormatter() - { - suffix = "BETTERUI_PERCENT_SUFFIX", - style = Styles.Damage, - statFormatter = (sb, value, master) => { sb.AppendFormat("{0:0.##}", value * 100); } - }; - - public static StatFormatter HP = new StatFormatter() - { - suffix = "BETTERUI_HP_SUFFIX", - style = Styles.Health - }; - - public static StatFormatter Seconds = new StatFormatter() - { - suffix = "BETTERUI_SECONDS_SUFFIX", - style = Styles.Damage - }; - - public static StatFormatter Armor = new StatFormatter() - { - suffix = "BETTERUI_ARMOR_SUFFIX", - style = Styles.Stack - }; - - public static StatFormatter Regen = new StatFormatter() - { - suffix = "BETTERUI_REGEN_SUFFIX", - style = Styles.Healing - }; - - public static StatFormatter Range = new StatFormatter() - { - suffix = "BETTERUI_RANGE_SUFFIX", - style = Styles.Damage - }; - public static StatFormatter Damage = new StatFormatter() - { - suffix = "BETTERUI_DAMAGE_SUFFIX", - style = Styles.Damage - }; - - - public void FormatString(StringBuilder stringBuilder, float value, CharacterMaster master) - { - if (!String.IsNullOrEmpty(style)) - { - stringBuilder.Append(""); - } - if (bold) stringBuilder.Append(""); - if (italic) stringBuilder.Append(""); - if (underline) stringBuilder.Append(""); - if (strikethrough) stringBuilder.Append(""); - if (!String.IsNullOrEmpty(color)) - { - stringBuilder.Append(""); - } - if (!String.IsNullOrEmpty(customFormatTag)) stringBuilder.Append(customFormatTag); - if (!String.IsNullOrEmpty(prefix)) stringBuilder.Append(RoR2.Language.GetString(prefix)); - - if (statFormatter != null) - { - statFormatter(stringBuilder, value, master); - } - else - { - if (value < 0.1) - { - stringBuilder.AppendFormat("{0:0.###}", value); - } - else - { - stringBuilder.AppendFormat("{0:0.##}", value); - } - } - - if (!String.IsNullOrEmpty(suffix)) stringBuilder.Append(RoR2.Language.GetString(suffix)); - if (!String.IsNullOrEmpty(customFormatClosingTag)) stringBuilder.Append(customFormatClosingTag); - if (strikethrough) stringBuilder.Append(""); - if (underline) stringBuilder.Append(""); - if (italic) stringBuilder.Append(""); - if (bold) stringBuilder.Append(""); - if (!String.IsNullOrEmpty(style)) stringBuilder.Append(""); - } - - } - - - - public delegate float StackingFormula(float value, float extraStackValue, int stacks); - - public static float LinearStacking(float value, float extraStackValue, int stacks) - { - return value + extraStackValue * (stacks - 1); - } - public static float ExponentialStackingPlusOne(float value, float extraStackValue, int stacks) - { - return value * (float)Math.Pow(extraStackValue, stacks); - } - public static float ExponentialStacking(float value, float extraStackValue, int stacks) - { - return value * (float)Math.Pow(extraStackValue, stacks - 1); - } - public static float NegativeExponentialStacking(float value, float extraStackValue, int stacks) - { - return (1 - (1 - value) * (float)Math.Pow(1 - extraStackValue, stacks - 1)); - } - [Obsolete("Deprecated: Use DivideByStacksPlusOne instead.")] - public static float DivideByBonusStacks(float value, float extraStackValue, int stacks) - { - return value / (stacks + 1); - } - public static float DivideByStacksPlusOne(float value, float extraStackValue, int stacks) - { - return value / (stacks + 1); - } - public static float DivideByStacks(float value, float extraStackValue, int stacks) - { - return value / stacks; - } - public static float FocusedConvergenceStacking(float value, float extraStackValue, int stacks) - { - return 1 / (value * stacks); - } - public static float HyperbolicStacking(float value, float extraStackValue, int stacks) - { - return (float)(1 - 1 / (1 + (value + extraStackValue * (stacks - 1)))); - } - public static float NoStacking(float value, float extraStackValue, int stacks) - { - return value; - } - - public delegate int CapFormula(float value, float extraStackValue, float procCoefficient); - public static int LinearCap(float value, float extraStackValue, float procCoefficient) - { - return (int)UnityEngine.Mathf.Round((1f - value * procCoefficient) / (extraStackValue * procCoefficient)) + 1; - } - - public class ItemProcInfo - { - public float value; - public float extraStackValue; - public StatFormatter statFormatter; - public StackingFormula stackingFormula; - public CapFormula capFormula; - - public void GetOutputString(StringBuilder stringBuilder, int stacks, CharacterMaster master, float procCoefficient) - { - this.statFormatter.FormatString(stringBuilder, procCoefficient * this.stackingFormula(this.value, this.extraStackValue, stacks), master); - if (capFormula != null) - { - var stacksToCap = capFormula(value, extraStackValue, procCoefficient); - stringBuilder.AppendFormat(RoR2.Language.GetString(stacksToCap > 1 ? "BETTERUI_PROCSTACKS_PLURAL" : "BETTERUI_PROCSTACKS_SINGULAR"), stacksToCap); - } - } - public float GetValue(int stacks) - { - return this.stackingFormula(value, extraStackValue, stacks); - } - - public float GetCap(float procCoefficient) - { - return this.capFormula == null ? -1 : this.capFormula(value, extraStackValue, procCoefficient); - } - } - - public static void RegisterProc(ItemIndex itemIndex, ItemProcInfo itemProcInfo) - { - if (itemIndex <= ItemIndex.None) - { - UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); - return; - } - RegisterProc(ItemCatalog.GetItemDef(itemIndex), itemProcInfo); - } - public static void RegisterProc(ItemIndex itemIndex, float value, float? extraStackValue = null, StatFormatter statFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) - { - if (itemIndex <= ItemIndex.None) - { - UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); - return; - } - RegisterProc(ItemCatalog.GetItemDef(itemIndex), value, extraStackValue, statFormatter, stackingFormula, capFormula); - } - public static void RegisterProc(ItemDef itemDef, ItemProcInfo itemProcInfo) - { - itemProcInfos[itemDef] = itemProcInfo; - } - public static void RegisterProc(ItemDef itemDef, float value, float? extraStackValue = null, StatFormatter statFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) - { - RegisterProc(itemDef, new ItemProcInfo() - { - value = value, - extraStackValue = extraStackValue ?? value, - statFormatter = statFormatter ?? StatFormatter.LuckChance, - stackingFormula = stackingFormula ?? LinearStacking, - capFormula = capFormula - }); - } - - public class ItemStat - { - public string nameToken; - public StackingFormula stackingFormula; - public float value; - public float stackValue; - public int stackLimit = int.MaxValue; - public StatFormatter statFormatter; - } - - public class ItemModifier - { - public delegate float ModificationFormula(float value, float modifier, float stacks, float stackModifier); - public static ModificationFormula ExponentialBonus = (value, modifier, stackModifier, stacks) => (1 - value) - (1 - value) * (1 - modifier) * (float)Math.Pow(1 - stackModifier, stacks - 1); - public static ModificationFormula PositiveExponentialBonus = (value, modifier, stackModifier, stacks) => value * modifier * (float)Math.Pow(1 - stackModifier, stacks - 1); - public static ModificationFormula PercentBonus = (value, modifier, stackModifier, stacks) => value * ((modifier + (stackModifier * (stacks - 1))) / 100); - public static ModificationFormula LuckBonus = (value, modifier, stackModifier, stacks) => - { - return Math.Min(1, Utils.LuckCalc(value, modifier)) - value; - }; - public static ModificationFormula AlliesBonus = (value, modifier, stackModifier, stacks) => - { - return value * modifier; - }; - public static ModificationFormula FlatBonus = (value, modifier, stackModifier, stacks) => - { - return value + modifier + stackModifier * stacks; - }; - - public delegate float ModificationLocator(CharacterMaster master); - public static ModificationLocator LuckLocator = (master) => master.luck; - public static ModificationLocator AlliesLocator = (master) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0); - - public delegate bool ModificationChecker(CharacterMaster master, ItemModifier itemModifier); - public static ModificationChecker ItemChecker = (master, itemModifier) => master.inventory.GetItemCount(itemModifier.itemDef) > 0; - public static ModificationChecker TeamItemChecker = (master, itemModifier) => Util.GetItemCountForTeam(master.GetBody().teamComponent.teamIndex, itemModifier.itemDef.itemIndex, true, true) > master.inventory.GetItemCount(itemModifier.itemDef); - public static ModificationChecker LuckChecker = (master, itemModifier) => master.luck != 0; - public static ModificationChecker AlliesChecker = (master, itemModifier) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0) > 1; - - public delegate float ModificationCounter(CharacterMaster master, ItemModifier itemModifier); - public static ModificationCounter ItemCounter = (master, itemModifier) => master.inventory.GetItemCount(itemModifier.itemDef); - public static ModificationCounter TeamItemCounter = (master, itemModifier) => Util.GetItemCountForTeam(master.GetBody().teamComponent.teamIndex, itemModifier.itemDef.itemIndex, true, true) - master.inventory.GetItemCount(itemModifier.itemDef); - public static ModificationCounter LuckCounter = (master, itemModifier) => master.luck; - public static ModificationCounter AlliesCounter = (master, itemModifier) => Math.Max(TeamComponent.GetTeamMembers(master.GetBody().teamComponent.teamIndex).Count - 1, 0); - - public string nameToken; - public string pluralNameToken; - public ModificationFormula modificationFormula; - public ItemDef itemDef; - public ModificationLocator modificationLocator; - public ModificationChecker modificationChecker; - public ModificationCounter modificationCounter; - public float modifier; - public float stackModifier; - - public bool GetModificationActive(CharacterMaster master) - { - return modificationChecker(master, this); - } - - public float GetModificationCount(CharacterMaster master) - { - return modificationCounter(master, this); - } - public float GetModifiedValue(float value, CharacterMaster master, float count) - { - if (modificationLocator != null) - { - return modificationFormula(value, modificationLocator(master), stackModifier, count); - } - else - { - return modificationFormula(value, modifier, stackModifier, count); - } - } - } - - - public class ItemTag - { - public static ItemTag Damage; - public static ItemTag Healing; - public static ItemTag Luck; - public static ItemTag LuckStat; - public static ItemTag EquipmentCooldown; - public static ItemTag SkillCooldown; - public static ItemTag Allies; - public static ItemTag MaxHealth; - public static ItemTag TitanDamage; - public static ItemTag TitanHealth; - public static ItemTag MovementSpeed; - static ItemTag() - { - Damage = new ItemTag(); - Healing = new ItemTag(); - Luck = new ItemTag(); - LuckStat = new ItemTag(); - EquipmentCooldown = new ItemTag(); - Allies = new ItemTag(); - MaxHealth = new ItemTag(); - TitanDamage = new ItemTag(); - TitanHealth = new ItemTag(); - SkillCooldown = new ItemTag(); - MovementSpeed = new ItemTag(); - } - } - - public static class Styles - { - public const string Damage = "cIsDamage"; - public const string Healing = "cIsHealing"; - public const string Mono = "cMono"; - public const string Stack = "cStack"; - public const string Health = "cIsHealth"; - public const string Void = "cIsVoid"; - public const string Death = "cDeath"; - public const string UserSetting = "cUserSetting"; - public const string Artifact = "cArtifact"; - public const string Sub = "cSub"; - public const string Event = "cEvent"; - public const string WorldEvent = "cWorldEvent"; - public const string KeywordName = "cKeywordName"; - public const string Shrine = "cShrine"; - } - } -} diff --git a/ModComponents/Misc.cs b/ModComponents/Misc.cs deleted file mode 100644 index de6c351e..00000000 --- a/ModComponents/Misc.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using RoR2; - -namespace BetterUI -{ - static class Misc - { - internal static void Hook() - { - if (ConfigManager.MiscHidePickupNotificiationsArtifacts.Value) - { - BetterUIPlugin.Hooks.Add("SetArtifact", GenericNotification_SetArtifact); - } - if (ConfigManager.MiscAdvancedPickupNotificationsEquipements.Value || - ConfigManager.MiscHidePickupNotificiationsEquipements.Value) - { - BetterUIPlugin.Hooks.Add("SetEquipment", GenericNotification_SetEquipment); - } - if (ConfigManager.MiscAdvancedPickupNotificationsItems.Value || - ConfigManager.MiscHidePickupNotificiationsItems.Value) - { - BetterUIPlugin.Hooks.Add("SetItem", GenericNotification_SetItem); - } - - if (ConfigManager.MiscShowHidden.Value) - { - BetterUIPlugin.Hooks.Add("ItemIsVisible", (ItemInventoryDisplay_ItemIsVisible_Delegate)ItemInventoryDisplay_ItemIsVisible); - } - if (ConfigManager.MiscShowPickupDescription.Value) - { - BetterUIPlugin.Hooks.Add("Awake", ContextManager_Awake); - BetterUIPlugin.Hooks.Add("GetContextString", (GenericPickupController_GetContextString_Delegate)GenericPickupController_GetContextString); - } - } - - internal static void ContextManager_Awake(Action orig, RoR2.UI.ContextManager self) - { - var Description = self.gameObject.transform.Find("ContextDisplay/Description"); - var textMesh = Description.gameObject.GetComponent(); - var rectTransform = Description.gameObject.GetComponent(); - rectTransform.sizeDelta = new UnityEngine.Vector2(rectTransform.sizeDelta.x, -0.7f); - rectTransform.anchoredPosition = new UnityEngine.Vector2(rectTransform.anchoredPosition.x, -1); - textMesh.fontSizeMin = textMesh.fontSize; - textMesh.alignment = TMPro.TextAlignmentOptions.TopLeft; - orig(self); - } - internal delegate string GenericPickupController_GetContextString_Delegate(Func orig, GenericPickupController self, Interactor activator); - internal static string GenericPickupController_GetContextString(Func orig, GenericPickupController self, Interactor activator) - { - PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickupIndex); - string pickupText = string.Format(RoR2.Language.GetString(((pickupDef != null) ? pickupDef.interactContextToken : null) ?? string.Empty), RoR2.Language.GetString(pickupDef.nameToken)); - if (pickupDef.itemIndex != ItemIndex.None) - { - ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); - pickupText += $"\n\n{RoR2.Language.GetString( ConfigManager.MiscPickupDescriptionAdvanced.Value ? itemDef.descriptionToken : itemDef.pickupToken)}"; - } - else if (pickupDef.equipmentIndex != EquipmentIndex.None) - { - EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); - pickupText += $"\n\n{RoR2.Language.GetString(ConfigManager.MiscPickupDescriptionAdvanced.Value ? equipmentDef.descriptionToken : equipmentDef.pickupToken)}"; - } - return pickupText; - } - internal delegate bool ItemInventoryDisplay_ItemIsVisible_Delegate(Func orig, ItemIndex itemIndex); - internal static bool ItemInventoryDisplay_ItemIsVisible(Func orig, ItemIndex itemIndex) - { - return true; - } - internal static void GenericNotification_SetArtifact(Action orig, RoR2.UI.GenericNotification self, ArtifactDef artifactDef) - { - if (ConfigManager.MiscHidePickupNotificiationsArtifacts.Value) - { - UnityEngine.Object.Destroy(self.gameObject); - return; - } - orig(self, artifactDef); - - } - internal static void GenericNotification_SetEquipment(Action orig, RoR2.UI.GenericNotification self, EquipmentDef equipmentDef) - { - if (ConfigManager.MiscHidePickupNotificiationsEquipements.Value) - { - UnityEngine.Object.Destroy(self.gameObject); - return; - } - orig(self, equipmentDef); - - self.descriptionText.token = equipmentDef.descriptionToken; - } - internal static void GenericNotification_SetItem(Action orig, RoR2.UI.GenericNotification self, ItemDef itemDef) - { - if (ConfigManager.MiscHidePickupNotificiationsItems.Value) - { - UnityEngine.Object.Destroy(self.gameObject); - return; - } - orig(self, itemDef); - - self.descriptionText.token = itemDef.descriptionToken; - } - } -} diff --git a/ModComponents/StatsDisplay.cs b/ModComponents/StatsDisplay.cs deleted file mode 100644 index 79dc403a..00000000 --- a/ModComponents/StatsDisplay.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; -using System.Text.RegularExpressions; - -using RoR2; -using BepInEx; -using UnityEngine; -using UnityEngine.UI; -using TMPro; - - - -namespace BetterUI -{ - public static class StatsDisplay - { - - private static GameObject statsDisplayContainer; - private static GameObject stupidBuffer; - private static RoR2.UI.HGTextMeshProUGUI textMesh; - private static int highestMultikill = 0; - private static CharacterBody playerBody; - private static Boolean statsDisplayToggle = false; - - internal static readonly Dictionary regexmap; - static Regex regexpattern; - - static string[] normalText; - static string[] altText; - - public delegate string DisplayCallback(CharacterBody characterBody); - - static StatsDisplay() - { - regexmap = new Dictionary { - { "$armordmgreduction", (statBody) => ((statBody.armor >= 0 ? statBody.armor / (100 + statBody.armor) : (100 / (100 - statBody.armor) - 1)) * 100).ToString("0.##") }, - { "$exp", (statBody) => TeamManager.instance.GetTeamExperience(statBody.teamComponent.teamIndex).ToString("0.##") }, - { "$maxexp", (statBody) => TeamManager.instance.GetTeamNextLevelExperience(statBody.teamComponent.teamIndex).ToString("0.##") }, - { "$level", (statBody) => statBody.level.ToString() }, - { "$dmg", (statBody) => statBody.damage.ToString("0.##") }, - { "$crit", (statBody) => statBody.crit.ToString("0.##") }, - { "$critdamage", (statBody) => statBody.critMultiplier.ToString("0.##") }, - { "$luckcrit", (statBody) => ( 100 * ((int)statBody.crit / 100) + 100 * Utils.LuckCalc(statBody.crit % 100 * 0.01f,statBody.master.luck)).ToString("0.##") }, - { "$hp", (statBody) => Math.Floor(statBody.healthComponent.health).ToString("0.##") }, - { "$maxhp", (statBody) => statBody.maxHealth.ToString("0.##") }, - { "$shield", (statBody) => Math.Floor(statBody.healthComponent.shield).ToString("0.##") }, - { "$maxshield", (statBody) => statBody.maxShield.ToString("0.##") }, - { "$barrier", (statBody) => Math.Floor(statBody.healthComponent.barrier).ToString("0.##") }, - { "$maxbarrier", (statBody) => statBody.maxBarrier.ToString("0.##") }, - { "$armor", (statBody) => statBody.armor.ToString("0.##") }, - { "$regen", (statBody) => statBody.regen.ToString("0.##") }, - { "$movespeed", (statBody) => statBody.moveSpeed.ToString("0.##") }, - { - "$velocity", (statBody) => - { - return (statBody.characterMotor != null) ? statBody.characterMotor.velocity.magnitude.ToString("0.##") : "n/a"; - } - }, - { - "$2dvelocity", (statBody) => - { - if(statBody.characterMotor != null) - { - var vector = statBody.characterMotor.velocity; - vector.y = 0; - return vector.magnitude.ToString("0.##"); - } - return "n/a"; - } - }, - { "$jumps", (statBody) => { - if(statBody.characterMotor != null) - { - return (statBody.maxJumpCount - statBody.characterMotor.jumpCount).ToString(); - } - return "0"; - } - }, - { "$maxjumps", (statBody) => statBody.maxJumpCount.ToString() }, - { "$atkspd", (statBody) => statBody.attackSpeed.ToString() }, - { "$luck", (statBody) => statBody.master.luck.ToString() }, - { "$multikill", (statBody) => statBody.multiKillCount.ToString() }, - { "$highestmultikill", (statBody) => highestMultikill.ToString() }, - { "$killcount", (statBody) => statBody.killCountServer.ToString() }, - //{ \"$deaths", (statBody) => statBody.master.dea }, - { "$dpscharacter", (statBody) => DPSMeter.CharacterDPS.ToString("N0") }, - { "$dpsminion", (statBody) => DPSMeter.MinionDPS.ToString("N0") }, - { "$dps", (statBody) => DPSMeter.DPS.ToString("N0") }, - { "$mountainshrines", (statBody) => TeleporterInteraction.instance ? TeleporterInteraction.instance.shrineBonusStacks.ToString() : "N/A" }, - { "$blueportal", (statBody) => TeleporterInteraction.instance ? TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal.ToString() : "N/A" }, - { "$goldportal", (statBody) => TeleporterInteraction.instance ? TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal.ToString() : "N/A" }, - { "$celestialportal", (statBody) => TeleporterInteraction.instance ? TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal.ToString() : "N/A" }, - { "$voidportal", (statBody) => TeleporterInteraction.instance ? TeleporterInteraction.instance.portalSpawners.Any(spawner => spawner.previewChildName == "VoidPortalIndicator" && spawner.NetworkwillSpawn).ToString() : "N/A"}, - { "$difficulty", (statBody) => Run.instance.difficultyCoefficient.ToString("0.##") }, - }; - var sortedKeys = regexmap.Keys.ToList(); - sortedKeys.Sort((s1, s2) => s2.Length - s1.Length); - regexpattern = new Regex(@"(\" + String.Join(@"|\", sortedKeys) + ")"); - - - if (ConfigManager.StatsDisplayEnable.Value) - { - RoR2.Run.onRunStartGlobal += runStartGlobal; - } - BetterUIPlugin.onStart += onStart; - BetterUIPlugin.onUpdate += onUpdate; - BetterUIPlugin.onHUDAwake += onHUDAwake; - } - internal static void Hook() { } - public static void AddStatsDisplay(string token, Func displayCallback) - { - AddStatsDisplay(token, new DisplayCallback(displayCallback)); - } - public static void AddStatsDisplay(string token, DisplayCallback displayCallback) - { - regexmap[token] = displayCallback; - var sortedKeys = regexmap.Keys.ToList(); - sortedKeys.Sort((s1, s2) => s2.Length - s1.Length); - regexpattern = new Regex(@"(\" + String.Join(@"|\", sortedKeys) + ")"); - normalText = regexpattern.Split(ConfigManager.StatsDisplayStatString.Value); - altText = regexpattern.Split(ConfigManager.StatsDisplayStatStringCustomBind.Value); - } - - - static void onStart() - { - normalText = regexpattern.Split(ConfigManager.StatsDisplayStatString.Value); - altText = regexpattern.Split(ConfigManager.StatsDisplayStatStringCustomBind.Value); - } - - - internal static void runStartGlobal(RoR2.Run self) - { - highestMultikill = 0; - } - static void onHUDAwake(RoR2.UI.HUD self) - { - if (ConfigManager.StatsDisplayEnable.Value) - { - statsDisplayContainer = new GameObject("StatsDisplayContainer"); - RectTransform rectTransform = statsDisplayContainer.AddComponent(); - - if (ConfigManager.StatsDisplayAttachToObjectivePanel.Value) - { - stupidBuffer = new GameObject("StupidBuffer"); - RectTransform rectTransform3 = stupidBuffer.AddComponent(); - LayoutElement layoutElement2 = stupidBuffer.AddComponent(); - - layoutElement2.minWidth = 0; - layoutElement2.minHeight = 2; - layoutElement2.flexibleHeight = 1; - layoutElement2.flexibleWidth = 1; - - stupidBuffer.transform.SetParent(BetterUIPlugin.objectivePanelController.objectiveTrackerContainer.parent.parent.transform); - statsDisplayContainer.transform.SetParent(BetterUIPlugin.objectivePanelController.objectiveTrackerContainer.parent.parent.transform); - - rectTransform.localPosition = new Vector3(0, -10, 0); - rectTransform.anchorMin = Vector2.zero; - rectTransform.anchorMax = Vector2.one; - rectTransform.localScale = new Vector3(1, -1, 1); - rectTransform.sizeDelta = Vector2.zero; - rectTransform.anchoredPosition = new Vector2(0, 0); - rectTransform.eulerAngles = new Vector3(0, 6, 0); - } - else - { - statsDisplayContainer.transform.SetParent(BetterUIPlugin.hud.mainContainer.transform); - - rectTransform.localPosition = new Vector3(0, 0, 0); - rectTransform.anchorMin = ConfigManager.StatsDisplayWindowAnchorMin.Value; - rectTransform.anchorMax = ConfigManager.StatsDisplayWindowAnchorMax.Value; - rectTransform.localScale = new Vector3(1, -1, 1); - rectTransform.sizeDelta = ConfigManager.StatsDisplayWindowSize.Value; - rectTransform.anchoredPosition = ConfigManager.StatsDisplayWindowPosition.Value; - rectTransform.eulerAngles = ConfigManager.StatsDisplayWindowAngle.Value; - } - - - VerticalLayoutGroup verticalLayoutGroup = statsDisplayContainer.AddComponent(); - verticalLayoutGroup.padding = new RectOffset(5, 5, 10, 5); - - GameObject statsDisplayText = new GameObject("StatsDisplayText"); - RectTransform rectTransform2 = statsDisplayText.AddComponent(); - textMesh = statsDisplayText.AddComponent(); - LayoutElement layoutElement = statsDisplayText.AddComponent(); - - statsDisplayText.transform.SetParent(statsDisplayContainer.transform); - - - rectTransform2.localPosition = Vector3.zero; - rectTransform2.anchorMin = Vector2.zero; - rectTransform2.anchorMax = Vector2.one; - rectTransform2.localScale = new Vector3(1, -1, 1); - rectTransform2.sizeDelta = Vector2.zero; - rectTransform2.anchoredPosition = Vector2.zero; - - if (ConfigManager.StatsDisplayPanelBackground.Value) - { - Image copyImage = BetterUIPlugin.objectivePanelController.objectiveTrackerContainer.parent.GetComponent(); - if (copyImage != null) - { - Image image = statsDisplayContainer.AddComponent(); - image.sprite = copyImage.sprite; - image.color = copyImage.color; - image.type = Image.Type.Sliced; - } - } - - textMesh.fontSize = 12; - textMesh.fontSizeMin = 6; - textMesh.faceColor = Color.white; ; - textMesh.outlineColor = Color.black; - textMesh.fontMaterial.SetFloat(ShaderUtilities.ID_FaceDilate, 0.2f); - textMesh.fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, 0.4f); - - layoutElement.minWidth = 1; - layoutElement.minHeight = 1; - layoutElement.flexibleHeight = 1; - layoutElement.flexibleWidth = 1; - } - } - static void onUpdate() - { - if (ConfigManager.StatsDisplayAttachToObjectivePanel.Value) - { - if (stupidBuffer != null) - { - stupidBuffer.transform.SetAsLastSibling(); - } - if (statsDisplayContainer != null) - { - statsDisplayContainer.transform.SetAsLastSibling(); - } - } - if (BetterUIPlugin.hud && BetterUIPlugin.hud.targetBodyObject && textMesh) - { - playerBody = BetterUIPlugin.hud.targetBodyObject ? BetterUIPlugin.hud.targetBodyObject.GetComponent() : null; - if (playerBody) - { - bool customBindPressed = Input.GetKey(ConfigManager.StatsDisplayCustomBind.Value); - if (Input.GetKeyDown(ConfigManager.StatsDisplayCustomBind.Value)) statsDisplayToggle = !statsDisplayToggle; - bool showStatsDisplay = ConfigManager.StatsDisplayToggleOnBind.Value ? statsDisplayToggle : !(ConfigManager.StatsDisplayShowCustomBindOnly.Value && !customBindPressed); - - highestMultikill = playerBody.multiKillCount > highestMultikill ? playerBody.multiKillCount : highestMultikill; - - statsDisplayContainer.SetActive(showStatsDisplay); - if (showStatsDisplay) - { - BetterUIPlugin.sharedStringBuilder.Clear(); - if (customBindPressed) - { - for (int i = 0; i < altText.Length; i++) - { - if (i % 2 == 0) - { - BetterUIPlugin.sharedStringBuilder.Append(altText[i]); - } - else - { - BetterUIPlugin.sharedStringBuilder.Append(regexmap[altText[i]](playerBody)); - } - } - } - else - { - for (int i = 0; i < normalText.Length; i++) - { - if (i % 2 == 0) - { - BetterUIPlugin.sharedStringBuilder.Append(normalText[i]); - - } - else - { - BetterUIPlugin.sharedStringBuilder.Append(regexmap[normalText[i]](playerBody)); - } - } - } - textMesh.SetText(BetterUIPlugin.sharedStringBuilder); - } - } - } - } - } -} diff --git a/README.md b/README.md index eabc6ed2..6d1b12a2 100644 --- a/README.md +++ b/README.md @@ -2,188 +2,4 @@ # BetterUI -A simple mod that adds various UI improvements. -Each can be disabled and configured in the config file. - -## Translators Wanted! - -If you want to help add new translations or improve our existing ones, please join [my Discord server](https://discord.faby.dev) and ping me (xoxfaby). - -## Support Me - -If you like what I'm doing, consider supporting me through GitHub Sponsors so I can keep doing it: - -https://github.com/sponsors/xoxfaby - -## Currently implemented: -- ItemStats -- Item Counters -- DPS Meter -- StatsDisplay -- Ordered Inventory, Scrapper Menu, Command Menu -- Command/Scrapper Menu Item Counters and Tooltips -- Close the command menu with escape, WASD or a custom keybind -- Automatically resize the command window if there are more items -- Remove background blur from command window -- Advanced Item Descriptions -- Advanced Equipment Descriptions -- Hide Pickup Notifications -- Skill Proc Coefficients with calculated effects based on the items you are carrying -- Buff Timers and Tooltips -- Show Hidden Items - -## Help & Feedback - -If you need help or have suggestions, create an issue on github, join my discord or find me on the RoR2 Modding Discord - -[My Discord Server](https://discord.faby.dev) @xoxfaby - -Please do not add me on discord, join of the the two servers and ping me there. - -https://github.com/xoxfaby/BetterUI - -## Features - -### ItemStats -Show calculcated stat bonuses for your items. - -![ItemStats](https://cdn.faby.dev/itemstats.png) - -### ItemCounters -Customizable ItemCounters. Choose which tiers you want counted, choose which tiers to show. -Use ItemScore to not just see how many items you have but how good they are. -By default item score is based on tiers, but you can change how much each tier is worth or even set custom values for each item! - -![ItemCounters](https://cdn.faby.dev/itemcounters.png) - -### DPSMeter -Fully clientside DPS Meter that can be integrated into the StatsDisplay. Counts minion damage! - -![DPSMeter](https://cdn.faby.dev/dpsmeter.png) - -### StatsDisplay -Show all of your character's stats! Completely customizable! - -![StatsDisplay](https://cdn.faby.dev/statsdisplay.png) - -### Skill Proc Coefficient Information - -![Skill Tooltip](https://cdn.faby.dev/skilltooltip.png) - -### Command/Scrapper Improvements -See how many items you have when using the scrapper or picking an item using the command artifact! -Tooltips with ItemStats! -Close the command/scrapper window with Escape, WASD or a custom keybind! - -![Command Counters](https://cdn.faby.dev/commandcounters.png) - -### Improved Item Sorting -Sort items alphabetically, by tier, stacks or even tags like "Scrap" or "Damage". EVEN RANDOMLY?! - -![Item Sorting](https://cdn.faby.dev/itembar.png) - -![Sorted Scrapper](https://cdn.faby.dev/sortedscrapper.png) - -### BuffTimers & Tooltips -Buff timers currently only work if you are the host because the timers are not networked in multiplayer. - -![Buff Timers](https://cdn.faby.dev/buffs.png) - -### Advanced item descriptions -Use the advanced item descriptions from the logbook that show the actual numbers for all the changes. -Integration with ItemStats in the command and scrapper windows. - -![Item Description](https://cdn.faby.dev/itemdesc.png) - -### Show Hidden Items -Show hidden items like the hidden monsoon/drizzle items - -## Configuration - -#### StatsDisplay - -The StatsDisplay parses the `StatString` in the config file and replaces all the parameters it finds. -The StatsDisplay can also be moved, resized and recolored and formatted ( See: http://digitalnativestudios.com/textmeshpro/docs/rich-text/ ) -If you want another parameter added, feel free to suggest it to me (See Help & Feedback) -Here is a list of all valid parameters right now - -$exp $level $luck -$dmg $crit $luckcrit $atkspd -$hp $maxhp $shield $maxshield $barrier $maxbarrier -$armor $armordmgreduction $regen -$movespeed $jumps $maxjumps -$killcount $multikill $highestmultikill -$dps $dpscharacter $dpsminions -$mountainshrines -$blueportal $goldportal $celestialportal - -#### Sorting - -The sorting is completely customizable. -The default sorting value is **S134** - -**S** means the items are first sorted by the "Scrap" tag and all the scrap is put at the end of the list. -**1** then sorts it by tier, in descending order, putting higher tier items at the front. -**3** sorts it by the stack size in descending order, meaning if you have more of an item, it will come first. -**4** then sorts it by pickup order, meaning items you got first, come first. - -You can customize this in any way you like. - -Filters: - -\# + a tag will apply the next sorting to only items that match the tag. -You can use any tags from the tag based sorting. -Examples: -`#s0` to sort scrap by tier ascending. -`#t14#t28` to sort Tier 1 items by pickup order and tier 2 items randomly. - -The full options: - -0 = Tier Ascending -1 = Tier Descending -2 = Stack Size Ascending -3 = Stack Size Descending -4 = Pickup Order -5 = Pickup Order Reversed -6 = Alphabetical -7 = Alphabetical Reversed -8 = Random -i = ItemIndex -I = ItemIndex Descending - -Tag Based: - -s = Scrap First -S = Scrap Last -d = Damage First -D = Damage Last -h = Healing First -H = Healing Last -u = Utility First -U = Utility Last -o = On Kill Effect First -O = On Kill Effect Last -e = Equipment Related First -E = Equipment Related Last -p = Sprint Related First -P = Sprint Related Last - -t1 = Tier 1 First -t2 = Tier 2 First -t3 = Tier 3 First -tL = Lunar Tier First -tB = Boss Tier First -tN = NoTier First - -T1 = Tier 1 Last -T2 = Tier 2 Last -T3 = Tier 3 Last -TL = Lunar Tier Last -TB = Boss Tier Last -TN = NoTier Last - -Single Items: -You can position specific items by specifying their internal name, using angle brackets to specify where. -Examples: -`s<(RegeneratingScrap)134` to place all scrap first, then regenerating scrap, then the rest of your items as normal. -`>(Behemoth)S134` to always place the brillant behemoth last, then the rest of your items as normal. +A mod that makes the UI better by adding a nice little button to the main menu \ No newline at end of file diff --git a/Thunderstore/thunderstore.toml b/Thunderstore/thunderstore.toml index e9267a76..8a0fa5f9 100644 --- a/Thunderstore/thunderstore.toml +++ b/Thunderstore/thunderstore.toml @@ -5,7 +5,7 @@ schemaVersion = "0.0.1" namespace = "XoXFaby" name = "BetterUI" versionNumber = "2.0.0" -description = "Looking for translators! Various UI improvements like ordered items with multiple ways of sorting, DPSMeter, Item Counters, Skill/Equipment/Item Information, Command/Scrapper counters and other improvements, customizable StatsDisplay, and much more." +description = "A mod that makes the UI better by adding a nice little button to the main menu." websiteUrl = "https://github.com/xoxfaby/BetterUI" containsNsfwContent = false diff --git a/Utils/ModCompat.cs b/Utils/ModCompat.cs deleted file mode 100644 index 28af0737..00000000 --- a/Utils/ModCompat.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using RoR2; - -namespace BetterUI -{ - namespace ModCompatibility - { - internal static class BetterAPICompatibility - { - internal static class Buffs - { - public static void AddName(BuffDef buffDef, string nameToken) - { - BetterAPI.Buffs.AddName(buffDef, nameToken); - } - public static void AddDescription(BuffDef buffDef, string descriptionToken) - { - BetterAPI.Buffs.AddDescription(buffDef, descriptionToken); - } - - public static void AddInfo(BuffDef buffDef, string nameToken = null, string descriptionToken = null) - { - BetterAPI.Buffs.AddInfo(buffDef, nameToken, descriptionToken); - } - public static void AddInfo(BuffDef buffDef, BetterUI.Buffs.BuffInfo buffInfo) - { - BetterAPI.Buffs.BuffInfo BetterAPIBuffInfo = new BetterAPI.Buffs.BuffInfo - { - nameToken = buffInfo.nameToken, - descriptionToken = buffInfo.descriptionToken, - }; - BetterAPI.Buffs.AddInfo(buffDef, BetterAPIBuffInfo); - } - - public static string GetName(BuffDef buffDef) - { - return BetterAPI.Buffs.GetName(buffDef); - } - public static string GetDescription(BuffDef buffDef) - { - return BetterAPI.Buffs.GetDescription(buffDef); - } - } - } - } -} \ No newline at end of file diff --git a/Utils/ProcCoefficientCatalog.cs b/Utils/ProcCoefficientCatalog.cs deleted file mode 100644 index 11b6133c..00000000 --- a/Utils/ProcCoefficientCatalog.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Linq; - -namespace BetterUI -{ - public static class ProcCoefficientCatalog - { - public struct ProcCoefficientInfo - { - public string name; - public float procCoefficient; - } - - private static readonly Dictionary> skills = new Dictionary>(); - public static void AddSkill(string skillDef, List procCoefficientInfoList) - { - skills[skillDef] = procCoefficientInfoList; - } - public static void AddSkill(string skillDef, ProcCoefficientInfo procCoefficientInfo) - { - skills[skillDef] = new List() { procCoefficientInfo }; - } - public static void AddSkill(string skillDef, string name, float procCoefficient) - { - AddSkill(skillDef, new ProcCoefficientInfo() { name = name, procCoefficient = procCoefficient }); - } - public static void AddToSkill(string skillDef, ProcCoefficientInfo procCoefficientInfo) - { - if (skills.ContainsKey(skillDef)) - { - skills[skillDef].Add(procCoefficientInfo); - } - else - { - AddSkill(skillDef,procCoefficientInfo); - } - } - public static void AddToSkill(string skillDef, string name, float procCoefficient) - { - AddToSkill(skillDef, new ProcCoefficientInfo() { name = name, procCoefficient = procCoefficient }); - } - public static List GetProcCoefficientInfo(string skillDef) - { - return skills.ContainsKey(skillDef) ? skills[skillDef] : null; - } - - static ProcCoefficientCatalog() - { - // Acrid - AddSkill("CrocoSlash", "SKILL_SLASH_NAME", 1); - AddSkill("CrocoSpit", "SKILL_SPIT_NAME", 1); - AddSkill("CrocoBite", "SKILL_BITE_NAME", 1); - AddSkill("CrocoLeap", "SKILL_LEAP_NAME", 1); - AddToSkill("CrocoLeap", "SKILL_POOL_NAME", 0.1f); - AddSkill("CrocoChainableLeap", "SKILL_LEAP_NAME", 1); - AddSkill("CrocoDisease", "SKILL_BOUNCE_NAME", 1); - - // Artificer - AddSkill("MageBodyFireFirebolt", "SKILL_BOLT_NAME", 1); - AddSkill("MageBodyFireLightningBolt", "SKILL_BOLT_NAME", 1); - AddSkill("MageBodyNovaBomb", "SKILL_EXPLOSION_NAME", 1); - AddToSkill("MageBodyNovaBomb", "SKILL_SPARKS_NAME", 0.3f); - AddSkill("MageBodyIceBomb", "SKILL_SPEAR_NAME", 1); - AddSkill("MageBodyWall", "SKILL_WALL_NAME", 1); - AddSkill("MageBodyFlamethrower", "SKILL_FLAMETHROWER_NAME", 1); - AddSkill("MageBodyFlyUp", "SKILL_SURGE_NAME", 1); - - // Bandit - AddSkill("FireShotgun2", "SKILL_BURST_NAME", 0.5f); - AddSkill("Bandit2Blast", "SKILL_BLAST_NAME", 1); - AddSkill("SlashBlade", "SKILL_SLASH_NAME", 1); - AddSkill("Bandit2SerratedShivs", "SKILL_BLADE_NAME", 1); - AddSkill("ResetRevolver", "SKILL_SHOT_NAME", 1); - AddSkill("SkullRevolver", "SKILL_SHOT_NAME", 1); - AddSkill("ThrowSmokebomb", "SKILL_SMOKEBOMB_NAME", 1); - - // Captain - AddSkill("CaptainShotgun", "SKILL_SHOTGUN_NAME", 0.75f); - AddSkill("CaptainTazer", "SKILL_POWERTAZER_NAME", 1); - AddSkill("CallAirstrike", "SKILL_AIRSTRIKE_NAME", 1); - AddSkill("CallAirstrikeAlt", "SKILL_AIRSTRIKE_NAME", 1); - AddSkill("PrepSupplyDrop", "SKILL_IMPACT_NAME", 0); - - // Commando - AddSkill("CommandoBodyFirePistol", "SKILL_BULLET_NAME", 1); - AddSkill("CommandoBodyFireFMJ", "SKILL_PHASEROUND_NAME", 1); - AddSkill("CommandoBodyFireShotgunBlast", "SKILL_SHOTGUN_NAME", 0.5f); - AddSkill("CommandoBodyBarrage", "SKILL_BULLET_NAME", 1); - AddSkill("ThrowGrenade", "SKILL_GRENADE_NAME", 1); - - // Engineer - AddSkill("EngiBodyFireGrenade", "SKILL_GRENADE_NAME", 1); - AddSkill("EngiBodyPlaceMine", "SKILL_MINE_NAME", 1); - AddSkill("EngiBodyPlaceSpiderMine", "SKILL_MINE_NAME", 1); - AddSkill("EngiHarpoons", "SKILL_HARPOON_NAME", 1); - AddSkill("EngiBodyPlaceTurret", "SKILL_TURRETSHOT_NAME", 1); - AddSkill("EngiBodyPlaceWalkerTurret", "SKILL_LASER_NAME", 0.6f); - - // Huntress - AddSkill("HuntressBodyFireSeekingArrow", "SKILL_ARROW_NAME", 1); - AddSkill("FireFlurrySeekingArrow", "SKILL_ARROW_NAME", 0.7f); - AddSkill("HuntressBodyGlaive", "SKILL_GLAIVE_NAME", 0.8f); - AddSkill("HuntressBodyArrowRain", "SKILL_RAIN_NAME", 0.2f); - AddSkill("AimArrowSnipe", "SKILL_BALLISTA_NAME", 1); - - // Loader - AddSkill("SwingFist", "SKILL_FIST_NAME", 1); - AddSkill("FireYankHook", "SKILL_FIST_NAME", 1); - AddSkill("BigPunch", "SKILL_FIST_NAME", 1); - AddSkill("ChargeZapFist", "SKILL_FIST_NAME", 1); - AddSkill("ThrowPylon", "SKILL_ZAP_NAME", 0.5f); - AddSkill("GroundSlam", "SKILL_SLAM_NAME", 1); - - // Mercenary - AddSkill("MercGroundLight2", "SKILL_SWORD_NAME", 1); - AddSkill("MercBodyWhirlwind", "SKILL_SLICE_NAME", 1); - AddSkill("MercBodyUppercut", "SKILL_SLICE_NAME", 1); - AddSkill("MercBodyAssaulter", "SKILL_DASH_NAME", 1); - AddSkill("MercBodyFocusedAssault", "SKILL_DASH_NAME", 1); - AddSkill("MercBodyEvis", "SKILL_HIT_NAME", 1); - AddSkill("MercBodyEvisProjectile", "SKILL_BLADE_NAME", 1); - - // MUL-T - AddSkill("ToolbotBodyFireNailgun", "SKILL_NAIL_NAME", 0.6f); - AddSkill("ToolbotBodyFireSpear", "SKILL_REBAR_NAME", 1); - AddSkill("ToolbotBodyFireGrenadeLauncher", "SKILL_ROCKET_NAME", 1); - AddSkill("ToolbotBodyFireBuzzsaw", "SKILL_SAW_NAME", 1); - AddSkill("ToolbotBodyStunDrone", "SKILL_CANISTER_NAME", 1); - AddToSkill("ToolbotBodyStunDrone", "SKILL_BOMBLET_NAME", 0.3f); - AddSkill("ToolbotBodyToolbotDash", "SKILL_CHARGE_NAME", 1); - AddToSkill("ToolbotBodyToolbotDash", "SKILL_RAM_NAME", 1); - - // REX - AddSkill("TreebotBodyFireSyringe", "SKILL_SYRINGES_NAME", 0.5f); - AddSkill("TreebotBodyAimMortar2", "SKILL_MORTAR_NAME", 1); - AddSkill("TreebotBodyAimMortarRain", "SKILL_HIT_NAME", 0.5f); - AddSkill("TreebotBodySonicBoom", "SKILL_BOOM_NAME", 0); - AddSkill("TreebotBodyPlantSonicBoom", "SKILL_BOOM_NAME", 0.5f); - AddSkill("TreebotBodyFireFlower2", "SKILL_PROJECTILE_NAME", 1); - AddToSkill("TreebotBodyFireFlower2", "SKILL_ROOTS_NAME", 0); - AddSkill("TreebotBodyFireFruitSeed", "SKILL_PROJECTILE_NAME", 1); - - // Railgunner - AddSkill("RailgunnerBodyFirePistol", "SKILL_PROJECTILE_NAME", 1f); - AddSkill("RailgunnerBodyScopeHeavy", "SKILL_PROJECTILE_NAME", 1f); - AddSkill("RailgunnerBodyFireSnipeHeavy", "SKILL_PROJECTILE_NAME", 1f); - AddSkill("RailgunnerBodyScopeLight", "SKILL_PROJECTILE_NAME", 1f); - AddSkill("RailgunnerBodyFireSnipeLight", "SKILL_PROJECTILE_NAME", 1f); - AddSkill("RailgunnerBodyFireMineBlinding", "SKILL_MINE_NAME", 0f); - AddSkill("RailgunnerBodyFireMineConcussive", "SKILL_MINE_NAME", 0f); - AddSkill("RailgunnerBodyChargeSnipeCryo", "SKILL_PROJECTILE_NAME", 1.5f); - AddSkill("RailgunnerBodyFireSnipeCryo", "SKILL_PROJECTILE_NAME", 1.5f); - AddSkill("RailgunnerBodyChargeSnipeSuper", "SKILL_PROJECTILE_NAME", 3f); - AddSkill("RailgunnerBodyFireSnipeSuper", "SKILL_PROJECTILE_NAME", 3f); - - // Void Fiend - AddSkill("FireHandBeam", "SKILL_BEAM_NAME", 1f); - AddSkill("FireCorruptBeam", "SKILL_BEAM_NAME", 0.625f); - AddSkill("ChargeMegaBlaster", "SKILL_FLOOD_NAME", 1); - AddSkill("FireCorruptDisk", "SKILL_FLOOD_NAME", 1); - AddSkill("CrushCorruption", "SKILL_CRUSH_NAME", 0f); - AddSkill("CrushHealth", "SKILL_CRUSH_NAME", 0f); - - // Items - AddSkill("LunarPrimaryReplacement", "SKILL_SHARD_NAME", 0.1f); - AddToSkill("LunarPrimaryReplacement", "SKILL_EXPLOSION_NAME", 1); - AddSkill("LunarSecondaryReplacement", "SKILL_MAELSTROM_NAME", 0.2f); - AddToSkill("LunarSecondaryReplacement", "SKILL_EXPLOSION_NAME", 1); - AddSkill("LunarDetonatorSpecialReplacement", "SKILL_DETONATION_NAME", 1); - } - } -} diff --git a/Utils/ProcItemCatalog.cs b/Utils/ProcItemCatalog.cs deleted file mode 100644 index 52f72100..00000000 --- a/Utils/ProcItemCatalog.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using RoR2; - -namespace BetterUI -{ - [Obsolete] - public static class ProcItemsCatalog - { - [Obsolete] - private static StringBuilder formatterStringBuilder = new StringBuilder(); - - - public static string ChanceFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) - { - formatterStringBuilder.Clear(); - formatterStringBuilder.Append(""); - formatterStringBuilder.Append(Math.Min(100, 100 * Utils.LuckCalc(value * procCoefficient, luck)).ToString("0.##")); - formatterStringBuilder.Append("%"); - return formatterStringBuilder.ToString(); - } - - public static string HPFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) - { - formatterStringBuilder.Clear(); - formatterStringBuilder.Append(""); - formatterStringBuilder.Append(value * procCoefficient); - formatterStringBuilder.Append(" HP"); - return formatterStringBuilder.ToString(); - } - - public static string RangeFormatter(float value, float procCoefficient, float luck, bool canCap, int cap) - { - formatterStringBuilder.Clear(); - formatterStringBuilder.Append(""); - formatterStringBuilder.Append(value * procCoefficient); - formatterStringBuilder.Append("m "); - return formatterStringBuilder.ToString(); - } - - public delegate string EffectFormatter(float value, float procCoefficient, float luck, bool canCap, int cap); - public class FormatterTranslater - { - EffectFormatter effectFormatter; - internal FormatterTranslater(EffectFormatter effectFormatter) - { - this.effectFormatter = effectFormatter; - } - - public void Formatter(StringBuilder stringBuilder, float value, CharacterMaster master) - { - stringBuilder.Append(effectFormatter(value, 1, 1, false, 1)); - } - } - - - [Obsolete] - public delegate float StackingFormula(float value, float extraStackValue, int stacks); - [Obsolete] - public static StackingFormula LinearStacking = ItemStats.LinearStacking; - [Obsolete] - public static StackingFormula ExponentialStacking = ItemStats.ExponentialStacking; - [Obsolete] - public static StackingFormula HyperbolicStacking = ItemStats.HyperbolicStacking; - [Obsolete] - public static StackingFormula NoStacking = ItemStats.NoStacking; - - [Obsolete] - public delegate int CapFormula(float value, float extraStackValue, float procCoefficient); - [Obsolete] - public static CapFormula LinearCap = ItemStats.LinearCap; - - [Obsolete] - public class EffectInfo - { - public float value; - public float extraStackValue; - public EffectFormatter effectFormatter; - public StackingFormula stackingFormula; - public CapFormula capFormula; - - public ItemStats.ItemProcInfo ToItemProcInfo() - { - var itemProcInfo = new ItemStats.ItemProcInfo() - { - value = value, - extraStackValue = extraStackValue, - statFormatter = new ItemStats.StatFormatter() - { - statFormatter = (new FormatterTranslater(effectFormatter)).Formatter - }, - stackingFormula = new ItemStats.StackingFormula(stackingFormula), - capFormula = new ItemStats.CapFormula(capFormula) - }; - return itemProcInfo; - } - } - - [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] - public static void AddEffect(ItemIndex itemIndex, EffectInfo effectInfo) - { - if (itemIndex <= ItemIndex.None) - { - UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); - return; - } - AddEffect(ItemCatalog.GetItemDef(itemIndex), effectInfo); - } - - [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] - public static void AddEffect(ItemIndex itemIndex, float value, float? extraStackValue = null, EffectFormatter effectFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) - { - if (itemIndex <= ItemIndex.None) - { - UnityEngine.Debug.LogError("ERROR: AddEffect was passed ItemIndex.None or below, this likely means you tried to register your effect before the item catalog was ready. Please use ItemCatalog.availability.CallWhenAvailable or pass an ItemDef directly."); - return; - } - AddEffect(ItemCatalog.GetItemDef(itemIndex), value, extraStackValue, effectFormatter, stackingFormula, capFormula); - } - - [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] - public static void AddEffect(ItemDef itemDef, EffectInfo effectInfo) - { - ItemStats.RegisterProc(itemDef, effectInfo.ToItemProcInfo()); - } - - [Obsolete("Removed, please use BetterUI.ItemStats.RegisterEffect", true)] - public static void AddEffect(ItemDef itemDef, float value, float? extraStackValue = null, EffectFormatter effectFormatter = null, StackingFormula stackingFormula = null, CapFormula capFormula = null) - { - AddEffect(itemDef, new EffectInfo() { - value = value, - extraStackValue = extraStackValue ?? value, - effectFormatter = effectFormatter ?? ChanceFormatter, - stackingFormula = stackingFormula ?? LinearStacking, - capFormula = capFormula - }); - } - } -} diff --git a/Utils/Utils.cs b/Utils/Utils.cs deleted file mode 100644 index c684c79f..00000000 --- a/Utils/Utils.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using RoR2.Skills; -using R2API.Utils; - -[assembly: ManualNetworkRegistration] -namespace BetterUI -{ - static class Utils - { - - - public static float LuckCalc(float chance, float luck) - { - if (luck == 0) - { - return chance; - } - else if (luck < 0) - { - return (float)((int)chance + Math.Pow(chance % 1, Math.Abs(luck) + 1)); - } - else - { - return (float)((int)chance + (1 - Math.Pow(1 - (chance % 1), Math.Abs(luck) + 1))); - } - } - - public static int TheREALFindSkillIndexByName(String skillDefName) - { - for (int i = SkillCatalog._allSkillDefs.Length - 1; i >= 0; i--) - { - if (SkillCatalog._allSkillNames[i] == skillDefName) - { - return i; - } - } - return -1; - } - } -} - -namespace R2API.Utils -{ - [AttributeUsage(AttributeTargets.Assembly)] - public class ManualNetworkRegistrationAttribute : Attribute { } -} \ No newline at end of file