Add switching the places between two slots, allowing moving items

This commit is contained in:
Sofia 2017-05-16 22:31:40 +03:00
parent 6c1669d1cc
commit ca80647acf
2 changed files with 20 additions and 1 deletions

View File

@ -205,7 +205,7 @@ namespace Cyber.Controls {
for (int x = 0; x < ItemGridDimensions.x; x++) {
// Find the item and mesh
int i = x + y * (int) ItemGridDimensions.x;
Item Item = Inventory.Drive.GetItemAt(x + y * (int) ItemGridDimensions.y);
Item Item = Inventory.Drive.GetItemAt(x + y * (int) ItemGridDimensions.x);
Mesh Mesh = null;
if (Item != null) {
Mesh = MeshDB.GetMesh(Item.ModelID);

View File

@ -98,6 +98,25 @@ namespace Cyber.Items {
return false;
}
/// <summary>
///
/// </summary>
/// <param name="idx1"></param>
/// <param name="idx2"></param>
public void SwitchSlots(int idx1, int idx2) {
Slot Slot1 = GetSlotAt(idx1);
Slot Slot2 = GetSlotAt(idx2);
SetSlotAt(idx1, Slot2);
SetSlotAt(idx2, Slot1);
}
private void SetSlotAt(int idx, Slot slot) {
if (idx >= Slots.Length) {
IncreaseCapacity(idx - Slots.Length + 1);
}
Slots[idx] = slot;
}
/// <summary>
/// Gets the item at the given index, or null if there is nothing.
/// </summary>