#include <scene.h>
Public Types | |
using | EntityByIDMap = std::unordered_map< std::string, std::unique_ptr< EntityInstance > > |
using | EntityIterator = utility::UniquePtrMapWrapper< EntityByIDMap, EntityInstance * > |
using | RootEntityList = std::vector< RootEntity > |
using | InstanceByIDMap = std::unordered_map< std::string, rtti::Object * > |
using | SortedComponentInstanceList = std::vector< ComponentInstance * > |
using | SpawnedComponentInstanceMap = std::unordered_map< EntityInstance *, SortedComponentInstanceList > |
Public Member Functions | |
Scene (Core &core) | |
virtual | ~Scene () override |
virtual bool | init (utility::ErrorState &errorState) override |
virtual void | onDestroy () override |
void | update (double deltaTime) |
SpawnedEntityInstance | spawn (const Entity &entity, utility::ErrorState &errorState) |
SpawnedEntityInstance | spawn (const Entity &entity, const std::vector< ComponentInstanceProperties > &instanceProperties, utility::ErrorState &errorState) |
void | destroy (SpawnedEntityInstance &entity) |
void | updateTransforms (double deltaTime) |
EntityIterator | getEntities () |
const rtti::ObjectPtr< EntityInstance > | findEntity (const std::string &inID) const |
const EntityInstance & | getRootEntity () const |
EntityInstance & | getRootEntity () |
RootEntityList | getEntityResources () |
RootEntityList & | getEntityResourcesRef () |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Public Attributes | |
RootEntityList | mEntities |
List of root entities owned by the Scene. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
Container for entities. The Scene is responsible for instantiation and management of all contained entities.
using EntityByIDMap = std::unordered_map<std::string, std::unique_ptr<EntityInstance> > |
using InstanceByIDMap = std::unordered_map<std::string, rtti::Object*> |
using RootEntityList = std::vector<RootEntity> |
using SortedComponentInstanceList = std::vector<ComponentInstance*> |
using SpawnedComponentInstanceMap = std::unordered_map<EntityInstance*, SortedComponentInstanceList> |
|
overridevirtual |
void destroy | ( | SpawnedEntityInstance & | entity | ) |
const rtti::ObjectPtr<EntityInstance> findEntity | ( | const std::string & | inID | ) | const |
Locate an entity in this scene with the given unique id. Note that the given id needs to match the id of an entity resource, not instance.
Example:
inID | the unique id of the entity to find. |
EntityIterator getEntities | ( | ) |
RootEntityList getEntityResources | ( | ) |
RootEntityList& getEntityResourcesRef | ( | ) |
EntityInstance& getRootEntity | ( | ) |
const EntityInstance& getRootEntity | ( | ) | const |
|
overridevirtual |
Initialize the scene. Will spawn all entities contained in this scene. As soon as this is called, EntityInstances will become available and are accessible through getRootEntity() and getEntities()
Reimplemented from Object.
|
overridevirtual |
Destroy the scene. Will call onDestroy for all ComponentInstances and EntityInstances in the scene.
Reimplemented from Object.
SpawnedEntityInstance spawn | ( | const Entity & | entity, |
const std::vector< ComponentInstanceProperties > & | instanceProperties, | ||
utility::ErrorState & | errorState | ||
) |
Spawns an entity hierarchy. The Entity (hierarchy) can be destroyed by calling destroy with the value returned from this function.
entity | entity resource to spawn. |
instanceProperties | instance properties to apply to the entity's properties |
errorState | contains error information if the returned object is nullptr. |
SpawnedEntityInstance spawn | ( | const Entity & | entity, |
utility::ErrorState & | errorState | ||
) |
Spawns an entity hierarchy. The Entity (hierarchy) can be destroyed by calling destroy with the value returned from this function.
entity | entity resource to spawn. |
errorState | contains error information if the returned object is nullptr. |
void update | ( | double | deltaTime | ) |
Update all entities contained in this scene
deltaTime | time in seconds between calls. |
void updateTransforms | ( | double | deltaTime | ) |
Update the transform hierarchy of the entities contained in this scene. For any TransformComponent the world transform is updated.
deltaTime | time in seconds in between calls. |
RootEntityList mEntities |
List of root entities owned by the Scene.