Skip to content

2. Create cultures, districts and buildings

Milan Ender edited this page Aug 22, 2016 · 17 revisions

Learn about the stuff that it takes to create proper prefabs for the city simulation. This guide refers mostly to the asset folder in the TutorialDynamicCities Module

Cultures

This is the most important asset for a city, as it is the backbone of every settlement.


  • buildingNeedPerZone: How much m^2 each population unit demands for a specific zone.
  • growthRate: The amount of population unit the city gains with each population update. Can be set to zero if you want to use a custom model. Further reference: 3. Population and City Growth
  • availableBuildings: Which buildings are available for this culture to spawn. It matches with the string specified in the building name field.
  • residentialZones: This field tells the system what population capacity is available, though that is more of an experimental feature at the moment and thus is set very high in order to prevent interference with the normal city growth.

The example in the tutorial module shows what is needed to get a proper culture.prefab:

{  
    "Culture" : {  
        "name" : "develop clan",  
        "buildingNeedPerZone" : {"GOVERNMENTAL" : 1, "CLERICAL" : 1, "RESIDENTIAL" : 12, "COMMERCIAL" : 6},  
        "growthRate" : 500,  
        "availableBuildings" : ["Marketplace", "House", "SimpleChurch", "Testbuilding", "Townhall"],  
        "residentialZones" : ["RESIDENTIAL"]  
    }  
}

Districts

They encompass a certain area in which only buildings of a white-listed zones are able to spawn.
It also features a color for the minimap overlay to visualize where the district is.
The examples in the tutorial module give a sufficient idea on how they look:

{
    "DistrictType" : {
        "name" : "residential",
        "color" : 435324,
        "zones" : ["RESIDENTIAL"]
    }
}

Buildings

Buildings can be the most complex prefabs currently. They can contain a a list of templates and generators at the same time. Also the min / max sizes for the (x, z) coordinates have to be added (in north-south orientation).

The zone tells the system what type the building is and in what districts it fits. This also matches with the buildingNeedPerZone field in the culture and thus determines the demand for this building.

To unlock more advanced features, set the isEntity field to true. This will enable the system to send an event on it's spawn, hence you can retrieve all additional components. Here a MarketSubscriberComponent is added, which gets linked to the settlement inventory upon catching the spawn-event.

{
    "GenericBuilding" : {
     "name" : "blacksmith",
     "templateNames" : ["TutorialDynamicCity:smithyTemplate"],
     "zone" : "COMMERCIAL",
     "minSize" : [14, 14],
     "maxSize" : [17, 17],
     "isEntity" : true
    },
    "MarketSubscriber" : {
     "production" : {"StructuralResources:Barrel" : 2},
     "productionInterval" : 500,
     "consumption" : {"Core:plank" : 16},
     "consumptionInterval" : 500
    }
}