Class World

Class Documentation

class World

Public Types

enum UpdateType

Values:

Sync
Async

Public Functions

World()

Constructor.

~World()

Destructor.

void SetUpdateType(UpdateType type)
UpdateType GetUpdateType() const
void AddSystem(System *p_system)

Add a new system to the world

void RemoveSystem(System *p_system)

Removes a system from world

void AddEntity(Entity *p_entity)

Adds a new entity to the world

void RemoveEntity(Entity *p_entity)

Removes an entity from world

void Update(float tick)

Updates the world

void _AddToDestroyQueue(Node *node)

internal use Node::Destroy() instead. Add a node to destroy queue

template <typename T>
void subscribe(EventSubscriber<T> *subscriber)

Subscribe to an event.

template <typename T>
void unsubscribe(EventSubscriber<T> *subscriber)

Unsubscribe from an event.

void unsubscribeAll(void *subscriber)

Unsubscribe from all events. Don’t be afraid of the void pointer, just pass in your subscriber as normal.

template <typename T>
void emit(const T &event)

Emit an event. This will do nothing if there are no subscribers for the event type.

const tinystl::vector<Entity *> &GetAllEntities() const
ftl::TaskScheduler *GetTaskScheduler() const

Protected Functions

void CheckDestroyQueue()

Protected Attributes

std::unordered_map<TypeIndex, tinystl::vector<Internal::BaseEventSubscriber *>> subscribers
bx::SpScUnboundedQueueT<Node> m_qDestroyQueue
tinystl::vector<System *> systems
tinystl::vector<Entity *> Entities
ftl::TaskScheduler *m_pTaskScheduler
UpdateType m_UpdateType