When a data-, entity- or datalist resource requires another resource that has not yet been loaded the resource manager will load the required resource automatically. For this to work a resource that is required by another resource is referenced by it’s ID in the requesting resource by placing it into XML tags that end with an uppercase string ID. Because of this the name of property XML tags inside data resource files may only end with ID to mark a property that contains an ID to a referenced resource.
Sounds confusing enough? OK! What it all means is that if you write an XML tag with an uppercase ‘ID’ at the end of it’s name, that tag is recognized as containing a string which is an ID which references to another resource.
If the referenced resource is a text- or datalist resource the referring ID needs to be made up of two parts: first the ID of the text resource or the datalist resource and second the ID of the actual string as defined in the text resource file or the ID of the item in the datalist. These two parts need to be divided by a slash character ‘/’. To better understand this have a look at the structure of this example “infantry unit” entity definition:
<?xml version="1.0" encoding="UTF-8"?> <data> <entity id="unitInfantry"> <components> <component classID="tbsUnitPropertiesComponent"> <nameID>textUnits/nameInfantryUnit</nameID> <descriptionID>textUnits/descInfantryUnit</descriptionID> <movementTypeID>movementTypes/movementTypeInfantry</movementTypeID> <price>1000</price> </component> </components> </entity> </data>
… the component properties nameID and descriptionID are referencing to an ID of a text string nameInfantryUnit and descInfantryUnit which are both located in the text resource with ID textUnits. The movementTypeID property contains a referenced ID to a lookup-table datalist item with ID movementTypeInfantry in the datalist resource with ID movementTypes.
If a resource is already loaded and is then requested by a referencing resource, the resource is not loaded again but it’s refCount is increased.