In April 2016, leper wrote a patch in #2951 to replace hardcoded template modifications in the TemplateManager with XML files.
This has the advantage that developers that are not familiar with the TemplateManager C++ code or not eager to change that code can
write a new special template, even without compiling anything.
These special templates allow changing a common (unit or structure) template by the values that are defined in the special template.
- "actor|" + template means that this simulation template will have all its components stripped (thus becomes a ghost).
- "foundation|" + template means that the TemplateLoader will construct a template that will appear as a foundation, i.e. 1 health, doesn't block obstructions and no vision range.
- "construction|" + template yields a construction site, i.e. removes almost all properties except the position and model (which rises when building).
This feature is very important for adding new gameplay mechanics and every month we stumble upon some feature or issue that could have been solved with one these special templates.
For example the gamesetup option to disable garrisoning of heroes in Regicide gamemode is intending to use this: D104.
Another example might be disabling of the Capture component when we don't want a gaia settlement to be taken over by player territory: D204.
Or marking a unit as invincible, like the treasure seaker woman on survival.
While these things could all be changed from trigger scripts accessing the simulation components, the Petra bot doesn't know about simulation component changes, unless
those deltas are sent through the GUIInterface (which is annoying to keep in sync each feature changed and also bad for performance).
A disadvantage of using templates and not using the simulation component is that we can't change the property dynamically in running games.
Regardless, that C++ code needs to vanish and we should have been able to use this feature months ago already.
This patch encompasses lepers two diffs uploaded in #2951 and a bugfix and rebases of mine.
Excluded are the contested string/newline changes in the test files and the change to not test the simulation if the public mod isn't available by me in August 2016 at |#2951#comment:13.
In order to not add the duplicate files required for the test (that have to be updated each time one changes the component schema), Itms has planned something and I'm sure he will be happy if he doesn't have to rebase, review and include this diff in his proposal.
The diff proposed here can be reviewed as individual commits in this github branch:
The old branch with the contested, now dropped commits is still available at: