ForgeDocs
Documentation for the forge framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Forge.Entities.ITemplate Interface Reference

Used for creating IEntity instances that have a set of data values already initialized. Templates should not be modified at runtime. More...

Inheritance diagram for Forge.Entities.ITemplate:
Forge.Entities.IQueryableEntity

Public Member Functions

IEntity Instantiate ()
 Instantiates the template to create a new IEntity instance. The IEntity is automatically registered with the IGameEngine that owns this template reference. The spawned IEntity will be added to systems on the next update call. The returned entity can be freely modified; modifications can be viewed as pre-initialization. More...
 
void AddDefaultData (Data.IData data)
 Adds a default data instance to the template. The template "owns" the passed data instance; a copy is not made of it. More...
 
bool RemoveDefaultData (DataAccessor accessor)
 Remove the given type of data from the template instance. New instances will not longer have this added to the template. More...
 
- Public Member Functions inherited from Forge.Entities.IQueryableEntity
ICollection< DataAccessorSelectData (bool includeRemoved=false, Predicate< DataAccessor > filter=null, ICollection< DataAccessor > storage=null)
 Selects data inside of the entity that passes the given filter. More...
 
Data.IData Current (DataAccessor accessor)
 Gets the current data value for the given type. More...
 
Data.IVersioned Previous (DataAccessor accessor)
 Gets the previous data value for the data type. More...
 
bool ContainsData (DataAccessor accessor)
 Checks to see if this Entity contains an instance of the given data type. Keep in mind that an IQueryableEntity contains data one frame after it has been removed; both ContainsData(accessor) and WasRemoved(accessor) can return true. More...
 

Properties

int TemplateId [get]
 Each ITemplate can be uniquely identified by its TemplateId. More...
 
- Properties inherited from Forge.Entities.IQueryableEntity
string PrettyName [get, set]
 A non-unique string that represents a "human readable" name for the entity. This carries no weight in the simulation, and is only meant for diagnostics. More...
 

Detailed Description

Used for creating IEntity instances that have a set of data values already initialized. Templates should not be modified at runtime.

For example, a generic Orc type will have an ITemplate that defines an Orc. Spawning code will then receive the Orc ITemplate, and when it comes time to spawn it will instantiate an entity from the template, and that entity will be a derivative instance of the original Orc.

Member Function Documentation

void Forge.Entities.ITemplate.AddDefaultData ( Data.IData  data)

Adds a default data instance to the template. The template "owns" the passed data instance; a copy is not made of it.

If the ITemplate is currently being backed by an IGameEngine, this will throw an InvalidOperationException. Templates that are being used in an IGameEngine cannot be modified.

Parameters
dataThe data instance to copy from.
IEntity Forge.Entities.ITemplate.Instantiate ( )

Instantiates the template to create a new IEntity instance. The IEntity is automatically registered with the IGameEngine that owns this template reference. The spawned IEntity will be added to systems on the next update call. The returned entity can be freely modified; modifications can be viewed as pre-initialization.

bool Forge.Entities.ITemplate.RemoveDefaultData ( DataAccessor  accessor)

Remove the given type of data from the template instance. New instances will not longer have this added to the template.

If the ITemplate is currently being backed by an IGameEngine, this will throw an InvalidOperationException.

Parameters
accessorThe type of data to remove.
Returns
True if the data was removed.

Property Documentation

int Forge.Entities.ITemplate.TemplateId
get

Each ITemplate can be uniquely identified by its TemplateId.


The documentation for this interface was generated from the following file: