Apply autostack FiR rules to Top Up action
This commit is contained in:
@@ -8,7 +8,15 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
public class StackFirItemsPatch : ModulePatch
|
public static class StackFirItemsPatches
|
||||||
|
{
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
new ContainerStackPatch().Enable();
|
||||||
|
new TopUpStackPatch().Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ContainerStackPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static Type MergeableItemType;
|
private static Type MergeableItemType;
|
||||||
|
|
||||||
@@ -59,4 +67,34 @@ namespace UIFixes
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class TopUpStackPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(Item), nameof(Item.IsSameItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
public static bool Prefix(Item __instance, Item other, ref bool __result)
|
||||||
|
{
|
||||||
|
bool ignoreSpawnedInSession;
|
||||||
|
if (__instance.Template is MoneyClass)
|
||||||
|
{
|
||||||
|
ignoreSpawnedInSession = Settings.MergeFIRMoney.Value;
|
||||||
|
}
|
||||||
|
else if (__instance.Template is AmmoTemplate)
|
||||||
|
{
|
||||||
|
ignoreSpawnedInSession = Settings.MergeFIRAmmo.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ignoreSpawnedInSession = Settings.MergeFIROther.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
__result = __instance.TemplateId == other.TemplateId && __instance.Id != other.Id && (ignoreSpawnedInSession || __instance.SpawnedInSession == other.SpawnedInSession);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace UIFixes
|
|||||||
InspectWindowStatsPatches.Enable();
|
InspectWindowStatsPatches.Enable();
|
||||||
new RemoveDoorActionsPatch().Enable();
|
new RemoveDoorActionsPatch().Enable();
|
||||||
ScrollPatches.Enable();
|
ScrollPatches.Enable();
|
||||||
new StackFirItemsPatch().Enable();
|
StackFirItemsPatches.Enable();
|
||||||
SwapPatches.Enable();
|
SwapPatches.Enable();
|
||||||
SyncScrollPositionPatches.Enable();
|
SyncScrollPositionPatches.Enable();
|
||||||
new TransferConfirmPatch().Enable();
|
new TransferConfirmPatch().Enable();
|
||||||
|
|||||||
Reference in New Issue
Block a user