Ludeon Forums

RimWorld => Releases => Mods => Outdated => Topic started by: lperkins2 on January 05, 2018, 12:55:19 AM

Title: [B18] Insulating Walls
Post by: lperkins2 on January 05, 2018, 12:55:19 AM
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
Title: Re: [B18] Insulating Walls
Post by: 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.
Title: Re: [B18] Insulating Walls
Post by: evilbob on January 05, 2018, 02:31:37 AM
I need it, I'm playing at -45'C cheaper heating bills are welcome  8)
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on January 05, 2018, 02:44:16 AM
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.
Title: Re: [B18] Insulating Walls
Post by: 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!
Title: Re: [B18] Insulating Walls
Post by: Sarge on January 05, 2018, 09:55:36 AM
This is clever. Sign me up.
Title: Re: [B18] Insulating Walls
Post by: 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.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on January 05, 2018, 02:21:32 PM
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.
Title: Re: [B18] Insulating Walls
Post by: Sarge on January 06, 2018, 02:45:43 AM
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.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on January 06, 2018, 03:15:48 AM
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.

Title: Re: [B18] Insulating Walls
Post by: evilbob on January 06, 2018, 04:19:06 AM
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
Title: Re: [B18] Insulating Walls
Post by: Sarge on January 06, 2018, 09:51:03 AM
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.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on January 06, 2018, 12:10:58 PM
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.
Title: Re: [B18] Insulating Walls
Post by: Sarge on January 06, 2018, 11:10:11 PM
It looks like you nailed it, I haven't had any issues in about 2 hours now.
Title: Re: [B18] Insulating Walls
Post by: Severik on January 12, 2018, 12:51:34 AM
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.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on January 16, 2018, 07:07:16 PM
Can you give me some more details / screenshot of your layout?  Probably easiest to find the bug if I can duplicate the setup.
Title: Re: [B18] Insulating Walls
Post by: FociA on February 04, 2018, 05:58:34 AM
Works great, you should release it in the steam community to find quicker issues.

idea:
combined materials. inner - center - outer wall(one tile wall, not 3 layer of walls). gold etc inner walls for beauty. woll in the center for Insulating. titanium etc for outerwall damage.
Title: Re: [B18] Insulating Walls
Post by: Harry_Dicks on February 04, 2018, 10:24:57 AM
So I was thinking about this. Could we have a "hardcore" edition of this mod, or something that doesn't reduce temp changes for double thick rooms under mountains to only equalize @ 1%? I like the idea of insulating walls, but I may not want this drastic of a change, only slightly as much :) If it all possible, would a mod options window be possible, with some sliders for us to play with? Maybe in the future, if you plan on expanding this mod that much further.

Personally, I think it could be fun to play with all kinds of heat transfer/insulation mod options. Maybe you want to require your ice sheet map to need 3 layer thick walls, for a 50% heat transfer reduction, but only two walls will give you 25% reduction? Just some fun thoughts ;)
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on February 08, 2018, 05:58:08 PM
Quote from: FociA on February 04, 2018, 05:58:34 AM
Works great, you should release it in the steam community to find quicker issues.

idea:
combined materials. inner - center - outer wall(one tile wall, not 3 layer of walls). gold etc inner walls for beauty. woll in the center for Insulating. titanium etc for outerwall damage.

I have no idea how I would go about releasing it on Steam, I don't use Steam with rimworld (I don't use steam with anything that isn't absolutely necessary).  If you have some pointers on how to do that, I could possibly make it happen.

Eventually I want to support something like that, but it will take reworking a lot more internals, which isn't super easy.  The stock temperature system calculates the room map every time a wall is placed or removed, and caches it.  It then goes through the room edges, checking exactly one space out, along the principal axes, to see what it in that cell.  I'll I'm doing (so far) is changing how it reacts to finding that cell filled, adding checks to additional cells is another thing entirely.

Monodevelop lets me browse the base assembly, but lacks any sort of decent search, and can't export the decompiled source for use with grep et al.  Rider has a much nicer decompiler, but lacks a way to browse the assembly at all, and also can't export it to a greppable form.  None of the windows decompiler stuff plays nicely with mono/wine, so I'm out of luck there too.  This leaves just browsing the assembly in monodevelop and hoping to spot what needs to be overridden.

