Hello, first time posting here.
I am prototyping an inventory system using unreal engine 4.
The goal:
Player can pick up items in the game world. Some items have individual states or conditions that needs to be remembered.
The problem:
It probably is not feasible to have an actor spawned for every single item, but we still need to run logic on a per instance basis.
I have a PickupItems base class that holds data that covers most items. It also handles basic functions for stuff like OnPickup, etc.
Most items are defined only by static data that I can reference from a data table. I.E. if I grab a piece of wood board, it has some weight values and dimensions values that never change. So the only thing I need to pass around and store is an ID.
But if there is a subclass of PickupItems called FoodPickupItems, and this class has some logic for incrementing a “spoilage” integer - the problem is that this logic lives in the class. Then, in order to consistently update that spoilage integer, I'd have to keep the entire actor alive all the time?
Is this a case for using a manager class? It might track all instances of the FoodPickupItems class in the world and handle incrementing their spoilage counters. And it might also search the players inventory, look for inventory item slots containing a spoilage flag, and incrementing a variable held there as well?
Is there any programming pattern which solves problems like this I could study?
Thanks for any advice.