Exemplo n.º 1
0
    private void GetAmounts(bool doExtras, out float available, out float total, out float reserved)
    {
        available = 0f;
        total     = 0f;
        reserved  = 0f;
        HashSet <Tag> resources = null;

        if (WorldInventory.Instance.TryGetDiscoveredResourcesFromTag(ResourceCategoryTag, out resources))
        {
            ListPool <Tag, ResourceCategoryHeader> .PooledList pooledList = ListPool <Tag, ResourceCategoryHeader> .Allocate();

            foreach (Tag item in resources)
            {
                EdiblesManager.FoodInfo foodInfo = null;
                if (Measure == GameUtil.MeasureUnit.kcal)
                {
                    foodInfo = Game.Instance.ediblesManager.GetFoodInfo(item.Name);
                    if (foodInfo == null)
                    {
                        pooledList.Add(item);
                        continue;
                    }
                }
                anyDiscovered = true;
                ResourceEntry value = null;
                if (!ResourcesDiscovered.TryGetValue(item, out value))
                {
                    value = NewResourceEntry(item, Measure);
                    ResourcesDiscovered.Add(item, value);
                }
                value.GetAmounts(foodInfo, doExtras, out float available2, out float total2, out float reserved2);
                available += available2;
                total     += total2;
                reserved  += reserved2;
            }
            foreach (Tag item2 in pooledList)
            {
                resources.Remove(item2);
            }
            pooledList.Recycle();
        }
    }