Update ui, split item, handle split, change button text
This commit is contained in:
@@ -369,6 +369,81 @@ namespace BrewMonster
|
||||
int cmd = Convert.ToInt32(Msg.dwParam2);
|
||||
switch (cmd)
|
||||
{
|
||||
case CommandID.EXG_IVTR_ITEM:
|
||||
{
|
||||
// S2C::cmd_exg_ivtr_item { byte index1; byte index2; }
|
||||
if (data == null || data.Length < 2)
|
||||
{
|
||||
Debug.LogWarning("[Inventory] EXG_IVTR_ITEM: Invalid data length");
|
||||
break;
|
||||
}
|
||||
|
||||
byte index1 = data[0];
|
||||
byte index2 = data[1];
|
||||
|
||||
if (m_pPack != null)
|
||||
{
|
||||
m_pPack.ExchangeItem(index1, index2);
|
||||
|
||||
var pItem1 = m_pPack.GetItem(index1, false);
|
||||
if (pItem1 != null)
|
||||
{
|
||||
pItem1.Package = InventoryConst.IVTRTYPE_PACK;
|
||||
pItem1.Slot = index1;
|
||||
}
|
||||
|
||||
var pItem2 = m_pPack.GetItem(index2, false);
|
||||
if (pItem2 != null)
|
||||
{
|
||||
pItem2.Package = InventoryConst.IVTRTYPE_PACK;
|
||||
pItem2.Slot = index2;
|
||||
}
|
||||
}
|
||||
|
||||
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
|
||||
ui?.RefreshAll();
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandID.MOVE_IVTR_ITEM:
|
||||
{
|
||||
// S2C::cmd_move_ivtr_item { byte src; byte dest; uint count; }
|
||||
if (data == null || data.Length < 6)
|
||||
{
|
||||
Debug.LogWarning("[Inventory] MOVE_IVTR_ITEM: Invalid data length");
|
||||
break;
|
||||
}
|
||||
|
||||
byte src = data[0];
|
||||
byte dest = data[1];
|
||||
uint count = BitConverter.ToUInt32(data, 2);
|
||||
|
||||
if (m_pPack != null)
|
||||
{
|
||||
// Client-side mirror of server operation.
|
||||
// When dest is empty and count < stack, this becomes "separate/split stack".
|
||||
m_pPack.MoveItem(src, dest, (int)count);
|
||||
|
||||
var pItemSrc = m_pPack.GetItem(src, false);
|
||||
if (pItemSrc != null)
|
||||
{
|
||||
pItemSrc.Package = InventoryConst.IVTRTYPE_PACK;
|
||||
pItemSrc.Slot = src;
|
||||
}
|
||||
|
||||
var pItemDest = m_pPack.GetItem(dest, false);
|
||||
if (pItemDest != null)
|
||||
{
|
||||
pItemDest.Package = InventoryConst.IVTRTYPE_PACK;
|
||||
pItemDest.Slot = dest;
|
||||
}
|
||||
}
|
||||
|
||||
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
|
||||
ui?.RefreshAll();
|
||||
break;
|
||||
}
|
||||
|
||||
case CommandID.PLAYER_DROP_ITEM:
|
||||
{
|
||||
// Parse the drop item data from the server response
|
||||
|
||||
Reference in New Issue
Block a user