Files
zzz_REBIRTH__Utils/Harmony/Harmony_XUiM_LootContainer.cs
2025-06-04 16:44:53 +09:30

88 lines
4.3 KiB
C#

namespace Harmony.XUiM_LootContainerPatches
{
/*[HarmonyPatch(typeof(XUiM_LootContainer))]
[HarmonyPatch("StashItems")]
public class StashItemsPatch
{
public static bool Prefix(XUiM_LootContainer __instance, ref (bool _allMoved, bool _anyMoved) __result,
XUiController _srcWindow,
XUiC_ItemStackGrid _srcGrid,
IInventory _dstInventory,
int _ignoreSlots,
bool[] _ignoredSlots,
XUiM_LootContainer.EItemMoveKind _moveKind,
bool _startBottomRight
)
{
if (_srcGrid == null || _dstInventory == null)
__result = (false, false);
float unscaledTime = Time.unscaledTime;
if (_moveKind == XUiM_LootContainer.EItemMoveKind.FillOnlyFirstCreateSecond && (double)unscaledTime - (double)XUiM_LootContainer.lastStashTime < 2.0)
_moveKind = XUiM_LootContainer.EItemMoveKind.FillAndCreate;
bool flag1 = true;
bool flag2 = false;
PreferenceTracker preferences = (PreferenceTracker)null;
if (_srcWindow is XUiC_LootWindow xuiCLootWindow)
preferences = xuiCLootWindow.GetPreferenceTrackerFromTileEntity();
if (preferences != null && preferences.AnyPreferences && _dstInventory is XUiM_PlayerInventory mPlayerInventory)
flag2 = mPlayerInventory.AddItemsUsingPreferenceTracker(_srcGrid, preferences);
XUiController[] stackControllers = (XUiController[])_srcGrid.GetItemStackControllers();
Log.Out("XUiM_LootContainerPatches-StashItems _ignoreSlots: " + _ignoreSlots);
for (int _slot = _startBottomRight ? stackControllers.Length - 1 : 0; (_startBottomRight ? (_slot >= 0 ? 1 : 0) : (_slot < stackControllers.Length ? 1 : 0)) != 0; _slot = _startBottomRight ? _slot - 1 : _slot + 1)
{
if (_ignoredSlots[_slot])
{
Log.Out("XUiM_LootContainerPatches-StashItems SLOT [" + (_slot + 1) + "] IS IGNORED");
}
if (!StackSortUtil.IsIgnoredSlot(_ignoreSlots, _ignoredSlots, _slot))
{
XUiC_ItemStack xuiCItemStack = (XUiC_ItemStack)stackControllers[_slot];
if (!xuiCItemStack.StackLock)
{
ItemStack itemStack = xuiCItemStack.ItemStack;
if (!xuiCItemStack.ItemStack.IsEmpty())
{
int count1 = itemStack.count;
_dstInventory.TryStackItem(0, itemStack);
if (itemStack.count > 0)
{
switch (_moveKind)
{
case XUiM_LootContainer.EItemMoveKind.All:
if (_dstInventory.AddItem(itemStack))
{
itemStack = ItemStack.Empty.Clone();
break;
}
break;
case XUiM_LootContainer.EItemMoveKind.FillAndCreate:
if (!_dstInventory.HasItem(itemStack.itemValue))
break;
goto case XUiM_LootContainer.EItemMoveKind.All;
}
}
if (itemStack.count == 0)
itemStack = ItemStack.Empty.Clone();
else
flag1 = false;
int count2 = itemStack.count;
if (count1 != count2)
{
xuiCItemStack.ForceSetItemStack(itemStack);
flag2 = true;
}
}
}
}
}
XUiM_LootContainer.lastStashTime = unscaledTime;
__result = (flag1, flag2);
return false;
}
}*/
}