So I have a factory that builds a unit over time. The unit costs mass. Mass is stored as a floating point variable, and is constantly generated over time. Example, I have a resource node that gives 5 mass a second. That means each step you take 5 mass * deltaT and adds that to total mass. When mass it displayed it is rounded to the nearest integer, and gain/loss indicators are displayed to the tenth.
This works fine and well for factories draining mass and resource nodes gaining mass over time. However, I am unsure how to handle it when mass gets to 0. Do I skip the step? These seems like the best choice because that creates and automatic queue for requesting available resources. However I currently don't account for all the gain at once. I look at the gain/drains unordered, which could lead to a broken queue. Example I have two factories that both need .3 resources, and one node that creates .5 resources each step. Then factory 2 builds twice as fast as factory 3, soley because factory 2 always gets priority on the mass. It might be that because I will have many factories and nodes thare all adding at different rages that stuff may average out, but I doubt it.
Could I also force all factories to stop building for a step? That sounds complicated, and very poorly written. I am considering to changing my system to ticks, but something still has to have priority for requesting mass, and I am not sure the best way to do it.