Quote from: Harry_Dicks on February 04, 2018, 10:24:57 AM
So I was thinking about this. Could we have a "hardcore" edition of this mod, or something that doesn't reduce temp changes for double thick rooms under mountains to only equalize @ 1%? I like the idea of insulating walls, but I may not want this drastic of a change, only slightly as much :) If it all possible, would a mod options window be possible, with some sliders for us to play with? Maybe in the future, if you plan on expanding this mod that much further.

Personally, I think it could be fun to play with all kinds of heat transfer/insulation mod options. Maybe you want to require your ice sheet map to need 3 layer thick walls, for a 50% heat transfer reduction, but only two walls will give you 25% reduction? Just some fun thoughts ;)

As above, checking for more than 2-thick walls is something I hope to get to with a 'phase 2' of the mod, when I have a better idea how these pieces fit together with everything else.  I may skip it entirely, and go for using a proper heat map, since I think that is the proper way to go long term, but I suspect that will have lots of little effects everywhere and I really need a good way to search for references before I can safely do that.

I picked 1% sort of arbitrarily, I may just has correctly made it 0%.  At 1%, the temperature effect on the room is dominated by the floor/ceiling ambient effect.  The idea was there is no good way to tell what the temperature change should be: it's not the outside world, since it's not an exterior wall, but it's also not the 'ambient underground temperature' (15C), so have a slight effect, but not much.  The proper thing to do is probably to look at the nearby cells and see if any of them are part of a room, and if so use that temperature, if not, the wall is at least 3 thick, and we should just use the ambient underground temperature.  We can't look more than the extra 1 tile away, or we might find our starting room, and there's no good way to know which direction to limit the search to.

As for the menu options, that's probably not a bad idea.  It would make isolating bugs simpler, since there are 3 overridden functions and disabling them at runtime would not be a bad idea.  I don't see a whole lot of point to investing time in adding sliders for fudge factor variables, and I'm not sure the mod option menu is the proper place to put per-item-type insulation settings, there would be a lot of them... 

As for adjusting the wall thickness needed to achieve 50% reduction in heat transfer, that won't change.  The equation for heat transfer is (temperature difference * material_specific_number) / material_thickness.  Doubling the thickness reduces the heat transfer in half, no matter what the temperature difference is, and no matter what the material type is.  The goal of this is to improve the realism of the temperature system, so replacing the real equation with a fake one would be counter-productive.
Title: Re: [B18] Insulating Walls
Post by: Ruisuki on February 24, 2018, 08:16:03 PM
Does anyone happen to know if the mod Rainbeaus Smooth Stone walls insulate with the same efficiency as vanilla walls? Ive gotten word on outside forums(not by OP) that they are only marginally better at insulation than natural(unsmoothed) cave walls.


https://ludeon.com/forums/index.php?topic=36687.390
Title: Re: [B18] Insulating Walls
Post by: Harry_Dicks on February 24, 2018, 09:56:17 PM
I would recommend checking this mod out, I think it is fantastic. It gives you a little button @ the bottom right to toggle on a heat map. Even if I still don't fully understand all of the insulation and heat dynamics, it makes things a lot easier to understand where your heat is transferring over your base. You can even customize how often it updates in the mod options, what! ;D

https://ludeon.com/forums/index.php?topic=33647.0

While we're at it, this is my other must have mod overlay, Show Me Where. It shows you where all of the different fertility zones are, so you can finally set up your grow zones on all of the proper tiles in no time flat. I remember tons of frustrations trying to mouseover all of these different cells trying to find all of the different fertile spots, frustrating. It also shows you your buildable area, perfect for swamps and just to have all around.

https://ludeon.com/forums/index.php?topic=37167.0
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on February 25, 2018, 01:44:56 PM
Unless Rainbeaus Smooth Stone Walls does some reflection magic, they insulate exactly the same as any other totally impassable terrain (constructed walls or natural stone).
Title: Re: [B18] Insulating Walls
Post by: Ruisuki on March 01, 2018, 02:32:28 AM
Quote from: Harry_Dicks on February 24, 2018, 09:56:17 PM
I would recommend checking this mod out, I think it is fantastic. It gives you a little button @ the bottom right to toggle on a heat map. Even if I still don't fully understand all of the insulation and heat dynamics, it makes things a lot easier to understand where your heat is transferring over your base. You can even customize how often it updates in the mod options, what! ;D

