How to simulate Electricity in Tile-based game

Hello dear JGO-community :slight_smile:

I’ve been lurking around threads for quite time, but finally i need some personal advice, and i hope i chose the right place to post and/or do not violate any rules I may have overlooked.

I’ ll try to keep it short and simple, so for my question:

First: I want to implement an ‘electricity layer’ in a tile based 2D game.(As model think of Terraria). In fact, the electric layer has a limited number of tile types , basically sorts of connections for instance: ‘vertical’ | ‘horizontal’ | ‘+’ which is just a way of mapping the current from one tile to another. Kind of like its done in dwarf fortress.

Second: Then i have an object layer (i.e Entities with different Components) which both ‘affect’ the electric layer AND ‘are affected’ by the electric layer.
Eventually thers will be 1) Power sources (Batteries etc.) 2)Controllers (Buttons, Latches, etc.) 3)electric consumers(lights, etc).

I have tried some different things, which i dont think is worth explaining here.
So the issue i have is: However i do it, i need a way to update from:
1) the power sources -> towards -> 2) the switches etc -> towards -> 3) the elec. consumers

The stage where i am at now is that I thought of a ‘Node based system’, where an entity would be composed of in/ outputs and the create a node object for EVERY connection made. The way i visualize it, is the way ‘Blender 3D’ does it when connecting nodes in the nodes editor. I guess you know what i mean if you know blender.
I actually made some images explaining the case, but since i dont have a place to upload the images without making one more account on some site, i won’t for now.

At last: I thought of having an ‘impulse base system’ , where i iterate all the power sources and send impulses from there to everything connected (over Nodes), but still, i cant think of a simple, linearly/update friendly way of doing it.

I think writing more would make my question only more complicated, so i’ll leave it at that for now :smiley:

I hope/guess there is somebody who has some more experience in this sort of stuff ^^
Thank you very much in advance.

Greetings and all the best, JJ

(And off course i use LWJGL btw :P)