diff --git a/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj index 399dcbf..ea40f0d 100644 --- a/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj +++ b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj @@ -2,7 +2,7 @@ net472 - 1.5.0 + 1.5.1 bepis69 diff --git a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs index 4ea8213..ad6751d 100644 --- a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs +++ b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs @@ -15,6 +15,8 @@ namespace CactusPie.ContainerQuickLoot internal static ConfigEntry AutoMergeStacksForNonLootContainers { get; set; } + internal static ConfigEntry CustomizeTagForLootContainers {get; set;} + [UsedImplicitly] internal void Start() { @@ -65,6 +67,17 @@ namespace CactusPie.ContainerQuickLoot ) ); + CustomizeTagForLootContainers = Config.Bind + ( + sectionName, + "Customize the keyword used to denote loot containers in tags", + "@loot", + new ConfigDescription + ( + "Customize the keyword used to denote loot containers in tags\nDefault value: \"@loot\"" + ) + ); + new QuickTransferPatch().Enable(); } } diff --git a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs index 192c198..0c28603 100644 --- a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs +++ b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs @@ -7,12 +7,13 @@ using SPT.Reflection.Patching; using Comfort.Common; using EFT; using EFT.InventoryLogic; +using System.CodeDom; +using System.ComponentModel; namespace CactusPie.ContainerQuickLoot { public class QuickTransferPatch : ModulePatch { - private static readonly Regex LootTagRegex = new Regex("@loot[0-9]*", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100)); protected override MethodBase GetTargetMethod() { @@ -159,6 +160,14 @@ namespace CactusPie.ContainerQuickLoot { var matchingContainerCollections = new List<(ContainerCollection containerCollection, int priority)>(); + string tag = ContainerQuickLootPlugin.CustomizeTagForLootContainers.Value.ToString(); + Regex lootTagRegex = new Regex + ( + tag + "[0-9]*", + RegexOptions.None, + TimeSpan.FromMilliseconds(100) + ); + foreach (Item inventoryItem in inventory.Equipment.GetAllItems()) { // It has to be a container collection - an item that we can transfer the loot into @@ -173,8 +182,8 @@ namespace CactusPie.ContainerQuickLoot continue; } - // We check if there is a @loot tag - Match regexMatch = LootTagRegex.Match(tagComponent.Name); + // We check if there is a tag + Match regexMatch = lootTagRegex.Match(tagComponent.Name); if (!regexMatch.Success) { @@ -191,9 +200,8 @@ namespace CactusPie.ContainerQuickLoot // We extract the suffix - if not suffix provided, we assume 0 // Length of @loot - we only want the number suffix - const int lootTagLength = 5; - string priorityString = regexMatch.Value.Substring(lootTagLength); + string priorityString = regexMatch.Value.Substring(tag.Length); int priority = priorityString.Length == 0 ? 0 : int.Parse(priorityString); matchingContainerCollections.Add((containerCollection, priority));