{ /// <summary> /// Handles an item pickup request from a client /// </summary> static public void Handle_CS_PlayerPickup(CS_PlayerPickup pkt, Player player) { //Allow the player's arena to handle it if (player._arena == null) { Log.write(TLog.Error, "Player {0} sent update packet with no arena.", player); return; } if (player.IsSpectator) { Log.write(TLog.Warning, "Player {0} attempted to pickup items from spec.", player); return; } if (player.IsDead) { Log.write(TLog.Warning, "Player {0} attempted to pickup items while dead.", player); return; } player._arena.handleEvent(delegate(Arena arena) { player._arena.handlePlayerPickup(player, pkt); } ); }
/// <summary> /// Triggered when a player requests to pick up an item /// </summary> public void handlePlayerPickup(Player from, CS_PlayerPickup update) { //Find the itemdrop in question ItemDrop drop; if (!_items.TryGetValue(update.itemID, out drop)) { //Doesn't exist return; } //Sanity checks if (update.quantity > drop.quantity) { return; } else if (update.quantity == drop.quantity) { //Delete the drop _items.Remove(drop.id); } else { drop.quantity = (short)(drop.quantity - update.quantity); } //Add the pickup to inventory! from.inventoryModify(drop.item, update.quantity); //Remove the item from player's clients Helpers.Object_ItemDropUpdate(_players, update.itemID, 0); }
/// <summary> /// Triggered when a player requests to pick up an item /// </summary> public virtual void handlePlayerPickup(Player from, CS_PlayerPickup update) { }