diff --git a/.gitignore b/.gitignore
index 8a30d25..6e9599b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
-## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
@@ -23,7 +23,6 @@ mono_crash.*
[Rr]eleases/
x64/
x86/
-[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
@@ -62,9 +61,6 @@ project.lock.json
project.fragment.lock.json
artifacts/
-# ASP.NET Scaffolding
-ScaffoldingReadMe.txt
-
# StyleCop
StyleCopReport.xml
@@ -90,7 +86,6 @@ StyleCopReport.xml
*.tmp_proj
*_wpftmp.csproj
*.log
-*.tlog
*.vspscc
*.vssscc
.builds
@@ -143,9 +138,7 @@ _TeamCity*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
-coverage*.json
-coverage*.xml
-coverage*.info
+coverage*[.json, .xml, .info]
# Visual Studio code coverage results
*.coverage
@@ -294,17 +287,6 @@ node_modules/
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
-# Visual Studio 6 auto-generated project file (contains which files were open etc.)
-*.vbp
-
-# Visual Studio 6 workspace and project file (working project files containing files to include in project)
-*.dsw
-*.dsp
-
-# Visual Studio 6 technical files
-*.ncb
-*.aps
-
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@@ -361,9 +343,6 @@ ASALocalRun/
# Local History for Visual Studio
.localhistory/
-# Visual Studio History (VSHistory) files
-.vshistory/
-
# BeatPulse healthcheck temp database
healthchecksdb
@@ -372,27 +351,5 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
-
-# Fody - auto-generated XML schema
-FodyWeavers.xsd
-
-# VS Code files for those working on multiple tools
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
-*.code-workspace
-
-# Local History for Visual Studio Code
-.history/
-
-# Windows Installer files from build outputs
-*.cab
-*.msi
-*.msix
-*.msm
-*.msp
-
-# JetBrains Rider
-*.sln.iml
+.idea/
+*.DotSettings
diff --git a/src/CactusPie.ContainerQuickLoot.sln b/src/CactusPie.ContainerQuickLoot.sln
new file mode 100644
index 0000000..56ec7bd
--- /dev/null
+++ b/src/CactusPie.ContainerQuickLoot.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32616.157
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CactusPie.ContainerQuickLoot", "CactusPie.ContainerQuickLoot\CactusPie.ContainerQuickLoot.csproj", "{9C38A2B1-5F09-49FE-AC57-9FBEF7717582}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9C38A2B1-5F09-49FE-AC57-9FBEF7717582}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {26F91A8D-3767-457A-821C-F66AFD620885}
+ EndGlobalSection
+EndGlobal
diff --git a/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj
new file mode 100644
index 0000000..d125f32
--- /dev/null
+++ b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj
@@ -0,0 +1,50 @@
+
+
+
+ net472
+ 1.1.0
+ CactusPie
+
+
+
+
+ runtime
+
+
+
+
+
+ ..\References\EFT_Managed\Aki.Reflection.dll
+ False
+
+
+ ..\References\EFT_Managed\Assembly-CSharp.dll
+ False
+
+
+ ..\References\EFT_Managed\Comfort.dll
+ False
+
+
+ ..\References\EFT_Managed\Comfort.Unity.dll
+ False
+
+
+ ..\References\EFT_Managed\ItemComponent.Types.dll
+ False
+
+
+ ..\References\EFT_Managed\UnityEngine.dll
+ False
+
+
+ ..\References\EFT_Managed\UnityEngine.CoreModule.dll
+ False
+
+
+ ..\References\EFT_Managed\UnityEngine.InputLegacyModule.dll
+ False
+
+
+
+
diff --git a/src/CactusPie.ContainerQuickLoot/CollectionExtensions.cs b/src/CactusPie.ContainerQuickLoot/CollectionExtensions.cs
new file mode 100644
index 0000000..b6e27e5
--- /dev/null
+++ b/src/CactusPie.ContainerQuickLoot/CollectionExtensions.cs
@@ -0,0 +1,31 @@
+using System.Collections.Generic;
+
+namespace CactusPie.ContainerQuickLoot
+{
+ public static class CollectionExtensions
+ {
+ /// Returns the only element of a sequence, or a default value if the sequence is empty or contains more than one element
+ /// An to return the single element of.
+ /// The type of the elements of .
+ /// The single element of the input sequence, or () if the sequence contains more than one or no elements.
+ ///
+ /// is .
+ public static TSource SingleOrDefaultWithoutException(this IEnumerable source)
+ where TSource : class
+ {
+ TSource result = default;
+
+ foreach (TSource element in source)
+ {
+ if (result != null)
+ {
+ return default;
+ }
+
+ result = element;
+ }
+
+ return result;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs
new file mode 100644
index 0000000..35cba62
--- /dev/null
+++ b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs
@@ -0,0 +1,15 @@
+using BepInEx;
+using JetBrains.Annotations;
+
+namespace CactusPie.ContainerQuickLoot
+{
+ [BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.0.0")]
+ public class ContainerQuickLootPlugin : BaseUnityPlugin
+ {
+ [UsedImplicitly]
+ internal void Start()
+ {
+ new QuickTransferPatch().Enable();
+ }
+ }
+}
diff --git a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs
new file mode 100644
index 0000000..a9257ba
--- /dev/null
+++ b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs
@@ -0,0 +1,107 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Aki.Reflection.Patching;
+using Comfort.Common;
+using EFT;
+using EFT.InventoryLogic;
+
+namespace CactusPie.ContainerQuickLoot
+{
+ public class QuickTransferPatch : ModulePatch
+ {
+ protected override MethodBase GetTargetMethod()
+ {
+ MethodInfo method = typeof(GClass2585).GetMethod("QuickFindAppropriatePlace", BindingFlags.Public | BindingFlags.Static);
+ return method;
+ }
+
+ [PatchPostfix]
+ public static void PatchPostfix(
+ ref GStruct375 __result,
+ object __instance,
+ Item item,
+ TraderControllerClass controller,
+ IEnumerable targets,
+ GClass2585.EMoveItemOrder order,
+ bool simulate)
+ {
+ if (order == GClass2585.EMoveItemOrder.MoveToAnotherSide)
+ {
+ GameWorld gameWorld = Singleton.Instance;
+
+ if (gameWorld == null)
+ {
+ return;
+ }
+
+ Player player = GetLocalPlayerFromWorld(gameWorld);
+ var inventory = (Inventory)typeof(Player).GetProperty("Inventory", BindingFlags.NonPublic | BindingFlags.Instance)?.GetValue(player);
+
+ if (inventory == null)
+ {
+ return;
+ }
+
+ ContainerCollection containerCollection = null;
+
+ Item targetContainer = inventory.Equipment.GetAllItems().FirstOrDefault(x =>
+ x.IsContainer &&
+ x.TryGetItemComponent(out TagComponent tagComponent) &&
+ tagComponent.Name.Contains("@loot") &&
+ (containerCollection = x as ContainerCollection) != null &&
+ containerCollection.Containers.Any(y => y.CanAccept(item)));
+
+ if (targetContainer == null || containerCollection == null)
+ {
+ return;
+ }
+
+ foreach (IContainer collectionContainer in containerCollection.Containers)
+ {
+ var container = collectionContainer as GClass2318;
+
+ if (container == null)
+ {
+ return;
+ }
+
+ // ReSharper disable once PossibleMultipleEnumeration
+ if (!(targets.SingleOrDefaultWithoutException() is EquipmentClass))
+ {
+ continue;
+ }
+
+ GClass2580 location = container.FindLocationForItem(item);
+ if (location == null)
+ {
+ continue;
+ }
+
+ GStruct375 moveResult = GClass2585.Move(item, location, controller, simulate);
+ if (moveResult.Failed)
+ {
+ return;
+ }
+
+ if (!moveResult.Value.ItemsDestroyRequired)
+ {
+ __result = moveResult.Cast();
+ }
+
+ return;
+ }
+ }
+ }
+
+ private static Player GetLocalPlayerFromWorld(GameWorld gameWorld)
+ {
+ if (gameWorld == null || gameWorld.MainPlayer == null)
+ {
+ return null;
+ }
+
+ return gameWorld.MainPlayer;
+ }
+ }
+}
diff --git a/src/NuGet.Config b/src/NuGet.Config
new file mode 100644
index 0000000..da1fd08
--- /dev/null
+++ b/src/NuGet.Config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file