Jump to content

New type of building rotation


Recommended Posts

Objectively speaking, building rotation works like a list. Each time a hotkey is pressed, the active preview will switch to the next valid index in the list. If it goes over the end, it will pick the first in the list. The setting then affects port placement, where the floor should be, sprite drawing etc.

We need something like that, but with a different hotkey and without actually affecting rotation. Instead it should be a number going from 0 to max (default 0). This can then create new alternate versions of the building. IBuildingConfig could gain some OnAlternateChanged method while BuildingDef could contain a max value. This will allow modding freedom to make various new buildings and more importantly, prevent the need for spamming the building menu with variations of the same building.

If AlternateVersion is an int in the Building component, it should be reachable by all the code, which could make use of it. One obvious usage is adding different components in DoPostConfigureComplete, or different offsets for ports. Perhaps even different number of ports to match the different number of components.

Adding a building cost modifier for each AlternateVersion could be interesting and if OnAlternateChanged can optionally skip certain numbers, like it can call Next() and then return, then OnAlternateChanged can check for owned techs, meaning the same building can gain more types of modifications as the player research more techs.

Ideally speaking, BuildingDef should be a locally owned instance to the specific Building, meaning AlternateVersion should be able to alter BuildingDef for the specific building. This would add a lot of modding freedom.

 

Examples of existing mods where this could be used:

High Flow Storage. I already (ab)used horizontal flipping to flip input and output on one building. With alternate versions I would be able to merge horizontal and vertical gas storage buildings into one building. It would also free up the rotation setting meaning each alternate port layout would be possible to rotate if needed.

Longer Bridges. It needs R360 rotation (obviously), meaning there is currently nothing left for length. Alternate layouts could switch length, meaning we could gain longer bridges without adding more buildings to the building menu. It can also add bridges to pass 3 or 4 pipes. Building cost modifier can add a cost for each length and each length can be unlocked by more advanced techs, but we still do not spam the build menu like modders have to do right now.

 

Another usage for this would be to add a new AlternateVersion and then make the old one unbuildable for previews, but still valid for buildings under construction or already constructed. This will allow making changes to a building, which isn't savegame safe, but at the same time avoid having to completely abandon the building and start with a new from scratch. DoPostConfigureComplete can then contain "if AlternateVersion >= 1, then add logic port and component using logic port" or whatever the savegame unsafe change would be.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...