I’m working on adding harvestable resource nodes to my levels, in principal it’s very simple: each resource has a loot table and an Int8 Amount which represents the number of times that resource may be harvested. If Amount is greater than 0 I roll for a resource on the loot table and decrement Amount, otherwise nothing happens. The issue comes when the player leaves and comes back- since each node is a static part of a level, when that level is unloaded, then reloaded, Amount rests to its default value.
The best solution I’ve come up with to solve this is to create a global tmap<Vector3 coordinates, int8 Amount> that persistently tracks each and every resource node in the game, and instead of checking its internal values a harvestable node simply handes its coordinates to the map, which increments/decrements Amount accordingly. It works, but it’s a bit of an antipattern, since it requires me to keep track of hundreds or potentially thousands of nodes in active memory when only a handful are active at any given time.
Is there a better way I can keep this data local, and trust a node to retain its data when unloaded, or is keeping a comprehensive list in persistent memory really the best solution?