Changes between Initial Version and Version 1 of Entity


Ignore:
Timestamp:
Jun 27, 2012, 5:28:58 AM (12 years ago)
Author:
historic_bruno
Comment:

Initial draft

Legend:

Unmodified
Added
Removed
Modified
  • Entity

    v1 v1  
     1An "entity" in 0 A.D.'s terminology is the internal representation of a game object. It could be a unit, structure, tree, or even a decorative [wiki:Actors actor] like a clump of grass. A map contains a number of these entities which describe the world as the players perceive it. They are also created during the game when a player trains a new unit or constructs a building, they are similarly destroyed when a unit or structure is destroyed. For an entity to be visible in the game, it must have a [wiki:Actors visual actor] associated with it.
     2
     3For more information on how entities fit into the game's architecture, see SimulationArchitecture.
     4
     5== Entity templates ==
     6
     7Many but not all entities are defined by entity ''templates'', located in `simulation\entities\` (see [wiki:Mod_Layout#templates mod layout]). An entity template is an XML data file which defines how the entity behaves, how it appears, its internal state, and how other entities may interact with it. This data is associated with [wiki:TDD_Simulation simulation] components (see [http://svn.wildfiregames.com/entity-docs/ this page] for component examples).
     8
     9Entity templates use inheritance, which allows different types of units to inherit common attributes from a parent. For example, a Roman Veles inherits from a common "ranged infantry javelinist" template, which inherits from a common "ranged infantry" template, and so on. This inheritance helps prevent duplication of the same data in numerous places.
     10
     11== Modifying entities ==
     12
     13Entities can be viewed in-game or for testing purposes, using Atlas' [wiki:Atlas_Manual_Object_Tab#TheActorViewer actor viewer] in entity mode. Currently there is no special editor for entity templates (as there is for actors), so it's best to use a decent text editor like Notepad++ on Windows.
     14
     15== Entity XML format ==
     16
     17The following is an example of an entity template XML file:
     18
     19{{{
     20#!xml
     21<?xml version="1.0" encoding="utf-8"?>
     22<Entity parent="template_unit">
     23  <Cost>
     24    <BuildTime>15</BuildTime>
     25  </Cost>
     26  <Health>
     27    <RegenRate>0.2</RegenRate>
     28  </Health>
     29  <Identity>
     30    <GenericName>Support</GenericName>
     31    <Classes datatype="tokens">Support Organic</Classes>
     32  </Identity>
     33  <Loot>
     34    <xp>10</xp>
     35    <food>1</food>
     36    <wood>1</wood>
     37    <stone>1</stone>
     38    <metal>1</metal>
     39  </Loot>
     40  <Minimap>
     41    <Type>support</Type>
     42  </Minimap>
     43  <Sound>
     44    <SoundGroups>
     45      <trained>interface/alarm/alarm_create_worker.xml</trained>
     46    </SoundGroups>
     47  </Sound>
     48  <UnitAI>
     49    <DefaultStance>passive</DefaultStance>
     50  </UnitAI>
     51</Entity>
     52}}}
     53
     54It can be seen that this template inherits from "template_unit" (and all of its parents, too).
     55
     56Entity templates must comply with the [http://relaxng.org/ schema] or they won't validate, causing an error when trying to use the entity in-game or Atlas. Each component adds to the schema those elements which it allows to be specified in the template, as documented [http://svn.wildfiregames.com/entity-docs/ here].. An element may be required or optional, it may have attributes or not; and its data may be restricted in type, limited to a set of predefined choices, or it may allow arbitrary text. Typical reasons for a template not validating include: leaving out required elements, adding elements that don't exist, misspellings, or using an incorrect data type (a decimal or negative number in a field that requires a positive integer).