Skip to content

Instantly share code, notes, and snippets.

@boformer
Last active April 19, 2017 13:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boformer/cb50a1a8f4ba89f91d09 to your computer and use it in GitHub Desktop.
Save boformer/cb50a1a8f4ba89f91d09 to your computer and use it in GitHub Desktop.
Sub Buildings Enabler Documentation for Asset Creators

Introduction

This tutorial will explain you how to create a Cities: Skylines building with "sub buildings". Sub buildings are separate building assets which can be used to create assets which are larger than 16x8.

To place these buildings, the Sub Buildings Enabler Mod is needed until Collossal Order comes up with a better solution.

But there are also other use-cases!

  • Use the same module multiple times. That means you can save a lot of memory and increase the rendering performance.
  • Create buildings with irregular-shaped footprints (composed of squares and circles)
  • Combine buildings with different functionalities (e.g. hospital + fire station).
  • Create buildings with multiple overlayed modules using different shaders (one that follows the terrain as a custom ground texture, one that does not)
  • Create "props" (actually buildings) that will not disappear when you zoom out. This is especially useful for larger decoration elements

About the mod

  • Feature is officially supported by the game, no hacks.
  • You only need it to place down the building. Even if the mod breaks, your super-large buildings are still there. You also don't need the mod to create the building. All you need is a text editor (e.g. Notepad).
  • Minimal, high-performance code (only active during loading screen)
  • The main building and the extension modules can be published as a single workshop item, or as separate items.
  • You can use any building from the workshop as a sub building.

Preparing your model

