Does anyone here have experience making games with streaming economies? I am working on a game and am looking for a better way to handle the economy. I feel like there must be a better algorithm than what I am using.
ResourceBinobjects contain resources
Settlementobjects have three queues of
Buildingobjects in arrays (Low, Medium, and High priorities)
Buildingobjects have a
nextTick()method that accepts a
ResourceBinand modifies it
Right now on every tick the
Settlement class will loop through all of the
Building arrays starting with High and working towards Low. On each
Building object it calls the
nextTick() method and passes its
ResourceBin. After making sure that the transforms won't cause any Resource to become negative, the
nextTick() method modifies the
ResourceBin and exits. If any of its transformations would cause a Resource to become negative it just exits.
The issue with this is that the entire system depends heavily on the order in which the buildings are processed. I also can't have it proportionally affect the resource transformations if you are low on resources (like what is done in Total Annihilation).
Does anyone know how other games implement streaming economies? Is there a better way to do this?
Also let me know in the comments if a code example would be useful. I can pastebin one if need be.