Make tag configurable
This commit is contained in:
parent
7a145e1105
commit
0c918afaa0
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<Version>1.5.0</Version>
|
<Version>1.5.1</Version>
|
||||||
<Authors>bepis69</Authors>
|
<Authors>bepis69</Authors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
internal static ConfigEntry<bool> AutoMergeStacksForNonLootContainers { get; set; }
|
internal static ConfigEntry<bool> AutoMergeStacksForNonLootContainers { get; set; }
|
||||||
|
|
||||||
|
internal static ConfigEntry<string> CustomizeTagForLootContainers {get; set;}
|
||||||
|
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
internal void Start()
|
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();
|
new QuickTransferPatch().Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,13 @@ using SPT.Reflection.Patching;
|
|||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
using EFT.InventoryLogic;
|
using EFT.InventoryLogic;
|
||||||
|
using System.CodeDom;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace CactusPie.ContainerQuickLoot
|
namespace CactusPie.ContainerQuickLoot
|
||||||
{
|
{
|
||||||
public class QuickTransferPatch : ModulePatch
|
public class QuickTransferPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static readonly Regex LootTagRegex = new Regex("@loot[0-9]*", RegexOptions.Compiled, TimeSpan.FromMilliseconds(100));
|
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
@ -159,6 +160,14 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
{
|
{
|
||||||
var matchingContainerCollections = new List<(ContainerCollection containerCollection, int priority)>();
|
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())
|
foreach (Item inventoryItem in inventory.Equipment.GetAllItems())
|
||||||
{
|
{
|
||||||
// It has to be a container collection - an item that we can transfer the loot into
|
// It has to be a container collection - an item that we can transfer the loot into
|
||||||
@ -173,8 +182,8 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We check if there is a @loot tag
|
// We check if there is a tag
|
||||||
Match regexMatch = LootTagRegex.Match(tagComponent.Name);
|
Match regexMatch = lootTagRegex.Match(tagComponent.Name);
|
||||||
|
|
||||||
if (!regexMatch.Success)
|
if (!regexMatch.Success)
|
||||||
{
|
{
|
||||||
@ -191,9 +200,8 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
// We extract the suffix - if not suffix provided, we assume 0
|
// We extract the suffix - if not suffix provided, we assume 0
|
||||||
// Length of @loot - we only want the number suffix
|
// 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);
|
int priority = priorityString.Length == 0 ? 0 : int.Parse(priorityString);
|
||||||
|
|
||||||
matchingContainerCollections.Add((containerCollection, priority));
|
matchingContainerCollections.Add((containerCollection, priority));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user