Skip to content

Commit

Permalink
Fixed swapping equipped items
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed Sep 12, 2021
1 parent a32f824 commit c028c19
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions ExtendedPlayerInventory/BepInExPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace ExtendedPlayerInventory
{
[BepInPlugin("aedenthorn.ExtendedPlayerInventory", "Extended Player Inventory", "0.2.3")]
[BepInPlugin("aedenthorn.ExtendedPlayerInventory", "Extended Player Inventory", "0.2.4")]
public class BepInExPlugin : BaseUnityPlugin
{
private static BepInExPlugin context;
Expand Down Expand Up @@ -256,6 +256,30 @@ static void Postfix(InventoryGui __instance, InventoryGrid ___m_playerGrid, Anim
var back = t.Field("m_shoulderItem").GetValue<ItemDrop.ItemData>();
var utility = t.Field("m_utilityItem").GetValue<ItemDrop.ItemData>();


int width = inv.GetWidth();
int offset = width * (inv.GetHeight() - 1);

if (helmet != null)
t.Field("m_helmetItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (chest != null)
t.Field("m_chestItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (legs != null)
t.Field("m_legItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (back != null)
t.Field("m_shoulderItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (utility != null)
t.Field("m_utilityItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);


for (int i = 0; i < items.Count; i++)
{
//Dbgl($"{items[i].m_gridPos} {inv.GetHeight() - 1},0 {items[i] != helmet}");
Expand Down Expand Up @@ -291,28 +315,6 @@ static void Postfix(InventoryGui __instance, InventoryGrid ___m_playerGrid, Anim
if (!___m_animator.GetBool("visible"))
return;

int width = inv.GetWidth();
int offset = width * (inv.GetHeight() - 1);

if (helmet != null)
t.Field("m_helmetItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (chest != null)
t.Field("m_chestItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (legs != null)
t.Field("m_legItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (back != null)
t.Field("m_shoulderItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);
offset++;

if (utility != null)
t.Field("m_utilityItem").GetValue<ItemDrop.ItemData>().m_gridPos = new Vector2i(offset % width, offset / width);


__instance.m_player.Find("Bkg").GetComponent<RectTransform>().anchorMin = new Vector2(0, (extraRows.Value + (addEquipmentRow.Value && !displayEquipmentRowSeparate.Value ? 1 : 0)) * -0.25f);

Expand Down

0 comments on commit c028c19

Please sign in to comment.