Compare commits
No commits in common. "master" and "1.5.0" have entirely different histories.
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<Version>1.6.0</Version>
|
<Version>1.5.0</Version>
|
||||||
<Authors> CactusPiereysonk,ArchmageTony,bepis69,ShinCFN</Authors>
|
<Authors>bepis69</Authors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -4,7 +4,7 @@ using JetBrains.Annotations;
|
|||||||
|
|
||||||
namespace CactusPie.ContainerQuickLoot
|
namespace CactusPie.ContainerQuickLoot
|
||||||
{
|
{
|
||||||
[BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.6.0")]
|
[BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.4.2")]
|
||||||
public class ContainerQuickLootPlugin : BaseUnityPlugin
|
public class ContainerQuickLootPlugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
internal static ConfigEntry<bool> EnableForCtrlClick { get; set; }
|
internal static ConfigEntry<bool> EnableForCtrlClick { get; set; }
|
||||||
@ -15,8 +15,6 @@ 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()
|
||||||
{
|
{
|
||||||
@ -67,17 +65,6 @@ 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,13 +7,12 @@ 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()
|
||||||
{
|
{
|
||||||
@ -23,11 +22,11 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static bool PatchPrefix(
|
public static bool PatchPrefix(
|
||||||
ref GStruct446<GInterface385> __result,
|
ref GStruct414<GInterface339> __result,
|
||||||
object __instance,
|
object __instance,
|
||||||
Item item,
|
Item item,
|
||||||
TraderControllerClass controller,
|
TraderControllerClass controller,
|
||||||
IEnumerable<CompoundItem> targets,
|
IEnumerable<LootItemClass> targets,
|
||||||
InteractionsHandlerClass.EMoveItemOrder order,
|
InteractionsHandlerClass.EMoveItemOrder order,
|
||||||
bool simulate)
|
bool simulate)
|
||||||
{
|
{
|
||||||
@ -80,7 +79,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once PossibleMultipleEnumeration
|
// ReSharper disable once PossibleMultipleEnumeration
|
||||||
if (!(targets.SingleOrDefaultWithoutException() is InventoryEquipment))
|
if (!(targets.SingleOrDefaultWithoutException() is EquipmentClass))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -99,19 +98,19 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct446<GClass3138> mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate);
|
GStruct414<GClass2804> mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate);
|
||||||
__result = new GStruct446<GInterface385>(mergeResult.Value);
|
__result = new GStruct414<GInterface339>(mergeResult.Value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemAddress location = container.FindLocationForItem(item);
|
ItemAddressClass location = container.FindLocationForItem(item);
|
||||||
if (location == null)
|
if (location == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct446<GClass3132> moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate);
|
GStruct414<GClass2802> moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate);
|
||||||
if (moveResult.Failed)
|
if (moveResult.Failed)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -119,7 +118,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
if (!moveResult.Value.ItemsDestroyRequired)
|
if (!moveResult.Value.ItemsDestroyRequired)
|
||||||
{
|
{
|
||||||
__result = moveResult.Cast<GClass3132, GInterface385>();
|
__result = moveResult.Cast<GClass2802, GInterface339>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -140,7 +139,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
// Logger.LogError("在这里代表gameworld==null");
|
// Logger.LogError("在这里代表gameworld==null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = GetLocalPlayerFromWorld(gameWorld);
|
Player player = GetLocalPlayerFromWorld(gameWorld);
|
||||||
// inventory = (Inventory)typeof(Player)
|
// inventory = (Inventory)typeof(Player)
|
||||||
// .GetProperty("Inventory", BindingFlags.NonPublic | BindingFlags.Instance)
|
// .GetProperty("Inventory", BindingFlags.NonPublic | BindingFlags.Instance)
|
||||||
@ -158,15 +157,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
private static IEnumerable<EFT.InventoryLogic.IContainer> FindTargetContainers(Item item, Inventory inventory)
|
private static IEnumerable<EFT.InventoryLogic.IContainer> FindTargetContainers(Item item, Inventory inventory)
|
||||||
{
|
{
|
||||||
var matchingContainerCollections = new List<(GClass2981 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())
|
||||||
{
|
{
|
||||||
@ -182,8 +173,8 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We check if there is a tag
|
// We check if there is a @loot tag
|
||||||
Match regexMatch = lootTagRegex.Match(tagComponent.Name);
|
Match regexMatch = LootTagRegex.Match(tagComponent.Name);
|
||||||
|
|
||||||
if (!regexMatch.Success)
|
if (!regexMatch.Success)
|
||||||
{
|
{
|
||||||
@ -191,7 +182,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We check if any of the containers in the collection can hold our item
|
// We check if any of the containers in the collection can hold our item
|
||||||
var containerCollection = inventoryItem as GClass2981;
|
var containerCollection = inventoryItem as ContainerCollection;
|
||||||
|
|
||||||
if (containerCollection == null || !containerCollection.Containers.Any(container => container.CanAccept(item)))
|
if (containerCollection == null || !containerCollection.Containers.Any(container => container.CanAccept(item)))
|
||||||
{
|
{
|
||||||
@ -200,8 +191,9 @@ 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(tag.Length);
|
string priorityString = regexMatch.Value.Substring(lootTagLength);
|
||||||
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));
|
||||||
@ -221,7 +213,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
Inventory inventory,
|
Inventory inventory,
|
||||||
TraderControllerClass controller,
|
TraderControllerClass controller,
|
||||||
bool simulate,
|
bool simulate,
|
||||||
ref GStruct446<GInterface385> result)
|
ref GStruct414<GInterface339> result)
|
||||||
{
|
{
|
||||||
if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value)
|
if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value)
|
||||||
{
|
{
|
||||||
@ -236,7 +228,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
foreach (Item targetItem in inventory.Equipment.GetNotMergedItems().Reverse())
|
foreach (Item targetItem in inventory.Equipment.GetNotMergedItems().Reverse())
|
||||||
{
|
{
|
||||||
if (targetItem.Template._id != item.Template._id)
|
if (targetItem.Template._id != item.Template._id)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,14 +237,14 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct446<GClass3138> mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate);
|
GStruct414<GClass2804> mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate);
|
||||||
|
|
||||||
if (!mergeResult.Succeeded)
|
if (!mergeResult.Succeeded)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new GStruct446<GInterface385>(mergeResult.Value);
|
result = new GStruct414<GInterface339>(mergeResult.Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user