From b176d904675d97c3d05d4b35cd1aae1068aeb7ae Mon Sep 17 00:00:00 2001 From: CactusPie Date: Mon, 20 Nov 2023 11:51:15 +0100 Subject: [PATCH] Add support for loose loot --- .../ContainerQuickLootPlugin.cs | 30 +++++++++++++++++++ .../QuickTransferPatch.cs | 21 +++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs index 35cba62..0a208d3 100644 --- a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs +++ b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs @@ -1,4 +1,6 @@ using BepInEx; +using BepInEx.Configuration; +using BepInEx.Logging; using JetBrains.Annotations; namespace CactusPie.ContainerQuickLoot @@ -6,9 +8,37 @@ namespace CactusPie.ContainerQuickLoot [BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.0.0")] public class ContainerQuickLootPlugin : BaseUnityPlugin { + internal static ConfigEntry EnableForCtrlClick { get; set; } + + internal static ConfigEntry EnableForLooseLoot { get; set; } + [UsedImplicitly] 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(); } } diff --git a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs index b06c450..617ddc9 100644 --- a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs +++ b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs @@ -26,12 +26,27 @@ namespace CactusPie.ContainerQuickLoot GClass2585.EMoveItemOrder order, bool simulate) { - // We only execute this for ctrl+click move - if (order != GClass2585.EMoveItemOrder.MoveToAnotherSide) + // If is ctrl+click loot + 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; } - + GameWorld gameWorld = Singleton.Instance; // If gameWorld is null that means the game is currently not in progress, for instance you're in your hideout