https://ludeon.com/forums/index.php?topic=33647.0

While we're at it, this is my other must have mod overlay, Show Me Where. It shows you where all of the different fertility zones are, so you can finally set up your grow zones on all of the proper tiles in no time flat. I remember tons of frustrations trying to mouseover all of these different cells trying to find all of the different fertile spots, frustrating. It also shows you your buildable area, perfect for swamps and just to have all around.

https://ludeon.com/forums/index.php?topic=37167.0
Appreciate the suggestions as always Harry. Good QOL right there. I THINK I saw Barky using this when previewing the Centralized Climate Control mod

Quote from: lperkins2 on February 25, 2018, 01:44:56 PM
Unless Rainbeaus Smooth Stone Walls does some reflection magic, they insulate exactly the same as any other totally impassable terrain (constructed walls or natural stone).
Excellent! So I can dig inside and focus smoothing without worry then. As long as I leave the outer layer reachable in order to smooth that is.
Title: Re: [B18] Insulating Walls
Post by: Makani on August 08, 2018, 10:06:26 AM
Requesting reupload of this mod.

I'm on a map that sees temperatures falling below -220. You just lose heat so fast it starts to not matter how good your heating is. Need better insulation to fight it.
Title: Re: [B18] Insulating Walls
Post by: Naji on August 08, 2018, 01:18:18 PM
Quote from: Makani on August 08, 2018, 10:06:26 AM
Requesting reupload of this mod.

I'm on a map that sees temperatures falling below -220. You just lose heat so fast it starts to not matter how good your heating is. Need better insulation to fight it.
+1
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on August 12, 2018, 05:30:54 PM
Alright, I just posted a link for a direct download that should stick around pretty much forever.
Title: Re: [B18] Insulating Walls
Post by: Makani on August 13, 2018, 09:48:57 AM
Quote from: lperkins2 on August 12, 2018, 05:30:54 PM
Alright, I just posted a link for a direct download that should stick around pretty much forever.

Thank you!
Title: Re: [B18] Insulating Walls
Post by: Makani on August 15, 2018, 01:57:06 PM
Bug report:

This mod caused some of my rooms to reach over 1000F, and others to plummet to -400F. Only this mod was added when the problem started, though notable, I am using the centralized climate control mod too.

