2D Engine v0.1.0
Loading...
Searching...
No Matches
Scene Struct Reference

Scene object to hold all entities and components. More...

#include <Scene.hpp>

Collaboration diagram for Scene:
Collaboration graph

Classes

struct  EntityDesc
 Entity Description. More...
 

Public Member Functions

EntityID NewEntity ()
 Construct a new Entity object.
 
template<typename T >
T * Assign (EntityID id)
 Assign a component to an entity.
 
template<typename T >
T * Get (EntityID id)
 Get the component object from an entity.
 
template<typename T >
void Remove (EntityID id)
 Remove a component from an entity.
 
void DestroyEntity (EntityID id)
 Destroy an entity.
 
void CreateSpriteSheetTile (int x, int y, b2World *physicsWorld, Board *board)
 Create a new SpriteSheet entity.
 
void AddBox2DCollider (EntityID entityID, bool isStatic, bool isTrigger, float x, float y, float width, float height, b2World *physicsWorld)
 Add a Box2D collider to an entity.
 
template<class T >
int GetId ()
 
EntityID CreateEntityId (EntityIndex index, EntityVersion version)
 
EntityIndex GetEntityIndex (EntityID id)
 
EntityVersion GetEntityVersion (EntityID id)
 
bool IsEntityValid (EntityID id)
 

Public Attributes

std::vector< EntityDescentities
 
std::vector< ComponentPool * > componentPools
 
std::vector< EntityIndexfreeEntities
 
bool m_showGrid = true
 
bool m_showColliders = true
 
EntityID m_selectedEntity = -1
 

Detailed Description

Scene object to hold all entities and components.

Member Function Documentation

◆ AddBox2DCollider()

void Scene::AddBox2DCollider ( EntityID entityID,
bool isStatic,
bool isTrigger,
float x,
float y,
float width,
float height,
b2World * physicsWorld )

Add a Box2D collider to an entity.

Parameters
entityID
isStatic
x
y
physicsWorld

◆ Assign()

template<typename T >
template Box2DColliderComponent * Scene::Assign< Box2DColliderComponent > ( EntityID id)

Assign a component to an entity.

Template Parameters
TComponent
Parameters
idEntity ID
Returns
T* Pointer to the component

◆ CreateEntityId()

EntityID Scene::CreateEntityId ( EntityIndex index,
EntityVersion version )

◆ CreateSpriteSheetTile()

void Scene::CreateSpriteSheetTile ( int x,
int y,
b2World * physicsWorld,
Board * board )

Create a new SpriteSheet entity.

Parameters
x
y
sheetLocal
physicsWorld

◆ DestroyEntity()

void Scene::DestroyEntity ( EntityID id)

Destroy an entity.

Parameters
idEntity ID

◆ Get()

template<typename T >
template Box2DColliderComponent * Scene::Get< Box2DColliderComponent > ( EntityID id)

Get the component object from an entity.

Template Parameters
TComponent
Parameters
idEntity ID
Returns
T* Pointer to the component

◆ GetEntityIndex()

EntityIndex Scene::GetEntityIndex ( EntityID id)

◆ GetEntityVersion()

EntityVersion Scene::GetEntityVersion ( EntityID id)

◆ GetId()

template<class T >
int Scene::GetId ( )

◆ IsEntityValid()

bool Scene::IsEntityValid ( EntityID id)

◆ NewEntity()

EntityID Scene::NewEntity ( )

Construct a new Entity object.

Returns
EntityID

◆ Remove()

template<typename T >
template void Scene::Remove< Box2DColliderComponent > ( EntityID id)

Remove a component from an entity.

Template Parameters
TComponent
Parameters
idEntity ID

Member Data Documentation

◆ componentPools

std::vector<ComponentPool *> Scene::componentPools

◆ entities

std::vector<EntityDesc> Scene::entities

◆ freeEntities

std::vector<EntityIndex> Scene::freeEntities

◆ m_selectedEntity

EntityID Scene::m_selectedEntity = -1

◆ m_showColliders

bool Scene::m_showColliders = true

◆ m_showGrid

bool Scene::m_showGrid = true

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