comment out ammo box in-place temporarily
This commit is contained in:
@@ -15,7 +15,7 @@ namespace UIFixes;
|
|||||||
|
|
||||||
public static class UnloadAmmoPatches
|
public static class UnloadAmmoPatches
|
||||||
{
|
{
|
||||||
private static UnloadAmmoBoxState UnloadState = null;
|
//private static UnloadAmmoBoxState UnloadState = null;
|
||||||
|
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
@@ -24,8 +24,8 @@ public static class UnloadAmmoPatches
|
|||||||
new UnloadScavTransferPatch().Enable();
|
new UnloadScavTransferPatch().Enable();
|
||||||
new NoScavStashPatch().Enable();
|
new NoScavStashPatch().Enable();
|
||||||
|
|
||||||
new UnloadAmmoBoxPatch().Enable();
|
//new UnloadAmmoBoxPatch().Enable();
|
||||||
new QuickFindUnloadAmmoBoxPatch().Enable();
|
//new QuickFindUnloadAmmoBoxPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TradingPlayerPatch : ModulePatch
|
public class TradingPlayerPatch : ModulePatch
|
||||||
@@ -106,108 +106,108 @@ public static class UnloadAmmoPatches
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UnloadAmmoBoxPatch : ModulePatch
|
// public class UnloadAmmoBoxPatch : ModulePatch
|
||||||
{
|
// {
|
||||||
protected override MethodBase GetTargetMethod()
|
// protected override MethodBase GetTargetMethod()
|
||||||
{
|
// {
|
||||||
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.UnloadAmmo));
|
// return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.UnloadAmmo));
|
||||||
}
|
// }
|
||||||
|
|
||||||
[PatchPrefix]
|
// [PatchPrefix]
|
||||||
public static void Prefix(Item item)
|
// public static void Prefix(Item item)
|
||||||
{
|
// {
|
||||||
if (Settings.UnloadAmmoBoxInPlace.Value && item is AmmoBox)
|
// if (Settings.UnloadAmmoBoxInPlace.Value && item is AmmoBox)
|
||||||
{
|
// {
|
||||||
UnloadState = new();
|
// UnloadState = new();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
[PatchPostfix]
|
// [PatchPostfix]
|
||||||
public static async void Postfix(Task __result)
|
// public static async void Postfix(Task __result)
|
||||||
{
|
// {
|
||||||
if (!Settings.UnloadAmmoBoxInPlace.Value)
|
// if (!Settings.UnloadAmmoBoxInPlace.Value)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await __result;
|
// await __result;
|
||||||
UnloadState = null;
|
// UnloadState = null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public class QuickFindUnloadAmmoBoxPatch : ModulePatch
|
// public class QuickFindUnloadAmmoBoxPatch : ModulePatch
|
||||||
{
|
// {
|
||||||
protected override MethodBase GetTargetMethod()
|
// protected override MethodBase GetTargetMethod()
|
||||||
{
|
// {
|
||||||
return AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.QuickFindAppropriatePlace));
|
// return AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.QuickFindAppropriatePlace));
|
||||||
}
|
// }
|
||||||
|
|
||||||
[PatchPrefix]
|
// [PatchPrefix]
|
||||||
public static void Prefix(Item item, TraderControllerClass controller, ref IEnumerable<LootItemClass> targets, ref InteractionsHandlerClass.EMoveItemOrder order)
|
// public static void Prefix(Item item, TraderControllerClass controller, ref IEnumerable<LootItemClass> targets, ref InteractionsHandlerClass.EMoveItemOrder order)
|
||||||
{
|
// {
|
||||||
if (UnloadState == null)
|
// if (UnloadState == null)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (item.Parent.Container.ParentItem is not AmmoBox box)
|
// if (item.Parent.Container.ParentItem is not AmmoBox box)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Ammo boxes with multiple stacks will loop through this code, so we only want to move the box once
|
// // Ammo boxes with multiple stacks will loop through this code, so we only want to move the box once
|
||||||
if (UnloadState.initialized)
|
// if (UnloadState.initialized)
|
||||||
{
|
// {
|
||||||
order = UnloadState.order;
|
// order = UnloadState.order;
|
||||||
targets = UnloadState.targets;
|
// targets = UnloadState.targets;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
// Have to do this for them, since the calls to get parent will be wrong once we move the box
|
// // Have to do this for them, since the calls to get parent will be wrong once we move the box
|
||||||
if (!order.HasFlag(InteractionsHandlerClass.EMoveItemOrder.IgnoreItemParent))
|
// if (!order.HasFlag(InteractionsHandlerClass.EMoveItemOrder.IgnoreItemParent))
|
||||||
{
|
// {
|
||||||
LootItemClass parent = (item.GetNotMergedParent() as LootItemClass) ?? (item.GetRootMergedItem() as EquipmentClass);
|
// LootItemClass parent = (item.GetNotMergedParent() as LootItemClass) ?? (item.GetRootMergedItem() as EquipmentClass);
|
||||||
if (parent != null)
|
// if (parent != null)
|
||||||
{
|
// {
|
||||||
UnloadState.targets = targets = order.HasFlag(InteractionsHandlerClass.EMoveItemOrder.PrioritizeParent) ?
|
// UnloadState.targets = targets = order.HasFlag(InteractionsHandlerClass.EMoveItemOrder.PrioritizeParent) ?
|
||||||
parent.ToEnumerable().Concat(targets).Distinct() :
|
// parent.ToEnumerable().Concat(targets).Distinct() :
|
||||||
targets.Concat(parent.ToEnumerable()).Distinct();
|
// targets.Concat(parent.ToEnumerable()).Distinct();
|
||||||
}
|
// }
|
||||||
|
|
||||||
UnloadState.order = order |= InteractionsHandlerClass.EMoveItemOrder.IgnoreItemParent;
|
// UnloadState.order = order |= InteractionsHandlerClass.EMoveItemOrder.IgnoreItemParent;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var operation = InteractionsHandlerClass.Move(box, UnloadState.fakeStash.Grid.FindLocationForItem(box), controller, false);
|
// var operation = InteractionsHandlerClass.Move(box, UnloadState.fakeStash.Grid.FindLocationForItem(box), controller, false);
|
||||||
operation.Value.RaiseEvents(controller, CommandStatus.Begin);
|
// operation.Value.RaiseEvents(controller, CommandStatus.Begin);
|
||||||
operation.Value.RaiseEvents(controller, CommandStatus.Succeed);
|
// operation.Value.RaiseEvents(controller, CommandStatus.Succeed);
|
||||||
|
|
||||||
UnloadState.initialized = true;
|
// UnloadState.initialized = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public class UnloadAmmoBoxState
|
// public class UnloadAmmoBoxState
|
||||||
{
|
// {
|
||||||
public StashClass fakeStash;
|
// public StashClass fakeStash;
|
||||||
public TraderControllerClass fakeController;
|
// public TraderControllerClass fakeController;
|
||||||
|
|
||||||
public bool initialized;
|
// public bool initialized;
|
||||||
public InteractionsHandlerClass.EMoveItemOrder order;
|
// public InteractionsHandlerClass.EMoveItemOrder order;
|
||||||
public IEnumerable<LootItemClass> targets;
|
// public IEnumerable<LootItemClass> targets;
|
||||||
|
|
||||||
public UnloadAmmoBoxState()
|
// public UnloadAmmoBoxState()
|
||||||
{
|
// {
|
||||||
if (Plugin.InRaid())
|
// if (Plugin.InRaid())
|
||||||
{
|
// {
|
||||||
fakeStash = Singleton<GameWorld>.Instance.R().Stash;
|
// fakeStash = Singleton<GameWorld>.Instance.R().Stash;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
fakeStash = (StashClass)Singleton<ItemFactory>.Instance.CreateItem("FakeStash", "566abbc34bdc2d92178b4576", null);
|
// fakeStash = (StashClass)Singleton<ItemFactory>.Instance.CreateItem("FakeStash", "566abbc34bdc2d92178b4576", null);
|
||||||
|
|
||||||
var profile = PatchConstants.BackEndSession.Profile;
|
// var profile = PatchConstants.BackEndSession.Profile;
|
||||||
fakeController = new(fakeStash, profile.ProfileId, profile.Nickname);
|
// fakeController = new(fakeStash, profile.ProfileId, profile.Nickname);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
18
Settings.cs
18
Settings.cs
@@ -96,7 +96,7 @@ internal class Settings
|
|||||||
public static ConfigEntry<bool> SwapItems { get; set; }
|
public static ConfigEntry<bool> SwapItems { get; set; }
|
||||||
public static ConfigEntry<bool> SwapMags { get; set; }
|
public static ConfigEntry<bool> SwapMags { get; set; }
|
||||||
public static ConfigEntry<bool> AlwaysSwapMags { get; set; }
|
public static ConfigEntry<bool> AlwaysSwapMags { get; set; }
|
||||||
public static ConfigEntry<bool> UnloadAmmoBoxInPlace { get; set; } // Advanced
|
//public static ConfigEntry<bool> UnloadAmmoBoxInPlace { get; set; } // Advanced
|
||||||
public static ConfigEntry<bool> SwapImpossibleContainers { get; set; }
|
public static ConfigEntry<bool> SwapImpossibleContainers { get; set; }
|
||||||
public static ConfigEntry<bool> ReorderGrids { get; set; }
|
public static ConfigEntry<bool> ReorderGrids { get; set; }
|
||||||
public static ConfigEntry<bool> SynchronizeStashScrolling { get; set; }
|
public static ConfigEntry<bool> SynchronizeStashScrolling { get; set; }
|
||||||
@@ -473,14 +473,14 @@ internal class Settings
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { })));
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
configEntries.Add(UnloadAmmoBoxInPlace = config.Bind(
|
// configEntries.Add(UnloadAmmoBoxInPlace = config.Bind(
|
||||||
InventorySection,
|
// InventorySection,
|
||||||
"Unload Ammo Boxes In-Place",
|
// "Unload Ammo Boxes In-Place",
|
||||||
true,
|
// true,
|
||||||
new ConfigDescription(
|
// new ConfigDescription(
|
||||||
"Whether to unload ammo boxes in-place, otherwise there needs to be free space somewhere",
|
// "Whether to unload ammo boxes in-place, otherwise there needs to be free space somewhere",
|
||||||
null,
|
// null,
|
||||||
new ConfigurationManagerAttributes { IsAdvanced = true })));
|
// new ConfigurationManagerAttributes { IsAdvanced = true })));
|
||||||
|
|
||||||
configEntries.Add(SwapImpossibleContainers = config.Bind(
|
configEntries.Add(SwapImpossibleContainers = config.Bind(
|
||||||
InventorySection,
|
InventorySection,
|
||||||
|
|||||||
Reference in New Issue
Block a user