Looking for a mod that adds more room types to the game

Started by AnActualDuck, March 22, 2020, 03:41:43 PM

Previous topic - Next topic

AnActualDuck

I made a really nice chapel/wedding spot but the game designates it just as "Room," and there is no real benefit to it's existence like other rooms give. I can't find any mods that even slightly tackle the idea of adding room types to the game that effect pawn mood. I could see a chapel being used for pawns that pray and for weddings, giving the usual mood boost for having a beautiful room. I'm sure there are other room types that could have various benefits as well (art gallery comes to mind for colonists that want to view art recreationally).

If you know of anything like this let me know! Thanks!

LWM

I have two planned new rooms:  "warehouse/storage room" or something for ....storage, and a "chapel"/"temple"/&c for my prayer spot mod.....but I've been busy with upgrading to 1.1 and getting other mods up and running, so I haven't had a chance to do these...

I at least have an idea how to go about doing it - there's some roomworker thing you have to set up and register?

Homez

Neither have I done it, but it looks fairly straightforward. Does require some C# though.

Create a new mod in the RimWorld Mods folder and a new solution; follow this tutorial if you don't know what that's about:

https://rimworldwiki.com/wiki/Modding_Tutorials/Setting_up_a_solution

You'll need the following folders in your Mods root directory: About, Assemblies, Source, and Defs. Inside Defs create a folder called Rooms, and inside Rooms create a file called RoomRoles.xml.

The inside of your RoomRoles.xml will need to look something like this:

<?xml version="1.0" encoding="utf-8" ?>
<Defs>
    <RoomRoleDef>
        <defName>Chapel</defName>
        <label>chapel</label>
        <workerClass>RockinRooms.RoomRoleWorker_Chapel</workerClass>
        <relatedStats>
            <li>Beauty</li>
            <li>Cleanliness</li>
            <li>Wealth</li>
            <li>Space</li>
            <li>Impressiveness</li>
        </relatedStats>
    </RoomRoleDef>
</Defs>


Notice the "<workerClass>RockinRooms.RoomRoleWorker_Chapel</workerClass>" line in the XML snippet above. That should be the namespace and class name of whatever class you make. If you have a decompiler, you can use "RimWorld.RoomRoleWorker_DiningRoom," "RimWorld.RoomRoleWorker_Hospital," or any other RoomRoleWorker as an example.

The GetScore method is basically a method that looks at all the stuff in a room and tallies up a score based on whatever it finds. When RimWorld is trying to decide what type of room something is, it pulls in all these Defs and RoomRoleWorker classes and executes their GetScore method. The RoomRoleWorker with the highest score is the winner, and the room will then be that type. For details, check out the Verse.Room.UpdateRoomStatsAndRole() method in the decompiled code.

What that means to you is that your Def and C# class will be automagically pulled in, and your GetScore method will compete against all the other RoomRoleWorker GetScore methods. The trick is to balance your GetScore method so that when the room genuinely looks like a Chapel, Chapel wins, and when it doesn't look like a Chapel, Chapel loses to something else.

Never done this before myself, so if my instructions are derped up or unclear, feel free to reply with questions.

The idea is interesting. RimWorld has many things, but it has a marked lack of religion. Pretty noticeable omission for a life simulator in my opinion.

LWM

I happened to know most of that.....but that was a fantastic writeup and you should 100% put that in the wiki as a tutorial for How to Make a Room Role.  The only thing I could think that is missing is a guide to what sorts of Scores vanilla rooms come up with.

I'm going to go follow along from where my knowledge ends and write up a RoomRoleDef.  And look up vanilla scores!

Again, thanks!

LWM

Here's vanilla room role scores:


   Barn      Number of Animal Beds * 7.6   
   Barracks      Number of non-medical beds * 100100   
   Bedroom      One bed: 100000   
   Dining Room      Number of tables * 8   
   Hospital      Number of medical beds * 100000   
   Kitchen      Number of "stoves" * 14   
   Laboratory      Number of research benches * 30   
   None      -1   
   Prison Barracks      Non-medical beds * 100100 + Medical beds * 50001   
   Prison Cell      1 bed: 170000, one medical bed 100000, otherwise 0   
   Rec Room      Number of "recreation" objects * 5   
   Room      0.99   
   Throne Room      One throne inside?  10000   
   Tomb      Number Sarcophaguses * 50   
   Workshop      Number of production workbenches * 13.5   

I now have a "Chapel" room for my Prayer Spot mod; next up, figuring out how to give pawns positive moods for nice places to pray.