Soring the energy in joules into an integer seems to be not precise enough but that should be fixable.
How careful do I need to be with item tags? For example can I just remove “WARM” tag from the item or should I first check if the item has that tag? Same for adding them, can I just add “WARM” tag or should I first check if the item already has that?
First off, know this, my C++ is probably ranked D- by know, been a very long time for me.
Second, I am only picking your brain to hopefully help in some obscure, unknown to me way.
I would think to check for the tag first to avoid running unnecessary code. This should help keep processor overhead down. And have you benchmarked the code to see how much time it adds? Will it lag the game on insane items being calculated for each turn?
If none of this is helpful, feel free to ignore me. LOL
Store the energy in millijoules or microjoules - an int can store 2147483648, and that’s up to 2 kJ with 6 significant figures. How large a number at how much precision do you need?
Item calculations are done per stack. Spawning 1000 items would only create one item stack. Debugging in 10k items one by one would be pretty tiresome.
I’m storing the energy in centijoules (0.01 J).
The biggest item in game with temperature is probably 200 l water tank.
Energy in 200 l of liquid water = 200000 g * ( 273.15 K * 2.108 J/gK + 334 J/g ) = 181960040 J = 18196004000 cJ
That thing can’t even be in liquid form at 0 °C without overflowing the integer.
You rarely think on how massive ammounts of energy melting water takes. The ice -> water change alone is 6680000000 cJ for 200 l of water.
Saving half joules in there should work. That would allow 200 l water tank to heat to around 1000 °C before issues start and with longer calculation intervals that should be accurate enough. Not sure how hot temperatures the system would need to handle.
At first it seemed that I would need much better precision but I had just messed with units.
I saw your PR on the github and could not find you on the discord, so I brought you a moni hug from there to here. This is an amazing first contribution, I hope all possible kinks and such are worked out and the PR goes smoothly!
I still need those saves with massive number of food stacks. (spawning items with debug menu will spawn X number of items in one stack. This will be calculated as single item.)
Performance with large number of items is still completely untested.
It is time to start adding the thermal properties to foods. And I could do with some help on how to do it.
The original plan was this:
Add “specific_heat_liquid”, “specific_heat_solid” abd “latent_heat” to all foods.
But we don’t really need unique values for all foods.
New plan:
Have a json file that defines different thermal properties for groupos of items.
I think a good way to do this would be able to use the material (flesh, veggy, wheat, ect), the item’s quench value to determine liquid content and weight?
Per-item values for everything otherwise sounds like hell.
The material could maybe be used. But there would be some problems.
How to handle foods that have multiple materials?
Some foods have no materials (only few odd ones like wax and royal jelly).
Some odd ones like “tomato” being separate material from “vegetable”. I guess they were meant for the allergy/food intolerance system.
No “dry” material. Dried mushrooms and fresh mushrooms are both “mushroom”.
No “cooked” material. Vegetable dishes would be like fresh vegetables. And then vegetable dishes would behave differently from meat dishes.