Struct Entity
Entity structure.
This is the combination of two 32-bits id: a unique-id and a version-id.
Constructors
Name | Description |
---|---|
this
|
Properties
Name | Type | Description |
---|---|---|
component
[get]
|
C* |
Get a component pointer of the entity. |
component
[set]
|
C |
Set the value of a component of the entity. |
id
[get]
|
Entity |
Returns the id of the entity. |
valid
[get]
|
bool |
Tells whether the entity is valid. |
Methods
Name | Description |
---|---|
destroy
|
Destroy the entity (unregister all attached components). |
invalidate
|
Invalidate the entity instance (but does not destroy it). |
isRegistered
|
Tell whether a component is registered to the entity. |
iterate
|
Iterate over the components registered to the entity. It calls the accessor delegate that has been set to each component. |
opEquals
|
Compare two entities and tells whether they are the same (same id). |
register
|
Register a component C to an entity. |
toString
|
Returns a string representation of an entity. |
unregister
|
Unregister a component C from an entity. |
Inner structs
Name | Description |
---|---|
Id
|
Example
@component struct Position
{
float x, y;
}
auto em = new EntityManager(new EventManager);
auto entity = em .create();
auto posCompPtr = entity .register!Position(2.0, 3.0);
assert(posCompPtr == entity .component!Position);
assert(posCompPtr .x == 2.0);
assert(entity .component!Position .y == 3.0);
Authors
Claude Merle
Copyright
© 2015-2016 Claude Merle
License
This file is part of EntitySysD.
EntitySysD is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
EntitySysD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License along with EntitySysD. If not, see http://www.gnu.org/licenses/.