From 69e6c61bd123cda6463b95ce07446232e83b876c Mon Sep 17 00:00:00 2001 From: excitedneon Date: Wed, 17 May 2017 01:28:12 +0300 Subject: [PATCH] Sync moving items in the inventory --- Assets/Scripts/Controls/InventoryInterface.cs | 2 +- Assets/Scripts/Items/InventoryAction.cs | 7 ++++++- Assets/Scripts/Items/InventoryActionHandler.cs | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Controls/InventoryInterface.cs b/Assets/Scripts/Controls/InventoryInterface.cs index 2b0cd36..155dbe5 100644 --- a/Assets/Scripts/Controls/InventoryInterface.cs +++ b/Assets/Scripts/Controls/InventoryInterface.cs @@ -187,7 +187,7 @@ namespace Cyber.Controls { Lerper.LerpTransformPosition(ItemGridCellMeshes[CurrentIndex].transform, new Vector3(), 10f); // Switch items - Inventory.Drive.SwitchSlots(GrabbedItemIndex, CurrentIndex); + Client.Send(PktType.InventoryAction, Inventory.ActionHandler.BuildSlotSwitch(GrabbedItemIndex, CurrentIndex)); // Reset grabbing GrabbedItem = null; diff --git a/Assets/Scripts/Items/InventoryAction.cs b/Assets/Scripts/Items/InventoryAction.cs index 97374af..90b06e7 100644 --- a/Assets/Scripts/Items/InventoryAction.cs +++ b/Assets/Scripts/Items/InventoryAction.cs @@ -19,7 +19,12 @@ namespace Cyber.Items { /// /// Use the item in the given slot. /// - Use + Use, + + /// + /// Switch items between two slots. + /// + Switch } } diff --git a/Assets/Scripts/Items/InventoryActionHandler.cs b/Assets/Scripts/Items/InventoryActionHandler.cs index 0648c73..e259f23 100644 --- a/Assets/Scripts/Items/InventoryActionHandler.cs +++ b/Assets/Scripts/Items/InventoryActionHandler.cs @@ -50,6 +50,10 @@ namespace Cyber.Items { return new InventoryActionPkt(InventoryAction.Equip, itemIdx); } + public InventoryActionPkt BuildSlotSwitch(int switchFrom, int switchTo) { + return new InventoryActionPkt(InventoryAction.Switch, new int[]{ switchFrom, switchTo }); + } + /// /// Handles an to handle. Ran on server and client. /// @@ -76,6 +80,9 @@ namespace Cyber.Items { return true; } return false; + case InventoryAction.Switch: + Inventory.Drive.SwitchSlots(intList[0], intList[1]); + return true; } return false; }