public void RemoveItem(TechType techType, EatableType eatableType)
        {
            var pickupable = techType.ToPickupable();

            if (Inventory.main.HasRoomFor(pickupable))
            {
                EatableEntities match = FindMatch(techType, eatableType);

                if (match != null)
                {
                    var go      = GameObject.Instantiate(CraftData.GetPrefabForTechType(techType));
                    var eatable = go.GetComponent <Eatable>();
                    var pickup  = go.GetComponent <Pickupable>();

                    match.UnpauseDecay();
                    eatable.timeDecayStart = match.TimeDecayStart;

                    if (Inventory.main.Pickup(pickup))
                    {
                        QuickLogger.Debug($"Removed Match Before || Fridge Count {FridgeItems.Count}");
                        FridgeItems.Remove(match);
                        QuickLogger.Debug($"Removed Match || Fridge Count {FridgeItems.Count}");
                    }
                    else
                    {
                        QuickLogger.Message(LanguageHelpers.GetLanguage("InventoryFull"), true);
                    }
                    GameObject.Destroy(pickupable);
                    OnContainerUpdate?.Invoke(NumberOfItems, _itemLimit);
                }
            }
        }
        private EatableEntities CreateFoodInventoryItem(Pickupable item)
        {
            var eatable = new EatableEntities();

            eatable.Initialize(item, false);
            return(eatable);
        }
Esempio n. 3
0
        private static EatableEntities GetEatableData(InventoryItem item)
        {
            var eatableEntity = new EatableEntities();

            eatableEntity.Initialize(item.item, false);
            return(eatableEntity);
        }
        public void AddItem(InventoryItem item, bool fromSave = false, float timeDecayPause = 0)
        {
            if (IsFull)
            {
                return;
            }

            var eatableEntity = new EatableEntities();

            eatableEntity.Initialize(item.item);
            eatableEntity.PauseDecay();
            if (fromSave)
            {
                eatableEntity.TimeDecayPause = timeDecayPause;
            }
            FridgeItems.Add(eatableEntity);
            OnContainerUpdate?.Invoke(NumberOfItems, _itemLimit);
            Destroy(item.item);
        }
Esempio n. 5
0
        public Pickupable RemoveItemFromContainer(TechType techType, int amount)
        {
            EatableEntities match = FindMatch(techType, EatableType.Any);

            if (match == null)
            {
                return(null);
            }

            var go      = GameObject.Instantiate(CraftData.GetPrefabForTechType(techType));
            var eatable = go.GetComponent <Eatable>();
            var pickup  = go.GetComponent <Pickupable>();

            match.UnpauseDecay();
            eatable.timeDecayStart = match.TimeDecayStart;
            FridgeItems.Remove(match);
            OnContainerUpdate?.Invoke(NumberOfItems, _itemLimit);

            return(pickup);
        }