Update for SPT 3.9.0

This commit is contained in:
Tyfon
2024-07-06 21:50:51 -07:00
parent 531d8fce06
commit 238e28dbc3
55 changed files with 427 additions and 407 deletions

View File

@@ -1,7 +1,7 @@
using Aki.Reflection.Patching;
using EFT;
using EFT;
using EFT.InventoryLogic;
using HarmonyLib;
using SPT.Reflection.Patching;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -13,14 +13,14 @@ namespace UIFixes
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(GClass1841), nameof(GClass1841.method_8));
return AccessTools.Method(typeof(GClass1855), nameof(GClass1855.method_9));
}
// The patched method can't handle new items that aren't in stash root.
// Find items that are in subcontainers and handle them first - the patched method will ignore items that have a CurrentAddress
// This is a subset of the original method - doesn't handle slots, equipment containers, etc.
[PatchPrefix]
public static void Prefix(ref GClass1189[] newItems, Profile ___profile_0, ItemFactory ___gclass1486_0, GClass2764 ___gclass2764_0)
public static void Prefix(ref GClass1198[] newItems, Profile ___profile_0, ItemFactory ___itemFactory, GClass2780 ___gclass2780_0)
{
Inventory inventory = ___profile_0.Inventory;
StashClass stash = inventory.Stash;
@@ -40,10 +40,10 @@ namespace UIFixes
List<Item> stashItems = stash.GetNotMergedItems().ToList();
ItemFactory.GStruct134 tree = ___gclass1486_0.FlatItemsToTree(unhandledItems.ToArray(), true, null);
ItemFactory.GStruct135 tree = ___itemFactory.FlatItemsToTree(unhandledItems.ToArray(), true, null);
foreach (Item item in tree.Items.Values.Where(i => i.CurrentAddress == null))
{
GClass1189 newItem = unhandledItems.First(i => i._id == item.Id);
GClass1198 newItem = unhandledItems.First(i => i._id == item.Id);
if (newItem.parentId != null || newItem.slotId != null)
{
// Assuming here that unhandled items are trying to go into containers in the stash - find that container
@@ -52,14 +52,14 @@ namespace UIFixes
{
if (containerCollection.GetContainer(newItem.slotId) is StashGridClass grid)
{
LocationInGrid location = GClass1485.CreateItemLocation<LocationInGrid>(newItem.location);
ItemAddress itemAddress = new GClass2769(grid, location);
LocationInGrid location = GClass1496.CreateItemLocation<LocationInGrid>(newItem.location);
ItemAddress itemAddress = new ItemAddressClass(grid, location);
GStruct414<GClass2782> operation = InteractionsHandlerClass.Add(item, itemAddress, ___gclass2764_0, false);
GStruct414<GClass2798> operation = InteractionsHandlerClass.Add(item, itemAddress, ___gclass2780_0, false);
if (operation.Succeeded)
{
operation.Value.RaiseEvents(___gclass2764_0, CommandStatus.Begin);
operation.Value.RaiseEvents(___gclass2764_0, CommandStatus.Succeed);
operation.Value.RaiseEvents(___gclass2780_0, CommandStatus.Begin);
operation.Value.RaiseEvents(___gclass2780_0, CommandStatus.Succeed);
}
}
}