Exemplo n.º 1
0
        private void PerformUsage(Entity user, InventoryItem itemUsed)
        {
            var consumed = false;

            var itemSpec = itemUsed.GetItemSpec();

            consumed |= ApplyHealAmount(user, itemUsed, itemSpec);
            consumed |= ApplyHungerAmount(user, itemUsed, itemSpec);

            if (consumed)
            {
                Logger.Write(string.Format("Item `{0}` used, and consumed.", itemUsed.GetItemSpec().GetName()));
                itemUsed.SetCount((short)(itemUsed.GetCount() - 1));
            }
            else
            {
                Logger.Write(string.Format("Item `{0}` used and was NOT consumed.", itemUsed.GetItemSpec().GetName()));
            }

            var msg = new ServerStopItemUsage
            {
                EntityId = user.EntityId,
                Success  = true
            };

            _engine.SendMessage(msg);
        }
Exemplo n.º 2
0
        public void CancelUsage(Entity user)
        {
            _itemsInUse.RemoveAll(item => item.Entity.EntityId == user.EntityId);
            var msg = new ServerStopItemUsage
            {
                EntityId = user.EntityId,
                Success  = false
            };

            _engine.SendMessage(msg);
        }