Automatically merge stacks when moving items
This commit is contained in:
parent
b176d90467
commit
208a906f24
@ -1,6 +1,5 @@
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Logging;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace CactusPie.ContainerQuickLoot
|
||||
@ -12,6 +11,8 @@ namespace CactusPie.ContainerQuickLoot
|
||||
|
||||
internal static ConfigEntry<bool> EnableForLooseLoot { get; set; }
|
||||
|
||||
internal static ConfigEntry<bool> AutoMergeStacks { get; set; }
|
||||
|
||||
[UsedImplicitly]
|
||||
internal void Start()
|
||||
{
|
||||
@ -38,6 +39,17 @@ namespace CactusPie.ContainerQuickLoot
|
||||
"Automatically put loose loot in containers"
|
||||
)
|
||||
);
|
||||
|
||||
AutoMergeStacks = Config.Bind
|
||||
(
|
||||
sectionName,
|
||||
"Merge stacks",
|
||||
true,
|
||||
new ConfigDescription
|
||||
(
|
||||
"Automatically merge stacks (money, ammo, etc.) when transferring them into a container"
|
||||
)
|
||||
);
|
||||
|
||||
new QuickTransferPatch().Enable();
|
||||
}
|
||||
|
@ -90,6 +90,27 @@ namespace CactusPie.ContainerQuickLoot
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ContainerQuickLootPlugin.AutoMergeStacks.Value && item.StackMaxSize > 1 && item.StackObjectsCount != item.StackMaxSize)
|
||||
{
|
||||
foreach (KeyValuePair<Item, LocationInGrid> containedItem in container.ContainedItems)
|
||||
{
|
||||
if (containedItem.Key.Template._id != item.Template._id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (containedItem.Key.StackObjectsCount + item.StackObjectsCount > item.StackMaxSize)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
GStruct375<GClass2599> mergeResult = GClass2585.Merge(item, containedItem.Key, controller, simulate);
|
||||
__result = new GStruct375<GInterface275>(mergeResult.Value);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GClass2580 location = container.FindLocationForItem(item);
|
||||
if (location == null)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user