Part 3: Buildings and resources

GetResource(int inResourceID, out uint outAmount)

This method returns the amount of the specified resource currently stored in warehouses or the buildings that produce it. The resource ID is a unique identifier whose value if determined using the IDMaker.FromString method. This can be useful as a trigger, for example to unlock a building. Example use:

    Int32 mDataIDOlives = IDMaker.FromString("c4cr Olives");
    game.GetResource(mDataIDOlives, out nOlives);

This will tell you how many olives are currently stored in the city (as reported by the Resource Advisor), as the variable nOlives. Note that the input string you need to give to IDMaker.FromString is generally of the form "c4cr <RESOURCE>" where <RESOURCE> is the name of the resource you want to count, such as iron, weapons, timber, silphium, wool, and so on.

GetActiveBuildings(int inBuildingID, out uint outAmount)

This method returns, as the variable outAmount, the number of active buildings of the specified type. To use this you need the unique ID for that building, which is obtained through a call to the IDMaker.FromString method. To find the building ID, you need to know the input string to provide: you can find a list of these in Part 10. In the following example use, we want to count the number of active (i.e. not mothballed) medium domi:

    uint nMedDomi = 0;
    Int32 mIDDomus2 = IDMaker.FromString("C4b Equites Housing 02");
    game.GetActiveBuildings(mIDDomus, out nMedDomi);

Note that whereas for most buildings it will be counted as active if not mothballed, this is not always the case. For example, the theater, arena, coliseum and circus do not count as active if they are waiting for performers to arrive. Patrician villas are not counted as active if they are not being taxed. Similarly, markets are not counted as active if they are not taxed, even if they are fully staffed.

GetInactiveBuildings(int inBuildingID, out uint outAmount)

This method returns the number of inactive buildings of the specified type, as indicated by the ID returned by the IDMaker.FromString method. See the note above regarding what counts as an "inactive" building. Its usage is otherwise as described for the GetActiveBuildings method above.

GetTotalBuildings(int inBuildingID, out uint outAmount)

This method returns the total number of buildings of the specified type in the variable outAmount, whether active or inactive. Its usage is otherwise as described for the GetActiveBuildings method above.

GetBuildingsCollapsing(out bool outCollapsing)

This method returns the variable outCollapsing flag as TRUE if there are any buildings that are about to collapse.

GetBuildingsOnFire(out bool outOnFire)

This method returns the variable outOnFire flag as TRUE if there are currently any buildings on fire. From testing, it appears that the game counts a building as being "on fire" if the Risks overlay shows a fire risk, rather than any fire being visible when viewed normally.

GetBuildingsPlagued(out bool outPlagued)

This method has not been tested as such, but the returned flag outPlagued is believed to be set TRUE if plague is currently affecting any buildings.

GetFigures(out bool outOnMap)

This method returns the variable outOnMap flag as TRUE if there are any people on the map - whether traders, or people immigrating, emigrating, wandering around or staying at home doing nothing.

< Previous: City ratings and other stats | Editor Guide | Next: UI Controls >