Exemplo n.º 1
0
        private static bool ApplyHungerAmount(Entity user, InventoryItem itemUsed, ItemSpec itemSpec)
        {
            var hungerReduceAmount = itemSpec.GetHungerReduceAmount();

            if (hungerReduceAmount == 0)
            {
                return(false);
            }

            var hunger = user.GetHunger();

            if (hunger == 0)
            {
                return(false);
            }

            hunger -= hungerReduceAmount;

            hunger = Math.Min(Math.Max(hunger, (short)0), (short)Consts.MaxHunger);

            if (hunger < 0)
            {
                hunger = 0;
            }

            user.SetHunger(hunger);

            return(true);
        }