/// <summary> /// pick up closest item and throw the equipped one on the ground /// </summary> /// <param name="player">player to pick up item</param> /// <returns>true if item picked up</returns> private bool pickupClosestItem(Being player) { DropItem dropItem = Game.instance.getClosestDropItem(player); if (dropItem != null && Vector2.DistanceSquared(dropItem.body.Position, player.body.Position) < Game.DROP_ITEM_MAX_DISTANCE) { Item playerItem = player.getItemManager().getItem(dropItem.getItem().getItemType()); player.getItemManager().putItem(dropItem.getItem()); if (playerItem != null) { dropItem.setItem(playerItem); dropItem.body.LinearVelocity.Y += 25f; dropItem.body.ApplyTorque((float)Game.instance.rand.NextDouble() * .25f - .125f); } else { Game.instance.activeItems.Remove(dropItem.guid); Game.instance.physicsSimulator.BodyList.Remove(dropItem.body); } } else { return(false); } return(true); }