Merge pull request 'Updated for 3.10.x' (#1) from ShinCFN/SPT-ContainerQuickLoot:master into master

Reviewed-on: #1
This commit is contained in:
bepis69 2024-12-22 20:59:48 +00:00
commit f378bbd5f6

View File

@ -23,11 +23,11 @@ namespace CactusPie.ContainerQuickLoot
[PatchPrefix] [PatchPrefix]
public static bool PatchPrefix( public static bool PatchPrefix(
ref GStruct414<GInterface339> __result, ref GStruct446<GInterface385> __result,
object __instance, object __instance,
Item item, Item item,
TraderControllerClass controller, TraderControllerClass controller,
IEnumerable<LootItemClass> targets, IEnumerable<CompoundItem> targets,
InteractionsHandlerClass.EMoveItemOrder order, InteractionsHandlerClass.EMoveItemOrder order,
bool simulate) bool simulate)
{ {
@ -80,7 +80,7 @@ namespace CactusPie.ContainerQuickLoot
} }
// ReSharper disable once PossibleMultipleEnumeration // ReSharper disable once PossibleMultipleEnumeration
if (!(targets.SingleOrDefaultWithoutException() is EquipmentClass)) if (!(targets.SingleOrDefaultWithoutException() is InventoryEquipment))
{ {
continue; continue;
} }
@ -99,19 +99,19 @@ namespace CactusPie.ContainerQuickLoot
continue; continue;
} }
GStruct414<GClass2804> mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate); GStruct446<GClass3138> mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate);
__result = new GStruct414<GInterface339>(mergeResult.Value); __result = new GStruct446<GInterface385>(mergeResult.Value);
return false; return false;
} }
} }
ItemAddressClass location = container.FindLocationForItem(item); ItemAddress location = container.FindLocationForItem(item);
if (location == null) if (location == null)
{ {
continue; continue;
} }
GStruct414<GClass2802> moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate); GStruct446<GClass3132> moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate);
if (moveResult.Failed) if (moveResult.Failed)
{ {
return true; return true;
@ -119,7 +119,7 @@ namespace CactusPie.ContainerQuickLoot
if (!moveResult.Value.ItemsDestroyRequired) if (!moveResult.Value.ItemsDestroyRequired)
{ {
__result = moveResult.Cast<GClass2802, GInterface339>(); __result = moveResult.Cast<GClass3132, GInterface385>();
} }
return false; return false;
@ -140,7 +140,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,7 +158,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<(ContainerCollection containerCollection, int priority)>(); var matchingContainerCollections = new List<(GClass2981 containerCollection, int priority)>();
string tag = ContainerQuickLootPlugin.CustomizeTagForLootContainers.Value.ToString(); string tag = ContainerQuickLootPlugin.CustomizeTagForLootContainers.Value.ToString();
Regex lootTagRegex = new Regex Regex lootTagRegex = new Regex
@ -191,7 +191,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 ContainerCollection; var containerCollection = inventoryItem as GClass2981;
if (containerCollection == null || !containerCollection.Containers.Any(container => container.CanAccept(item))) if (containerCollection == null || !containerCollection.Containers.Any(container => container.CanAccept(item)))
{ {
@ -221,7 +221,7 @@ namespace CactusPie.ContainerQuickLoot
Inventory inventory, Inventory inventory,
TraderControllerClass controller, TraderControllerClass controller,
bool simulate, bool simulate,
ref GStruct414<GInterface339> result) ref GStruct446<GInterface385> result)
{ {
if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value) if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value)
{ {
@ -236,7 +236,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 +245,14 @@ namespace CactusPie.ContainerQuickLoot
continue; continue;
} }
GStruct414<GClass2804> mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate); GStruct446<GClass3138> mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate);
if (!mergeResult.Succeeded) if (!mergeResult.Succeeded)
{ {
return false; return false;
} }
result = new GStruct414<GInterface339>(mergeResult.Value); result = new GStruct446<GInterface385>(mergeResult.Value);
return true; return true;
} }