SpinTires XML files Inheritance

SpinTires XML files Inheritance
XML files Spintires no different from ordinary XML files and can be read by any third party software. But SpinTires uses the special rules of reading data from XML files.

Templates


SpinTires XML templates are used to avoid copying. For example, the wheels of the truck are basically identical, however, each described by its own XML node. To prevent copying the attributes in each node, the wheel's template is created in a special file called "_templates":

<_templates>
<Wheel>
<RearWheel
ConnectedToHandbrake="true"
DefaultWheelType="kraz_rear"
HardpointOffsetY="-0.244"
SuspensionMin="-0.4"
SuspensionStrength="0.02"
Torque="default"
/>
</Wheel>
</_templates>
There are global templates with predefined templates. They can be enabled by adding, for example, an attribute ="trucks". All these files are in folder "\Media\_templates".
Each wheel uses this template (an attribute called "_template"):

<Wheel _template="RearWheel" HardpointX="-0.49" />
<Wheel _template="RearWheel" HardpointX="-0.49" RightSide="true" />
<Wheel _template="RearWheel" HardpointX="-1.93" />
<Wheel _template="RearWheel" HardpointX="-1.93" RightSide="true" />
XML branch may use only those templates that are described as a child of node node with the same name. Remember that the wheels use template "RearWheel", which is a child of node of the branch Wheel in the section "_templates".
Thus, it appears almost the same as copying all attributes in each individual XML node. The node that uses the template can override any attribute of a particular template. The node's hierarchy, as well as the hierarchy of attributes is copied by the system template.

Inheritance


SpinTires XML file can inherit from another file:

<_parent File="kamaz6520" />

This is approximately the same as the global template for the entire file. It turns out that all the attributes and nodes are loaded from the file "kamaz6520.xml" then the attributes and branches from the current file (if they are there) are merged at the top (overridden).

This, for example, facilitates the support of different trucks, which are slightly different from each other. Inheritance also affects the behavior of the model directly in the game:

  • All Steam game achievements work with all inherited trucks. If truck B has a row

    <_parent, File="A" />

    The player can get all the same achievements on the truck B, and truck A.
  • SpinTires truck addon requirements and addons exclude work for all included addons. For example, the string

    ExcludeAddons="A"

    also exclude B, if B has a row

    <_parent, File="A" />

    And requirement

    <RequiredAddon Types="A" />

    Also true for B if B has all the same string

    <_parent, File="A" />
  • Inheritance applies to all model properties.

_inheritRemove


If the node of inherited XML file contains the string

_inheritRemove="true"

Its properties and attributes will not be copied from the parent file. For example, if your truck mod has 4 wheels instead of 6, you add these 2 extra wheels with a string

_inheritRemove="true"

_noinherit


If the node of inherited XML file contains the string

_noinherit="true"

Then its attributes and child nodes will not be copied from the parent file. For example, if your truck mod has absolutely other wheels, you use "_noinherit" to not to give the parent file to override any settings of the mod.

 Views: 5k