private void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); // Remove from inventory bool success = InventoryController.Remove(session, itemUid, out Item item); if (!success) { return; } // Unequip existing item in slot int index = session.Player.Badges.FindIndex(i => i.GemSlot == item.GemSlot); if (index >= 0) { // Add to inventory InventoryController.Add(session, session.Player.Badges[index], false); // Unequip session.Player.Badges.RemoveAt(index); session.FieldManager.BroadcastPacket(GemPacket.UnequipItem(session, (byte)item.GemSlot)); } // Equip session.Player.Badges.Add(item); session.FieldManager.BroadcastPacket(GemPacket.EquipItem(session, item)); }
private static void HandleTransparency(GameSession session, PacketReader packet) { byte index = packet.ReadByte(); byte[] transparencyBools = packet.ReadBytes(10); Item item = session.Player.Inventory.Badges[index]; item.TransparencyBadgeBools = transparencyBools; session.FieldManager.BroadcastPacket(GemPacket.EquipItem(session, item, index)); }
private static void HandleEquipItem(GameSession session, PacketReader packet) { long itemUid = packet.ReadLong(); // Remove from inventory bool success = session.Player.Inventory.RemoveItem(session, itemUid, out Item item); if (!success) { return; } // Unequip existing item in slot Item[] badges = session.Player.Inventory.Badges; int index = Array.FindIndex(badges, x => x != null && x.GemSlot == item.GemSlot); if (index >= 0) { // Add to inventory badges[index].IsEquipped = false; session.Player.Inventory.AddItem(session, badges[index], false); // Unequip badges[index] = default; session.FieldManager.BroadcastPacket(GemPacket.UnequipItem(session, item.GemSlot)); } // Equip item.IsEquipped = true; int emptyIndex = Array.FindIndex(badges, x => x == default); if (emptyIndex == -1) { return; } badges[emptyIndex] = item; session.FieldManager.BroadcastPacket(GemPacket.EquipItem(session, item, emptyIndex)); }