Example #1
0
        public static string CountRation()
        {
            float             num             = 0.0f;
            float             qualityCalories = 0.0f;
            List <Pickupable> pickupables     = WorldInventory.Instance.GetPickupables(GameTags.Edible);

            if (pickupables != null)
            {
                foreach (Pickupable pickupable in pickupables)
                {
                    if (!pickupable.KPrefabID.HasTag(GameTags.StoredPrivate))
                    {
                        Edible component = pickupable.GetComponent <Edible>();
                        if (component.GetQuality() >= quality)
                        {
                            qualityCalories += component.Calories;
                        }
                        num += component.Calories;
                    }
                }
            }

            return(string.Format(
                       "{0}\n<color=\"{1}\"><b>{2}</b></color> ({3})",
                       GameUtil.GetFormattedCalories((float)num, GameUtil.TimeSlice.None, true),
                       QualityState.StateManager.State.QualityColor,
                       GameUtil.GetFormattedCalories((float)qualityCalories, GameUtil.TimeSlice.None, true),
                       quality
                       ));
        }
        public HandleVector <int> .Handle AddPickupable(Pickupable pickupable)
        {
            byte   foodQuality = 5;
            Edible component   = pickupable.GetComponent <Edible>();

            if ((Object)component != (Object)null)
            {
                foodQuality = (byte)component.GetQuality();
            }
            byte          masterPriority = 0;
            Prioritizable prioritizable  = null;

            if ((Object)pickupable.storage != (Object)null)
            {
                prioritizable = pickupable.storage.prioritizable;
                if ((Object)prioritizable != (Object)null)
                {
                    PrioritySetting masterPriority2 = prioritizable.GetMasterPriority();
                    masterPriority = (byte)masterPriority2.priority_value;
                }
            }
            Rottable.Instance sMI = pickupable.GetSMI <Rottable.Instance>();
            byte freshness        = 0;

            if (!sMI.IsNullOrStopped())
            {
                freshness = QuantizeRotValue(sMI.RotValue);
            }
            KPrefabID component2 = pickupable.GetComponent <KPrefabID>();
            TagBits   rhs        = new TagBits(ref disallowedTagMask);

            component2.AndTagBits(ref rhs);
            HandleVector <int> .Handle handle = fetchables.Allocate(new Fetchable
            {
                pickupable     = pickupable,
                foodQuality    = foodQuality,
                freshness      = freshness,
                masterPriority = masterPriority,
                tagBitsHash    = rhs.GetHashCode()
            });
            if (!sMI.IsNullOrStopped())
            {
                rotUpdaters[handle] = sMI;
            }
            return(handle);
        }