Add support for loose loot

This commit is contained in:
CactusPie 2023-11-20 11:51:15 +01:00
parent 087714d394
commit b176d90467
2 changed files with 48 additions and 3 deletions

View File

@ -1,4 +1,6 @@
using BepInEx; using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using JetBrains.Annotations; using JetBrains.Annotations;
namespace CactusPie.ContainerQuickLoot namespace CactusPie.ContainerQuickLoot
@ -6,9 +8,37 @@ namespace CactusPie.ContainerQuickLoot
[BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.0.0")] [BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.0.0")]
public class ContainerQuickLootPlugin : BaseUnityPlugin public class ContainerQuickLootPlugin : BaseUnityPlugin
{ {
internal static ConfigEntry<bool> EnableForCtrlClick { get; set; }
internal static ConfigEntry<bool> EnableForLooseLoot { get; set; }
[UsedImplicitly] [UsedImplicitly]
internal void Start() internal void Start()
{ {
const string sectionName = "Container quick loot setting";
EnableForCtrlClick = Config.Bind
(
sectionName,
"Enable for Ctrl+click",
true,
new ConfigDescription
(
"Automatically put the items in containers while transferring them with ctrl+click"
)
);
EnableForLooseLoot = Config.Bind
(
sectionName,
"Enable for loose loot",
true,
new ConfigDescription
(
"Automatically put loose loot in containers"
)
);
new QuickTransferPatch().Enable(); new QuickTransferPatch().Enable();
} }
} }

View File

@ -26,12 +26,27 @@ namespace CactusPie.ContainerQuickLoot
GClass2585.EMoveItemOrder order, GClass2585.EMoveItemOrder order,
bool simulate) bool simulate)
{ {
// We only execute this for ctrl+click move // If is ctrl+click loot
if (order != GClass2585.EMoveItemOrder.MoveToAnotherSide) if (order == GClass2585.EMoveItemOrder.MoveToAnotherSide)
{
if (!ContainerQuickLootPlugin.EnableForCtrlClick.Value)
{
return true;
}
}
// If is loose loot pick up
else if (order == GClass2585.EMoveItemOrder.PickUp && controller.OwnerType == EOwnerType.Profile)
{
if (!ContainerQuickLootPlugin.EnableForLooseLoot.Value)
{
return true;
}
}
else
{ {
return true; return true;
} }
GameWorld gameWorld = Singleton<GameWorld>.Instance; GameWorld gameWorld = Singleton<GameWorld>.Instance;
// If gameWorld is null that means the game is currently not in progress, for instance you're in your hideout // If gameWorld is null that means the game is currently not in progress, for instance you're in your hideout