コード例 #1
0
        public override void UseItem(IBasicHealthKit hk)
        {
            int slot                = hk.slot;
            var inventory           = hk.inventory;
            var humanBodyTakeDamage = inventory.GetLocal <HumanBodyTakeDamage>();

            if (!humanBodyTakeDamage)
            {
                return;
            }

            var metabolism = inventory.GetLocal <Metabolism>();

            if (!metabolism)
            {
                return;
            }

            if (stopsBleeding)
            {
                humanBodyTakeDamage.Bandage(1000f);
            }

            var oldHealth  = humanBodyTakeDamage.health;
            var compHealth = oldHealth + amountToHeal;

            if (compHealth > 200)
            {
                compHealth = 200;
            }
            humanBodyTakeDamage.health = compHealth;
            inventory.inventoryHolder.playerClient.controllable.GetLocal <ClientVitalsSync>().SendClientItsHealth();

            if (oldHealth != 200)
            {
                int  consumedCount = 1;
                bool flag          = hk.Consume(ref consumedCount);
                if (consumedCount == 0)
                {
                    inventory.MarkSlotDirty(slot);
                    hk.FireClientSideItemEvent(InventoryItem.ItemEvent.Used);
                }
                if (flag)
                {
                    inventory.RemoveItem(slot);
                }
            }
        }
コード例 #2
0
 public virtual void UseItem(IBasicHealthKit hk)
 {
 }