From ea3e3f3a307f3789a0ecd4f772ddc22f1c4ac5e2 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 22 Jan 2025 21:16:10 +0000 Subject: [PATCH] moaaaaar --- .../Core/Utils/Collections/ProbabilityObjectArray.cs | 12 ++++++++++++ Tools/ItemTplGenerator/ItemTplGenerator.cs | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs b/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs index 855eb92d..ea4cdd35 100644 --- a/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs +++ b/Libraries/Core/Utils/Collections/ProbabilityObjectArray.cs @@ -1,5 +1,6 @@ using Core.Utils.Cloners; using System.Text.Json.Serialization; +using Microsoft.AspNetCore.Components.Web; namespace Core.Utils.Collections; @@ -46,6 +47,17 @@ public class ProbabilityObjectArray : List where T : ProbabilityObje return probCumsum; } + public ProbabilityObjectArray Filter(Predicate> predicate) + { + var filtered = new ProbabilityObjectArray(_mathUtil, _cloner, new List()); + foreach (var probabilityObject in this) + { + if (predicate.Invoke(probabilityObject)) + filtered.Add(probabilityObject); + } + return filtered; + } + /** * Clone this ProbabilitObjectArray * @returns {ProbabilityObjectArray} Deep Copy of this ProbabilityObjectArray diff --git a/Tools/ItemTplGenerator/ItemTplGenerator.cs b/Tools/ItemTplGenerator/ItemTplGenerator.cs index 8d8130a0..648d5462 100644 --- a/Tools/ItemTplGenerator/ItemTplGenerator.cs +++ b/Tools/ItemTplGenerator/ItemTplGenerator.cs @@ -190,7 +190,7 @@ public class ItemTplGenerator( // Include any bracketed suffixes that exist, handles the case of colored gun variants var weaponFullName = _localeService.GetLocaleDb()[$"{kv.Key} Name"]?.ToUpper(); - if (weaponFullName.RegexMatch("\\((.+?)\\)$", out var itemNameBracketSuffix) && + if (weaponFullName.RegexMatch(@"\((.+?)\)$", out var itemNameBracketSuffix) && !weaponShortName.EndsWith(itemNameBracketSuffix.Groups[1].Value)) { weaponShortName += $"_{itemNameBracketSuffix.Groups[1].Value}"; @@ -495,7 +495,7 @@ public class ItemTplGenerator( var caliber = CleanCaliber(item.Properties.AmmoCaliber.ToUpper()); // If the item has a bracketed section at the end of its name, include that - if (itemName?.RegexMatch("\\((.+?)\\)$", out var itemNameBracketSuffix) ?? false) + if (itemName?.RegexMatch(@"\((.+?)\)$", out var itemNameBracketSuffix) ?? false) { return $"{caliber}_{itemNameBracketSuffix.Groups[1].Value}"; } @@ -510,7 +510,7 @@ public class ItemTplGenerator( } // If the item has a bracketed section at the end of its name, use that - if (itemName.RegexMatch("\\((.+?)\\)$", out var itemNameBracker)) + if (itemName.RegexMatch(@"\((.+?)\)$", out var itemNameBracker)) { return itemNameBracker.Groups[1].Value; }