Just as a note for that bullet point on the description at the moment: You don't need to write this yourself, it's already in the game. Add a 'drain' property to the energy_source in your entity prototype with a power value, just like the input/output_flow_limit properties. Can't get more performance-friendly than native game systems.