I wrote a somewhat similar mod Solar Halo, that has a heating mechanic. I'd love to port it to use your library, but there are a few things I'd like to be tested/explained/changed before doing so.
coolio.
1) I wrote my code to rely on products finished as a proxy for energy spent. This lets the handler run about every 20 ticks (could probably be even more sparse) and simplifies the math for a bit of production spikiness and some storage overhead. Have you tried anything like this? Do you have a benchmarking system you could test against if I were to give you a pull request?
1) You shouldn't run code like this every 20 ticks, you should instead run the code for a fraction of your machines every tick. That way, you do the exact same work, over the span of 20 ticks, rather than all at once. That will reduce stutter caused by your script, which results in smoother feeling gameplay. TFMG thermal uses an update quota system, where every tick it will update a certain number of machines, (for example 1000) if you have more machines than that, TFMG thermal will spread out all the updates over multiple ticks. This guarantees that with any number of machines, the performance cost never rises above a maximum amount. Instead, trading in some simulation accuracy.
2) Its hard to know exactly whether your code is more or less efficient. More importantly, calculating heat produced based change in products finished is less efficient than having a recipe produce a fluid that is burned in a reactor that is set to stop consuming fuel when at max temperature. using that you could eliminate on tick scripts. The reason i dont do that is that TFMG thermal needs to work conditionally (depending on surface condition) with any recipe, on any building.
3) Using products finished to calculate heat opens up possibilities for exploits with recipe switching; in addition, it may not work as expected for recipes that are very slow. which is fine, but something to be aware of. My method calculates energy usage directly using the energy consumption multiplier and a precalculated base energy consumption to minimise workload.
2) It is unclear to me what you are doing with the bp_proxy stuff. Are they there to make the heat pipe connections show up for ghosts?
1) The BP proxy in my mod is responsible for containing rotation information of heat interfaces when players place and paste blueprints containing them. This is necessary because heat interfaces themselves cannot be rotated, and do not have ghosts (since they aren't placable by any item) and cannot be used for this purpose. My next update for TFMG thermal eliminates this and will use ghost tagging instead to store rotation information in the interface's parent ghost. The next update for the mod also includes a boatload of other improvements that will make the mod generally better.
2) Regardless, you don't need to know the complete inner workings of TFMG thermal to be able to utilise it effectively templates.lua contains everything you should need to know.
Thanks for your time
No problem.
P.S: You've accidentally shipped a bunch of .bak files and your .git folder in your mod release.