Here's a screenshot of the rooms:
(https://i.imgur.com/jFnwu8S.png)
Top right room is -450F at the time of screenshot. Top middle -300F (but the fire suggests a very rapid temperature swing). Top left 670F. Outdoors -19F.

Climate units set for 78F.

Temperature across the whole base is out of expected ranges, but these were the most extreme examples.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on August 15, 2018, 02:24:18 PM
Hm, I thought I'd fixed that... I'll see if I can squeeze some time out to figure out what's causing it.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on August 16, 2018, 03:04:31 PM
And the answer is I did fix it, but the link I posted was to an old version.  I've uploaded the fixed version now, go ahead and give it another try.
Title: Re: [B18] Insulating Walls
Post by: Makani on October 28, 2018, 04:15:50 PM
Requesting update again. The city colony must survive!

(https://i.imgur.com/KPiOlqg.png)
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on October 29, 2018, 02:02:58 AM
Have you checked out my rewrite of this, which implements the advanced features I mentioned here?  I can probably upload an update to this in the next day or two, but the other version is configurable, and tracks temperature per cell. 

It's at https://lp-programming.com/heatmap19.zip
Title: Re: [B18] Insulating Walls
Post by: Makani on October 31, 2018, 11:53:34 PM
Quote from: lperkins2 on October 29, 2018, 02:02:58 AM
Have you checked out my rewrite of this, which implements the advanced features I mentioned here?  I can probably upload an update to this in the next day or two, but the other version is configurable, and tracks temperature per cell. 

It's at https://lp-programming.com/heatmap19.zip

Well, I'm not really looking to change the simulation's base mechanics.
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on November 01, 2018, 01:14:55 PM
Fair enough, I just recompiled it against version 19, which should work on version 1.0 too.
https://lp-programming.com/rwtemperature19.zip
Title: Re: [B18] Insulating Walls
Post by: Modo44 on November 01, 2018, 04:00:43 PM
Insulation based on wall condition is nice, but it would also need to depend on the specific material to make sense. For a basic example, the same thickness of wooden wall will insulate way better than steel.

Also, single walls need to matter this mod is going to work in a plausible way (i.e. not require reading the manual to understand what is happening).
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on November 01, 2018, 04:39:05 PM
So, I'd love to make insulation depend properly on material, but doing so in a way that will work with arbitrary wall materials from other mods is non-trivial. 

That said, it's non obvious that an arbitrary wooden wall will insulate better than an arbitrary steel wall.  K for wood is around .16, for stainless, it's around 16.  So, for an equally air tight wall, of equal thickness, the steel will transfer heat about 100 times as fast as the wood.  But I am not convinced that the walls should be treated as equally built.  The total thickness is the same, but for the wooden walls to stop bullets, and considering the construction time, and the use of raw rather than processed wood, I always figured they're basically log walls, which do not insulate anywhere near as well as wooden sheeting with an air gap.  Meanwhile, the relatively low HP on the steel walls means they're probably hollow. 

All that aside, I'd happily make wooden walls better insulators if I could think of a good way to do it without breaking things with other mods.

As for single walls mattering, that is not possible with this mod.  Each room tracks a list of cells 2 away, it does not track the cells that comprise its wall.  You can see this in the debug viewer in the game.  It would have to go back to the room definition itself and work out the walls of the room, and would probably require larger changes to make it work right (and run fast enough). 

I mentioned a few posts earlier that I rewrote this mod to use a 2d heatmap, which better handles wall materials (hp% matters, maxhp does not), and properly handles single thick walls.  It's also configurable, but does take a slightly more powerful computer (it's not bad, but if RW doesn't run well for you as is, it certainly won't help).
Title: Re: [B18] Insulating Walls
Post by: Makani on November 08, 2018, 05:29:34 PM
Hmm.

Is there a detailed list of tradeoffs between this mod and heatmap?
Title: Re: [B18] Insulating Walls
Post by: lperkins2 on November 08, 2018, 07:00:55 PM
Not really, but it's pretty simple. 

This mod just makes double thick walls not magically equalize temperature with the outside world.  This makes the temperature change in rooms pretty much depend only on the roof/floor temperature change.  Overhead mountain makes the temperature tend toward 15C, no matter what.  Thin rock and manufactured roof make the indoor temperature tend toward the outdoor temperature.  It doesn't really change the core mechanics at all.

HeatMap uses a 2D heat map to calculate the temperature.  This means that temperatures vary within a room, not just between rooms.  The biggest 'problem' is if you have insufficient heat to have a warm enough room, your colonists won't seek the spaces by a fire to warm up (or cool down if the opposite is true).  In practice, this isn't really any worse than the vanilla behavior, where the entire room would be too cold, and is often much better since you can simply light a campfire outdoors or stand near steam vents to warm people up when you lack buildings. 

This one could be extended a bit, for example, the temperature at the external wall cell could be queried, it would give the temperature of the next room over (or outside) if the wall is only 2 thick.  The problem is that 3-thick walls will count as outdoor, and thus insulate worse than 2-thick walls underground.  I haven't come up with a good solution for that problem.

In summary:
This mod:

Heat Map:

Both mods are safe to add and remove mid-game (by safe, I mean the game won't crash or similar, your freezer might need a redesign).

Since I don't run this mod myself anymore, I'm unlikely to add new features to it, but I will probably keep working on HeatMap from time to time.
Title: Re: [B18] Insulating Walls
Post by: ambivalence on December 26, 2018, 12:58:33 PM
Maybe I miss something, but HeatMap (now?) seems to add a temperature overlay, nothing more. So, these mods solve different problems and thus should be compatible with each other?
Title: Re: [B18] Insulating Walls
Post by: Kryt on August 09, 2019, 05:54:27 AM
Great mod but all links are dead. Can anyone reupload the mod? Pleeease!