Roof/Ceiling Collapse removal

Started by frenetica, February 18, 2018, 07:47:24 AM

Previous topic - Next topic

frenetica

Hi, all.

I've been trying to completely mod out roof collapse; it's pointless micromanagement that forces me to make a bunch of ugly buildings with single supports that look gnarly. I hate it; I hate how my ridiculous transparent-roofed indoor pool needs to have marble columns at regular intervals, or face collapse. This, right here, is the truest suffering, and with your help, I can put an end to it. xD

So, I've been tinkering with RoofDefs.xml, and it's very sparse. I'm assuming that, for whatever reason, Tynan decided people would love this particular mechanic so much that it's hardcoded. ;) Therefore, I'm thinking that what I need to do is make a Nonsensical Roof Shield Generator that, while wasting a square, essentially supports all the roofing on the map, in perpetuity. (Which also could make for hilarious amounts of fun if it was destroyed in a raid - but, those are dice I'm willing to roll.)

But, since there's a help forum here, and after having found no posts that feel as strongly about roofs, roof collapse, and roof-collapse related incidents as I do, I thought I'd ask if anyone has a suggestion for a better, or more elegant solution. Thanks so much!

dninemfive

There's probably a way to patch the behavior out of the core of the game, but as a new modder to Rimworld myself it'd probably be easier to add a roof-supporting, invisible building which does not impede movement and can be placed on any floor, then script it to appear on any cell that's at least 12 tiles from the nearest roof-supporting building (including the support itself, of course). Unfortunately, that's as far as I can go other than pointing out that you need assemblies to do the scripting, as I haven't messed around with those much myself.

frenetica

Hiya, dninemfive! Thanks for the assist - I was kind of hoping I'd be able to jury-rig a solution without digging into assemblies, but, it's probably better to bite the bullet and dig in, huh? Well - what are you working on, at the moment? Can I help you out a bit, since you confirmed my fears/suspicions? I figure we new modders oughta stick together!

(Even if I'm a little worried my advice might be, uh, unelegant, at best...)

jamaicancastle

If you don't mind learning a little C# and picking up the Harmony library, the easiest way to patch it would be to target the methods RoofCollapseUtility.WithinRangeOfRoofHolder() and .ConnectedToRoofHolder(), which determines whether a roof is, well, within range of and connected to something holding it up. You can write a four or five-line patch for each method that will cause them to return true under all conditions, making the roof think it's being supported even when it's not.

dninemfive

frenetica - definitely go with jamaicancastle's response. I had completely forgotten Harmony existed. As for me, I'm currently working on patching some mods I use with XML (I'm currently stopped by an interesting error (https://ludeon.com/forums/index.php?topic=39122.0) I've been having). I have more in-depth plans, but I'm procrastinating from getting into assemblies, which I'll need to do them.

Jaxxa

I can have a look at adding that to my Enhanced Options mod if you like.

frenetica

jamaicancastle - ah, thanks, that sounds perfect. I'd actually like to learn C# in the first place, so maybe dinking around with it'd be as good a place as any. I'll give it a try.

dninemfive - Yo, I gave your xml a look; and I'm not sure how helpful my thoughts are, it's kind of late here. But I'll give it a real glance or five tomorrow, and see if I can't help out a bit. Anyway, procrastination is okay - too much work numbs the mind, and makes the output crummy. Same with too much procrastination, of course, but - I believe in ya!

Jaxxa - Ah, that'd be great! If you do it, I wouldn't mind seeing the code - I don't mind, and'll probably try to do something about it, myself, but...

It does seem like the kind of option that'd fit in perfectly with your collection. And I know I'm not the only person who gets irked by the 'don't build at the boundary' boundary, and tiny hive-like buildings, ahaha... Thanks!

Jaxxa

I just added an option for this in my Enhanced options mod.

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

As with all my mods the source is on GitHub.
The Relevent part is mostly here:
https://github.com/jaxxa/ED-EnhancedOptions/blob/master/Source/ED-EnhancedOptions/Patches/PatchRoofCollapseBuffer.cs

Feel free to ask questions about how it works.