So I need it so that energy runs through the pipes and if the energy comes in contact with something it can interact with, it runs a function. But to somehow work with intersections.
The items will be placeable on a grid so that players can make any sort of order of pipes.
Players set the direction of the pipes (for a 4-way they would set 3 inputs and 1 output) or you provide prefabs with preset directions.
User-friendly option:
Use maze-solving algorithms to find the shortest path to whatever target you need. This is also the most scalable option, as you can have multiple types of items/energy routed to different targets, whereas with the previous option, all inputs would be routed to the same destination.
For optimization purposes, you would calculate a path to the target:
When the generator is initially placed
Each time the route to the closest seller is changed
Each time a new seller is added to the pipes (it may be closer than the previously closest)
instead of every time you spawn a new unit of energy.