Truinto / ONI-Modloader-SimpleMods

OxygenNotIncluded Mods
MIT License
16 stars 6 forks source link

Inconsistent Throughputs for Air Conditioners #49

Closed TroublesomeCorvid closed 7 months ago

TroublesomeCorvid commented 8 months ago

I've been having trouble figuring out how this bit of your mod works because the throughputs of the Thermo Regulators and Thermo Aquatuners don't seem to be consistent with the inputs: Absolute Power Factor, Max kDPU, and Absolute Target Temperature.

The issue stems from the fact that with fluids and gasses, the game only ever advances a packet through a pipe segment once every in-game second. Meanwhile, the simulation is working out the math for your mod per tick. Which means that, for example, if a full-sized packet of fluid in a pipe (10kg) requires 1,000 kDPU to cool to a certain target temperature, and I have the Aquatuner's Max-kDPU set to 500, then I should get only 5kg of throughput, right?

But instead, I'm getting the full 10kg packet, because while the game only advances packets once per second, the Aquatuner is going per tick, and so it fills the pipe before the packet is moved.

If there's no setting in the game's code you can use to fix this, then there's two other ways that involve simple math.

  1. Run the math like this: (your original math) divided by (number of ticks-per-second the sim runs), or...
  2. Take the user inputs for (Absolute Power Factor), (Max kDPU), (Absolute Target Temperature), and divide each of those by (number of ticks-per-second the sim runs).

It's a bit of an ugly fix, but as the old saying goes, "Needs must when the devil drives." The devil, for this case, being the Devs at Klei, of course. :P

TroublesomeCorvid commented 8 months ago

Cairath set me straight on how frequently things are calculated in the game...

image

So, I guess this means adjusting the sim frequency on the Aquatuners and Thermo Regulators to 1000ms to line up with how frequently the sim moves packets through pipes?

Truinto commented 8 months ago

All the calculation happens in AirConditioner.UpdateState, which is called by Sim200ms.

I don't really get what you want. I will explain my thought process, maybe that helps. 1) I was annoyed that cooling stuff to a specific temperature was so difficult. Like, if you want to have 0-5 °C water for a sleet wheat farm, then you need to have a loop feeding back material, until it is cool enough, but then you may overcool it and break all your pipes. So really you need an extra room just to make a heat exchanger... anyway, I didn't get that to work. So the first component is "target temperature", which simply only outputs that one temperature you want. 2) But with that you have the issue that cooling a lot of material by a huge amount will overheat and melt the building very quickly. So the second component is "max kDPU" (or max heating of the building). 3) Assuming target temperature is more important, the only way to meet max DPU is to reduce the material throughput. (Unless you want to cheat and delete heat.)

Point 3 is a just a result of the other factors. I did not care for the exact pipe package mass. And in the context of a sleet wheat farm, that really doesn't matter.

By the way, the heat should be preserved regardless of how the pipe handles the packages. If not, than either my math has a bug or the pipe system is bad in general.