Keep in mind that you have to create multiple models with their own mesh and their own uv map/textures:

  • One main model (the one that has to be placed roadside if you don't use a template that can be placed anywhere). This one is required.
  • One or multiple extension models ("sub-buildings"). The sub-building meshes can be re-used multiple times with different rotations (e.g. airport with multiple similar gates).

Every building has to be imported as a normal building in the asset editor. That means the center of each model has to be at 0|0|0. The maximum size of each part is 16x8, 15x9, 14x11 or 13x12 cells.

Once again: Every module has it's own textures. Keep that in mind!

In this tutorial, I will create a simple airport without textures, consisting of a central terminal building and and 2 gate sub-buildings.

I created these 2 standalone meshes for it:

Terminal Gates

Save the .fbx files and the textures in the Import folder of the game.

Importing the main building

In the asset editor, select the desired template for your building (e.g. airport, stadium, harbor). Import your asset and decorate it with props and trees, set the color variations and the correct plot size.

The main model has to contain all networks. In case of an airport, that means runways and taxiways, pedestrian paths and maybe also normal roads. This tutorial will not explain you how to create these paths. Contact me on steam for help. If your asset is really large, it makes sense to create a "merged" model that includes all sub building meshes, so you can see where to place the network. Then save it as a template and import only the main building (enable the "Import Props" checkbox).

The category of this asset will also determine the workshop category of your asset with sub-buildings (if you want to publish all parts as a single item).

Now open the save dialogue. Enter a file name (bottom left) and the asset name (right side). The asset name will be display in the game. Also make sure that the thumbnail looks good.

Write down the file name and the asset name you entered. The internal name of your asset, which we will need later, has the format: filename.assetname.

In this example, it would be SBE_airport_terminal.Super-Awesome Airport:

http://i.imgur.com/v2x0Jw7.png

Save the asset.

Importing the sub buildings

Now we will import all sub buildings. The only real difference is that we are using a special template that does not require a road connection, and which does not generate a menu icon for our sub building.

The only templates which are matching both criterias are the sub-building templates of the International Airport ("Large Airport L1/L2/R1/R2", After Dark DLC required). If you don't own the DLC, use this template instead.

Select the model of your sub-building and import the asset. I recommend you to change the ItemClass and the UICategory of your sub-buildings with the asset editor mods released by Snow_Cat.

Now save this asset as well. Also write down the file name and the asset name you entered. In this example I will use SBE_airport_gate.Gate.

Arranging the buildings and writing the sub building definition file

Switch back to your modeling application and import all meshes at 0|0|0. Now duplicate, move and rotate the sub-building meshes until everything is in place. Write down the rotation and position values for every sub-building.

Open your file manager and navigate to your local "Assets" folder (on Windows, enter this path in your explorer path bar: %AppData%\..\Local\Colossal Order\Cities_Skylines\Addons\Assets\). Create a new folder with a name of your choice and move the .crp files of your main building and all sub-buildings into that folder.

Now open your text editor and paste this code. It will define the positions where your sub-buildings are displayed (relative to the main building origin):

<?xml version="1.0" encoding="utf-8"?>
<SubBuildingsDefinition>
  <Buildings>
    <Building name="SBE_airport_terminal.Super-Awesome Airport">
      <SubBuildings>
        <SubBuilding name="SBE_airport_gate.Gate" pos-x="-100" pos-y="0" pos-z="-67" angle="-45" fixed-height="true" />
        <SubBuilding name="SBE_airport_gate.Gate" pos-x="100" pos-y="0" pos-z="-67" angle="45" fixed-height="true" />
      </SubBuildings>
    </Building>
  </Buildings>
</SubBuildingsDefinition>

Replace the values in this file with your own values. In the <Building> tag, replace the name with the internal name of your main building.

The <SubBuilding> tags represent the sub-buildings. Enter names and the values you used in your modeling application (position and angle). Note that Cities: Skylines uses a different coordinate system than Blender (Y is up, + is sometimes -).

The fixed-height attribute sets if the asset must be rendered on the same height as the main building.

Save the file with the name SubBuildingsDefinition.xml in the folder you created for your .crp files.

Asset Folder

Final Adjustments

Now you can place your asset ingame. Make sure that the 'Sub Buildings Enabler' mod is enabled. If anything is wrong with the config file or the assets, the mod will display a warning. Place the asset and check if it looks alright

To quickly find the right settings, adjust and save the xml file, then load a city from the ESC menu and place the building again. The mod will apply the new settings from the save file whenever a city is loaded.

Placed Airport

Workshop Publishing

It is recommend to publish the main building and the sub-buildings as a single workshop item. To do that, go to the Content Manager and click on the Share button of your main building asset.

Click on the little folder icon in the preview image (and edit the preview image if you want), then open the subfolder Content.

Now you have to create another .xml file that is slightly different and place it in the folder. When you upload something to the workshop, the "package id" changes. Instead of the filename you entered, it will be the workshop ID of the asset (e.g. "1447385507"). There is no way to find out this ID before you hit publish.

But the mod is smart: It will try to auto-complete the asset name if all assets share the same workshop ID (single workshop item). Just change the .xml file you created earlier so it matches this one (remove everything in the names before the '.'):

<?xml version="1.0" encoding="utf-8"?>
<SubBuildingsDefinition>
  <Buildings>
    <Building name="Super-Awesome Airport">
      <SubBuildings>
        <SubBuilding name="Gate" pos-x="-100" pos-y="0" pos-z="-67" angle="-45" fixed-height="true" />
        <SubBuilding name="Gate" pos-x="100" pos-y="0" pos-z="-67" angle="45" fixed-height="true" />
      </SubBuildings>
    </Building>
  </Buildings>
</SubBuildingsDefinition>

Save the modified SubBuildingsDefintion.xml file in the Content folder.

Now paste the .crp files of all sub-buildings into the Content folder. That means all assets will become a single workshop item. The folder should look like this:

Content Folder

Press Publish. Create a backup of your local .crp files, then delete them. After that, subscribe to your workshop asset and test if everything works correcly.

Don't forget to add the mod as a dependency! Also mention that the mod is only needed to place the asset, and can be disabled at any time without causing broken saves or missing assets.

Advanced

You can also use buildings with functions as sub-buildings (e.g. to create a combined fire station + hospital). Just keep in mind that such a sub-building needs road access. To hide the asset in the building menu, set the property ToolController.m_editPrefabInfo.m_placementStyle to Procedural with Mod Tools.

You can also use Mod Tools to find out the internal name of workshop items (<workshopId>.some_text). Just place the building ingame and open the info window. The name will be displayed at the top. Use this name in your SubBuildingsDefintion.xml file.

@macronomicus
Copy link

woah, very nice, thank you so much for this! Im looking forward to using this for the Biltmore estate & grounds :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment