Esempio n. 1
0
        public virtual IEnumerable <ComponentButton> GetContextMenu(ItemSlot slot, InvContextMenu menu)
        {
            var game = GameImpl.Instance;

            yield return(new ComponentButton(menu,
                                             new RectangleF(Vector2.Zero, new Size2(20, 6)), Locale.GetInterface("Drop"),
                                             (button, pressType) => {
                if (button == MouseButton.Left && pressType == PressType.Pressed)
                {
                    var pos = ItemObject.GetFeasibleDropPos(game.CurrentMap, game.Player.Position);
                    if (pos == Vector2.Zero)
                    {
                        return false;
                    }
                    var item = new ItemObject(this, game.CurrentMap, pos);
                    game.CurrentMap.AddObject(item);
                    slot.Items[slot.Index] = null;
                    menu.Close();
                    return true;
                }
                return false;
            }));
        }