Exemplo n.º 1
0
    public void TryHealInjury(Injury injury)
    {
        if (!this.CanHealInjury(injury))
        {
            return;
        }
        injury.GetSlot().SetInjury(null);
        this.m_Injuries.Remove(injury);
        InjuryTreatment treatment = this.GetTreatment(injury.GetInjuryType());

        DebugUtils.Assert(treatment != null, true);
        Dictionary <int, int> allItems = treatment.GetAllItems();

        using (Dictionary <int, int> .KeyCollection.Enumerator enumerator = allItems.Keys.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ItemID itemID = (ItemID)enumerator.Current;
                InventoryBackpack.Get().RemoveItem(itemID, allItems[(int)itemID]);
            }
        }
        EventsManager.OnEvent(Enums.Event.HealWound, 1);
    }
Exemplo n.º 2
0
    public bool CanHealInjury(Injury injury)
    {
        if (injury == null)
        {
            return(false);
        }
        InjuryTreatment treatment = this.GetTreatment(injury.GetInjuryType());

        DebugUtils.Assert(treatment != null, true);
        Dictionary <int, int> allItems = treatment.GetAllItems();

        using (Dictionary <int, int> .KeyCollection.Enumerator enumerator = allItems.Keys.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                ItemID itemID = (ItemID)enumerator.Current;
                if (InventoryBackpack.Get().GetItemsCount(itemID) < allItems[(int)itemID])
                {
                    return(false);
                }
            }
        }
        return(true);
    }