Merge pull request #1 from reysonk/aki-380-release-29197
Update for AKI 3.8.0 release-29197
This commit is contained in:
commit
43c7e9682d
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
src/CactusPie.ContainerQuickLoot/References
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net472</TargetFramework>
|
<TargetFramework>net472</TargetFramework>
|
||||||
<Version>1.2.0</Version>
|
<Version>1.4.2</Version>
|
||||||
<Authors>CactusPie</Authors>
|
<Authors>CactusPie</Authors>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ using JetBrains.Annotations;
|
|||||||
|
|
||||||
namespace CactusPie.ContainerQuickLoot
|
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
|
public class ContainerQuickLootPlugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
internal static ConfigEntry<bool> EnableForCtrlClick { get; set; }
|
internal static ConfigEntry<bool> EnableForCtrlClick { get; set; }
|
||||||
|
@ -16,24 +16,24 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
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;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
public static bool PatchPrefix(
|
public static bool PatchPrefix(
|
||||||
ref GStruct375<GInterface275> __result,
|
ref GStruct414<GInterface324> __result,
|
||||||
object __instance,
|
object __instance,
|
||||||
Item item,
|
Item item,
|
||||||
TraderControllerClass controller,
|
TraderControllerClass controller,
|
||||||
IEnumerable<LootItemClass> targets,
|
IEnumerable<LootItemClass> targets,
|
||||||
GClass2585.EMoveItemOrder order,
|
InteractionsHandlerClass.EMoveItemOrder order,
|
||||||
bool simulate)
|
bool simulate)
|
||||||
{
|
{
|
||||||
Inventory inventory;
|
Inventory inventory;
|
||||||
|
|
||||||
// If is ctrl+click loot
|
// If is ctrl+click loot
|
||||||
if (order == GClass2585.EMoveItemOrder.MoveToAnotherSide)
|
if (order == InteractionsHandlerClass.EMoveItemOrder.MoveToAnotherSide)
|
||||||
{
|
{
|
||||||
if (!ContainerQuickLootPlugin.EnableForCtrlClick.Value)
|
if (!ContainerQuickLootPlugin.EnableForCtrlClick.Value)
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If is loose loot pick up
|
// 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)
|
if (!ContainerQuickLootPlugin.EnableForLooseLoot.Value)
|
||||||
{
|
{
|
||||||
@ -69,11 +69,11 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IContainer> targetContainers = FindTargetContainers(item, inventory);
|
IEnumerable<EFT.InventoryLogic.IContainer> 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);
|
return !TryMergeItemIntoAnExistingStack(item, inventory, controller, simulate, ref __result);
|
||||||
}
|
}
|
||||||
@ -98,19 +98,19 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct375<GClass2599> mergeResult = GClass2585.Merge(item, containedItem.Key, controller, simulate);
|
GStruct414<GClass2788> mergeResult = InteractionsHandlerClass.Merge(item, containedItem.Key, controller, simulate);
|
||||||
__result = new GStruct375<GInterface275>(mergeResult.Value);
|
__result = new GStruct414<GInterface324>(mergeResult.Value);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GClass2580 location = container.FindLocationForItem(item);
|
GClass2769 location = container.FindLocationForItem(item);
|
||||||
if (location == null)
|
if (location == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct375<GClass2597> moveResult = GClass2585.Move(item, location, controller, simulate);
|
GStruct414<GClass2786> moveResult = InteractionsHandlerClass.Move(item, location, controller, simulate);
|
||||||
if (moveResult.Failed)
|
if (moveResult.Failed)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -118,7 +118,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
|
|
||||||
if (!moveResult.Value.ItemsDestroyRequired)
|
if (!moveResult.Value.ItemsDestroyRequired)
|
||||||
{
|
{
|
||||||
__result = moveResult.Cast<GClass2597, GInterface275>();
|
__result = moveResult.Cast<GClass2786, GInterface324>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -132,27 +132,30 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
GameWorld gameWorld = Singleton<GameWorld>.Instance;
|
GameWorld gameWorld = Singleton<GameWorld>.Instance;
|
||||||
|
|
||||||
// If gameWorld is null that means the game is currently not in progress, for instance you're in your hideout
|
// 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;
|
inventory = 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)
|
// ?.GetValue(player);
|
||||||
?.GetValue(player);
|
inventory = (Inventory)typeof(Player).GetProperty("Inventory")?.GetValue(player);
|
||||||
|
|
||||||
if (inventory == null)
|
if (inventory == null)
|
||||||
{
|
{
|
||||||
|
// Logger.LogError("在这里表示inventory==null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<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<(ContainerCollection containerCollection, int priority)>();
|
||||||
|
|
||||||
@ -196,7 +199,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
matchingContainerCollections.Add((containerCollection, priority));
|
matchingContainerCollections.Add((containerCollection, priority));
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IContainer> result = matchingContainerCollections
|
IEnumerable<EFT.InventoryLogic.IContainer> result = matchingContainerCollections
|
||||||
.OrderBy(x => x.priority)
|
.OrderBy(x => x.priority)
|
||||||
.SelectMany(x => x.containerCollection.Containers);
|
.SelectMany(x => x.containerCollection.Containers);
|
||||||
|
|
||||||
@ -210,7 +213,7 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
Inventory inventory,
|
Inventory inventory,
|
||||||
TraderControllerClass controller,
|
TraderControllerClass controller,
|
||||||
bool simulate,
|
bool simulate,
|
||||||
ref GStruct375<GInterface275> result)
|
ref GStruct414<GInterface324> result)
|
||||||
{
|
{
|
||||||
if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value)
|
if (!ContainerQuickLootPlugin.AutoMergeStacksForNonLootContainers.Value)
|
||||||
{
|
{
|
||||||
@ -234,14 +237,14 @@ namespace CactusPie.ContainerQuickLoot
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GStruct375<GClass2599> mergeResult = GClass2585.Merge(item, targetItem, controller, simulate);
|
GStruct414<GClass2788> mergeResult = InteractionsHandlerClass.Merge(item, targetItem, controller, simulate);
|
||||||
|
|
||||||
if (!mergeResult.Succeeded)
|
if (!mergeResult.Succeeded)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = new GStruct375<GInterface275>(mergeResult.Value);
|
result = new GStruct414<GInterface324>(mergeResult.Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user