diff --git a/.gitignore b/.gitignore index 6e9599b..07413e5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +src/CactusPie.ContainerQuickLoot/References # User-specific files *.rsuser *.suo diff --git a/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj index a779754..dd95c4c 100644 --- a/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj +++ b/src/CactusPie.ContainerQuickLoot/CactusPie.ContainerQuickLoot.csproj @@ -2,7 +2,7 @@ net472 - 1.2.0 + 1.4.2 CactusPie diff --git a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs index 663896e..4ea8213 100644 --- a/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs +++ b/src/CactusPie.ContainerQuickLoot/ContainerQuickLootPlugin.cs @@ -4,7 +4,7 @@ using JetBrains.Annotations; namespace CactusPie.ContainerQuickLoot { - [BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.4.1")] + [BepInPlugin("com.cactuspie.containerquikloot", "CactusPie.ContainerQuickLoot", "1.4.2")] public class ContainerQuickLootPlugin : BaseUnityPlugin { internal static ConfigEntry EnableForCtrlClick { get; set; } diff --git a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs index 17bd460..0b47a04 100644 --- a/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs +++ b/src/CactusPie.ContainerQuickLoot/QuickTransferPatch.cs @@ -16,24 +16,24 @@ namespace CactusPie.ContainerQuickLoot protected override MethodBase GetTargetMethod() { - MethodInfo method = typeof(GClass2585).GetMethod("QuickFindAppropriatePlace", BindingFlags.Public | BindingFlags.Static); + MethodInfo method = typeof(InteractionsHandlerClass).GetMethod("QuickFindAppropriatePlace", BindingFlags.Public | BindingFlags.Static); return method; } [PatchPrefix] public static bool PatchPrefix( - ref GStruct375 __result, + ref GStruct414 __result, object __instance, Item item, TraderControllerClass controller, IEnumerable targets, - GClass2585.EMoveItemOrder order, + InteractionsHandlerClass.EMoveItemOrder order, bool simulate) { Inventory inventory; // If is ctrl+click loot - if (order == GClass2585.EMoveItemOrder.MoveToAnotherSide) + if (order == InteractionsHandlerClass.EMoveItemOrder.MoveToAnotherSide) { if (!ContainerQuickLootPlugin.EnableForCtrlClick.Value) { @@ -41,7 +41,7 @@ namespace CactusPie.ContainerQuickLoot } } // If is loose loot pick up - else if (order == GClass2585.EMoveItemOrder.PickUp && controller.OwnerType == EOwnerType.Profile) + else if (order == InteractionsHandlerClass.EMoveItemOrder.PickUp && controller.OwnerType == EOwnerType.Profile) { if (!ContainerQuickLootPlugin.EnableForLooseLoot.Value) { @@ -69,11 +69,11 @@ namespace CactusPie.ContainerQuickLoot return true; } - IEnumerable targetContainers = FindTargetContainers(item, inventory); + IEnumerable targetContainers = FindTargetContainers(item, inventory); - foreach (IContainer collectionContainer in targetContainers) + foreach (EFT.InventoryLogic.IContainer collectionContainer in targetContainers) { - if (!(collectionContainer is GClass2318 container)) + if (!(collectionContainer is StashGridClass container)) { return !TryMergeItemIntoAnExistingStack(item, inventory, controller, simulate, ref __result); } @@ -98,19 +98,19 @@ namespace CactusPie.ContainerQuickLoot continue; } - GStruct375 mergeResult = GClass2585.Merge(item, containedItem.Key, controller, simulate); - __result = new GStruct375(mergeResult.Value); + GStruct414 mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate); + __result = new GStruct414(mergeResult.Value); return false; } } - GClass2580 location = container.FindLocationForItem(item); + GClass2769 location = container.FindLocationForItem(item); if (location == null) { continue; } - GStruct375 moveResult = GClass2585.Move(item, location, controller, simulate); + GStruct414 moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate); if (moveResult.Failed) { return true; @@ -118,7 +118,7 @@ namespace CactusPie.ContainerQuickLoot if (!moveResult.Value.ItemsDestroyRequired) { - __result = moveResult.Cast(); + __result = moveResult.Cast(); } return false; @@ -132,27 +132,30 @@ namespace CactusPie.ContainerQuickLoot GameWorld gameWorld = Singleton.Instance; // If gameWorld is null that means the game is currently not in progress, for instance you're in your hideout - if (gameWorld == null) + //start 3.7 hideout gameWorld nolonger be null.So need to use getlocationId + if (gameWorld == null || gameWorld.LocationId == null) { inventory = null; + // Logger.LogError("在这里代表gameworld==null"); return false; } - + Player player = GetLocalPlayerFromWorld(gameWorld); - - inventory = (Inventory)typeof(Player) - .GetProperty("Inventory", BindingFlags.NonPublic | BindingFlags.Instance) - ?.GetValue(player); + // inventory = (Inventory)typeof(Player) + // .GetProperty("Inventory", BindingFlags.NonPublic | BindingFlags.Instance) + // ?.GetValue(player); + inventory = (Inventory)typeof(Player).GetProperty("Inventory")?.GetValue(player); if (inventory == null) { + // Logger.LogError("在这里表示inventory==null"); return false; } return true; } - private static IEnumerable FindTargetContainers(Item item, Inventory inventory) + private static IEnumerable FindTargetContainers(Item item, Inventory inventory) { var matchingContainerCollections = new List<(ContainerCollection containerCollection, int priority)>(); @@ -196,7 +199,7 @@ namespace CactusPie.ContainerQuickLoot matchingContainerCollections.Add((containerCollection, priority)); } - IEnumerable result = matchingContainerCollections + IEnumerable result = matchingContainerCollections .OrderBy(x => x.priority) .SelectMany(x => x.containerCollection.Containers); @@ -210,7 +213,7 @@ namespace CactusPie.ContainerQuickLoot Inventory inventory, TraderControllerClass controller, bool simulate, - ref GStruct375 result) + ref GStruct414 result) { if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value) { @@ -234,14 +237,14 @@ namespace CactusPie.ContainerQuickLoot continue; } - GStruct375 mergeResult = GClass2585.Merge(item, targetItem, controller, simulate); + GStruct414 mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate); if (!mergeResult.Succeeded) { return false; } - result = new GStruct375(mergeResult.Value); + result = new GStruct414(mergeResult.Value); return true; }