DEFAULT TEMPLATES
The easiest way to plug in an instrument or switch using Model Behaviors is to use one or more existing template (either the from the default ones or from the templates that you yourself have previously created). In the bast case scenario, that means that you could implement your yoke with only the following code in the XML file:
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
</UseTemplate>
This will call the code defined in the following template that contains all the required logic to implement the Yoke:
<MSFS_Packages>\Official\OneStore\fs-base-aircraft-common\ModelBehaviorDefs\Asobo\Common\Handling.xml
That template contains a call to another template called ASOBO_HANDLING_Yoke_SubTemplate
, which defines a number of default parameters:
<Template Name="ASOBO_HANDLING_Yoke_SubTemplate">
<Parameters Type="Default">
<Condition Check="CREATE_TWO_NODES">
<True>
<NODE_ID>HANDLING_Yoke_1</NODE_ID>
<NODE_ID2>HANDLING_Yoke_2</NODE_ID2>
</True>
<False>
<NODE_ID>HANDLING_Yoke_#ID#</NODE_ID>
</False>
</Condition>
<ANIM_NAME_YOKE_X>HANDLING_YOKE_Lever_StickLR</ANIM_NAME_YOKE_X>
<ANIM_NAME_YOKE_Y>HANDLING_YOKE_Lever_StickForeAft</ANIM_NAME_YOKE_Y>
<!-- Ignoring some code for clarity -->
</Parameters>
<!-- Ignoring some code for clarity -->
</Template>
In the example above, the default parameters are not overridden because the animation name and node ID defined by the artists match the values that are being defined by default.
NOTE: Default parameters are defined inside of the <Parameters Type="Default">
tags. Previously the templates used <DefaultTempateParameters>
however this has been depricated, and <Parameters Type="Default">
should be used as they can be chained multiple times in a row, while <DefaultTemplateParameters>
can only be used once by template/component.
If the animations and/or nodes are not named the same as the default parameters, then they can be overridden by setting their values Inside of the <UseTemplate>
tag, for example:
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<ANIM_NAME_YOKE_X>Yoke_Anim_LR</ANIM_NAME_YOKE_X>
<ANIM_NAME_YOKE_Y>Yoke_Anim_UD</ANIM_NAME_YOKE_Y>
<NODE_ID>Yoke</NODE_ID>
</UseTemplate>
The default parameters of this template also contain a <Condition>
tag, which allows the template to have different behaviors depending on the value of a parameter. Here this is used to define an extra NODE_ID
- if the yokes are in separate nodes, but it can also be used inside of the logic of the template itself. The ASOBO_HANDLING_Yoke_SubTemplate
template then uses the same condition in its logic to define an extra component when this condition is true:
<Condition Check="CREATE_TWO_NODES">
<UseTemplate Name="ASOBO_GT_ComponentWith_PART_ID">
<NODE_ID>#NODE_ID2#</NODE_ID>
</UseTemplate>
</Condition>
This <Condition>
can then be triggered by setting <CREATE_TWO_NODES>
as follows:
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<CREATE_TWO_NODES>True</CREATE_TWO_NODES>
</UseTemplate>
It is also important to note that all the parameters defined are inherited:
<Component ID="MyParentComponent">
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<!-- <CREATE_TWO_NODES> is not defined here -->
</UseTemplate>
<Component ID="MyComponent">
<Parameters Type="Default">
<CREATE_TWO_NODES>True</CREATE_TWO_NODES>
</Parameters>
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<!-- <CREATE_TWO_NODES> is True here -->
</UseTemplate>
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<!-- <CREATE_TWO_NODES> is True here -->
</UseTemplate>
<Component ID="MyFirstChildComponent">
<Parameters Type="Override">
<CREATE_TWO_NODES>False</CREATE_TWO_NODES>
</Parameters>
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<!-- <CREATE_TWO_NODES> is False here -->
</UseTemplate>
</Component>
<Component ID="MySecondChildComponent">
<Parameters Type="Default">
<!-- This does not override CREATE_TWO_NODES as it is already defined and
we are inside of a Parameters Type="Default" tag. -->
<CREATE_TWO_NODES>False</CREATE_TWO_NODES>
</Parameters>
<UseTemplate Name="ASOBO_HANDLING_Yoke_Template">
<!-- <CREATE_TWO_NODES> is True here. -->
</UseTemplate>
</Component>
</Component>
</Component>
Note that, once defined, a parameter cannot be "undefined". It can only be overridden by giving it a new value inside a <Parameters Type="Override">
, or directly inside of a <UseTemplate>
tag.
As a rule of thumb, when using the default templates, you should try to avoid using templates that include "Subtemplates" in their names, as those are meant to be called by going though another template. They can be called directly, but doing so will often mean that you are missing some default parameters that would have been set by that template, which can cause the template not to work. In addition, you should note that templates stored in the Generic subfolder are generally building blocks templates that are meant to be used to create other templates. They do not implement any specific instrument on their own.