Make tag configurable
This commit is contained in:
parent
7a145e1105
commit
0c918afaa0
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<Version>1.5.0</Version>
|
||||
<Version>1.5.1</Version>
|
||||
<Authors>bepis69</Authors>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -15,6 +15,8 @@ namespace CactusPie.ContainerQuickLoot
|
||||
|
||||
internal static ConfigEntry<bool> AutoMergeStacksForNonLootContainers { get; set; }
|
||||
|
||||
internal static ConfigEntry<string> 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();
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user