Templates explanation

From Divinity Engine Wiki
Revision as of 16:24, 28 July 2017 by LarSeb (talk | contribs) (Created page with "=== Root template === Root templates are the building blocks of our game. A root template can be an item, a character, a trigger, etc. A root template describes a game object...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Root template

Root templates are the building blocks of our game. A root template can be an item, a character, a trigger, etc.

A root template describes a game object. It contains the data of a thing necessary to put that thing in the game. (For instance: its visual, the physics, the AI bounds, name, stats, scripts, etc. All these properties describe and make up the game object.)

A root template is set up so that it defines the default visual and default behaviour of the game object. This means that a root template contains important gameplay information.

For our interactive, reactive, systemic game to work correctly, we need roots and they must be carefully set up.


Army Men game has 2 roots: ArmyMan and Tank. Thanks art team!


Local instances

You never really place a root in the game. You place a reference to the root in the game. Roots really exist on another plane outside of the game.

The game merely contains links to the root. When you drag a root into the game, it creates a local instance of the root at that spot. You could say local instances are children of their parent (the root).


Army Men game has 2 local instances in-game that refer to the root ArmyMan.


A local instance can live without data. It just refers to the root and it will get its data there.

However, if the root is deleted, the link is broken and the local instance will no longer be able to show anything. (This is why you get asserts if roots are deleted when they’re used by local instances.)


Inheritance

If you are an artist, think of a root template as a magical mold or a magical pattern: when you update the mold, everything you ever made with it updates too!

If you are a programmer, think of a root template as a class.

Every time a root template is updated, all its local instances inherit the updates automatically.


“Green?! NO! All ArmyMan must be red!” The Root ArmyMan was updated with the colour RED. All its instances in the game everywhere inherit the colour automatically.

(NOTE: This is just an example of a property. Colour works differently in our game.)


Whew. What a relief. I thought we would have to update all local instances everywhere in the entire game. Thank you root system!


Colorsarmy.jpg