My issue is that I've been trying to implement a power/electrical system for a while now. I'm using Unreal Engine 4 with C++ but that's not really relevant.I'm trying to implement some sort of system of generators, power storage, and power draining objects that all interact through one another through a system of wires or cables, similar to any of the many minecraft mods which add machines.My thoughts were moving towards using a node system, where nodes looking for power can trace through the system and find a generator or storage cell. I couldn't find a single tutorial or example anywhere online. Anyone have any input?Thanks!
component-based power system for a game
c++;trees;system
After experimenting for a while I have a solution. I've split the network of machines into many EnergyNet objects, which represents something like a cluster of wires. Each EnergyNet represents a system of energy suppliers, consumers, and storagers, which are a combination of both.Every update tick, the energy net measures the amount of energy produces and distributes it to the consumers. Any remaining energy is then stored in the storagers or disposed.By using multiple EnergyNets, I can create many complex systems with far distanced between them. If two EnergyNets were to intersect, I could easily merge their components the for a single EnergyNet!edit:I represent the machines by aList<Machine>and my connections by aList<Tuple<Machine, Machine>>If anyone would like, I can submit my source code, but I have to admit it's a bit of a mess. I planned on rewriting everything once I had figured it out...