SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::World Class Referenceabstract

World Class. This class defines the basic behaves of World. When we create an new world, we need inherit from this. More...

#include <World.h>

Inheritance diagram for Spices::World:
Spices::EditorWorld Spices::RuntimeWorld Spices::GameEditorWorld Spices::WhittedRTWorld

Public Types

enum  WorldMarkBits {
  Clean = 0x00000001 , MeshAddedToWorld = 0x00000002 , FrushStableFrame = 0x00000004 , NeedUpdateTLAS = 0x00000008 ,
  MAX = 0x7FFFFFFF
}
 
typedef uint32_t WorldMarkFlags
 

Public Member Functions

 World ()=default
 Constructor Function.
 
virtual ~World ()=default
 Destructor Function.
 
virtual void OnPreActivate ()=0
 This interface define the specific world behaves before on activated.
 
virtual void OnActivate (TimeStep &ts)=0
 This interface define the specific world behaves on activated.
 
virtual void OnDeactivate ()=0
 This interface defines the specific world behaves after on activated.
 
Entity CreateEntity (const std::string &name="None")
 Create a new empty entity in this world.
 
Entity CreateEntityWithUUID (UUID uuid, const std::string &name="None")
 Create a new empty entity with a uuid in this world.
 
void DestroyEntity (Entity &entity)
 Destroy a entity from this world.
 
entt::registry & GetRegistry ()
 Get Registry variable.
 
Entity QueryEntitybyID (uint32_t id)
 Get World Entity by id(entt::entity).
 
WorldMarkFlags GetMarker () const
 Get WorldMarkFlags this frame.
 
void Mark (WorldMarkFlags flags)
 Mark WorldMarkFlags with flags.
 
void ReserMark ()
 Reset WorldMarkFlags to Clean.
 
void ClearMarkerWithBits (WorldMarkFlags flags)
 Clear WorldMarkFlags with flags.
 
template<typename T , typename F >
void ViewComponent (F &&fn)
 View all component in this world.
 
template<typename T , typename F >
void ViewComponent (const std::vector< uint32_t > &ranges, F &&fn)
 View all component in this world in ranges.
 
template<typename T , typename F >
void ViewComponent (const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F &&fn)
 View all component in this world in ranges.
 
template<typename F >
void ViewRoot (F &&fn)
 View all root in this world.
 
template<typename T , typename... Args>
T & AddComponent (entt::entity e, Args &&... args)
 Template Function. Used for add specific component to entity.
 
template<typename T >
T & GetComponent (entt::entity e)
 Get Component owned by this entity.
 
template<typename T >
void RemoveComponent (entt::entity e)
 Remove Component owned from this entity.
 
template<typename T >
bool HasComponent (entt::entity e)
 If Component is owned by this entity or not.
 
void RemoveFromRoot (Entity &entity)
 Remove a entity from this world root.
 
void AddToRoot (Entity &entity)
 Add a entity to this world root.
 
bool IsRootEntity (Entity &entity)
 Determine if a entity is in root.
 

Protected Attributes

std::shared_mutex m_Mutex
 Mutex for world.
 
entt::registry m_Registry
 This variable handles all entity.
 
std::unordered_map< UUID, entt::entity > m_RootEntityMap
 This variable is a cache. @noto Not in use now.
 
WorldMarkFlags m_Marker = WorldMarkBits::Clean
 World State this frame.
 

Private Member Functions

Entity CreateEmptyEntity (UUID uuid)
 
template<typename T >
void OnComponentAdded (Entity *entity, T &component)
 Called On any Component Added to this world.
 

Friends

class Entity
 
class WorldFunctions
 

Detailed Description

World Class. This class defines the basic behaves of World. When we create an new world, we need inherit from this.

Definition at line 40 of file World.h.


The documentation for this class was generated from the following files: