I have a 2d tile-based game. I plan to add a power system in the near future, something along the lines of Oxygen Not Included’s power system with wires.
The wires will be tiles in a seperate tilemap in the game, but in the code they will be something else.
What I plan to do is to make the “wires” some nodes in an array (which corresponds to the map) and have the connections be stored in another array, basically a graph. There will be power sources and all power consumers that are connected to a wire system with a power source will be powered. Issue is, I wouldn’t want the power consumers to constantly check whether they are connected to a power producer or vice versa.
I think I’d do this by making the consumers memorize whether they are connected to a power source, but I don’t know how to make this check fast enough considering there can be multiple power consumers/sources…
The map (at the current state) consists of 300 tiles horizontally and 190 tiles vertically. I’ll attach an image of the game too:
(entire map):
If more details are required, I’ll gladly provide some!
Any help is appreciated!