[B18] Insulating Walls

Started by lperkins2, January 05, 2018, 12:55:19 AM

Previous topic - Next topic

lperkins2

Insulating Walls

Description:
Makes the material type used for double thick walls matter.  Higher HP walls insulate better.  Walls beneath overhead mountain count as 10khp walls.

Details:
The temperature system in RimWorld is kinda wonky, this is the start of an effort to fix it. 

Walls provide the same insulation value, no matter their material type.  Further, walls more than 1 tile thick magically equalize temperature with the outside world, at half the normal rate, even if they are deep inside a mountain. 

This partially fixes both.  Double walled rooms inside overhead mountain will move toward the outside temperature at 1% the normal speed.  Unless the outside temperature is extremely high or extremely low, this will be swamped out by the area heating from the floor/ceiling.

Double walled rooms without overhead mountain insulate depending on the current HP of the outer tile.  The material type of the inner wall still doesn't matter.  Likewise, material type of one thick walls doesn't matter.

Upcoming versions will check the material type of the inner wall, and check further out for nearby rooms to exchange heat.  The eventual goal is to implement a crude heat map, with temperature not calculated by room, but that will require in depth related changes.

Author/Mod Team
lperkins2

Download
See attachment

How to install:
- Unzip the contents and place them in your RimWorld/Mods folder.
- Activate the mod in the mod menu in the game.

[attachment deleted by admin: too old]

'Permenant' location: https://lp-programming.com/rwtemperature.zip

BrokenValkyrie

Nice, I always assumed the quick temperature equalization was due to shoddy roofing. At least that how I was justifying it in my head.

evilbob

I need it, I'm playing at -45'C cheaper heating bills are welcome  8)

lperkins2

Quote from: BrokenValkyrie on January 05, 2018, 01:02:51 AM
Nice, I always assumed the quick temperature equalization was due to shoddy roofing. At least that how I was justifying it in my head.

A large part of it is shoddy roofing.  Heat transfers through thin roof at 1/14 the rate of open air (hole in the roof).  It equalizes at the same rate for thick roof, but always equalizes toward 15C, ignoring the outside weather.  Also, once the temperature outside is more than 100K different from the temperature inside, the extra difference is weighted 5x heavier (so if outside is 0C, and inside is 110C, it transfers heat as though the inside were 150C).  Single thickness walls transfer heat at 1/4 the rate of thin roofs. 

I might see how hard it would be to add an insulated roof, but I suspect that will also be a ways down the line.

Harry_Dicks

This mod looks very interesting. Just out of curiosity, do you know how your mod affects performance? Also, do temperature checks tick very often, and are they resource intensive? Is there anyway of slowing them down? Thanks!

Sarge


Heymom

Hey
Very interesting mod, have been a big fan of the max ice setting, so its -80 on avg on the maps i play.
I tried your mod, and my rooms now get so hot they set fire to the place. I am using the "auto cooler" mod, and i think its conflicting with that mod.

idea; add insulation options, ex. wooden walls + wool etc.. would be neat.

lperkins2

#7
Quote from: Harry_Dicks on January 05, 2018, 03:05:57 AM
This mod looks very interesting. Just out of curiosity, do you know how your mod affects performance? Also, do temperature checks tick very often, and are they resource intensive? Is there anyway of slowing them down? Thanks!

The performance impact on this version should be minor.  It does have to use a bit of reflection to access the temperature data, and I don't know how well c#'s jit can optimize that, but it only adds a couple lookups ans some simple math.  Temperature processes once every 7 ticks.  The roof checks are extremely fast, since it precalculates the % of the room that is roofed/thick roofed, then just adjusts the temperature based on that percent.  Perimeter of rooms matters a little, but it calculates the edge checks in segments, so only 1/5 of the perimeter is processed each temperature tick (the whole perimeter is processed every 35 ticks).  The biggest determinant for time required is # of rooms.  It would be possible to slow the cycle rate down, but I'm not sure it would be a good idea.  It's only likely to matter if you have dozens of rooms, and I don't know what effect it would have on heaters, coolers, and the like.

Quote from: Heymom on January 05, 2018, 11:04:03 AM
Hey
Very interesting mod, have been a big fan of the max ice setting, so its -80 on avg on the maps i play.
I tried your mod, and my rooms now get so hot they set fire to the place. I am using the "auto cooler" mod, and i think its conflicting with that mod.

idea; add insulation options, ex. wooden walls + wool etc.. would be neat.

That does sound like a bad mod interaction, I can't find that mod though, so I can't see what it's doing.  You might try changing the mod load order, but if there are other mods that touch the same internals you're likely to have problems. 

Eventually, I will probably add an explicit insulation property, which is autocalculated based on HP for mod-added walls, or anything which doesn't set the insulation value.  That would let someone (with actual artistic skill) add an insulated wall type, but I probably won't do it myself.

Edit:  Hm, I just had a couple rooms start oscillating temperature, I do have a central heat mod installed, but none of its stuff built, so something wonky is going on.  I'll look into it, but in the mean time, be careful using this mod, there may be an issue.

Edit2:  Okay, so I think I might have it fixed, I think the original version of the TempDiffFromOutdoorsAdjusted must have been inverting the sign somehow, I'll verify that once monodevelop finishes installing.  In the mean time, I just updated the zip file to disable that patch, the better wall insulation seems to be working as intended still.  If I'm right about how the function is getting used, the reason Heymom found the bug is he's on a map with a temperature difference in excess of 100K (-80 to +50), anyway, I should have a fully functional version up in a couple hours.

Sarge

I'm on a map with very mild temps and I'm getting the same thing. Just out of the blue things started catching alight indoors with temps well over 100C.

lperkins2

Hm, that's gonna be a pain to puzzle out...  Since I disabled one of the two patches, the trouble must be coming from the one that is still enabled, which is the more complicated one.  I'm a bit brain fried from programming all day, so I'll probably hit it tomorrow. 

In the mean time, the source is included in the zip, if anyone wants to take a peek, I'd have no objections.  The method overridden is Verse.RoomGroupTempTracker.WallEqualizationTempChangePerInterval.


evilbob

I also had a problem with igniting the rooms, and some husky also came on fire. After a few minutes I had to turn off the mod. :o

Sarge

If I knew the first thing about coding I'd help you look. Good luck, I really think your mod is worth it for the extremes crowd.

lperkins2

Alright, I think it's fixed.  I was multiplying the result by the 'cycleIndex' instead of the number of cells in the room.  This is why the problem would only show up after a while and I missed it in my testing.  If anyone is brave enough to give it a go, let me know if anything else breaks. 

As a side note, rider's decompiler seems fancier, and outputs prettier code, but monodevelop's is easier to parse.

Sarge

It looks like you nailed it, I haven't had any issues in about 2 hours now.

Severik

i got almost no errors the last few days.

then i was away for about 10 minutes after building a second layer of walls around my Research Lab.

when i came back, all my Pawns and Animals were Suffering from extreme Cold. it was -125°C and falling. had to load an older Save. still got the Problem after building the double Walls. so i had switch off the mod.