LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
EntityManager Class Reference

Handles the Entities in the active state. More...

#include <entitymanager.h>

Inherited by EntityEditor.

Public Member Functions

virtual void Draw ()
 Draw the entities.
 
virtual void Update ()
 Update the objects.
 
virtual void Move (float deltaT)
 
void SetCollisionMaps (Map *map)
 
void Register (std::shared_ptr< Entity > obj)
 
void Register (std::shared_ptr< Camera > camera)
 
void Remove (std::shared_ptr< Entity > entity)
 
std::shared_ptr< EntityGetEntity (const std::string &name)
 
virtual void CheckMouseEvents ()
 
virtual void HandleMouseEvent (const SDL_MouseButtonEvent &mouseEvent)
 
virtual void HandleMouseEvent (const SDL_MouseMotionEvent &mouseEvent)
 
Json::Value Save ()
 
void PrintSharedPtrCount ()
 

Protected Attributes

EntityList mEntities
 The list of entities in the scene.
 
std::shared_ptr< CameramCamera
 

Detailed Description

Handles the Entities in the active state.

A class to simplify handling of the Entities, and simple collision interactions between them

Member Function Documentation

void EntityManager::CheckMouseEvents ( )
virtual

Testing the new method for mouse handling

std::shared_ptr< Entity > EntityManager::GetEntity ( const std::string &  name)

Get an Entity by its name

Parameters
nameThe name to lookup
Returns
A shared_ptr to the entity, nullptr if lookup failed
void EntityManager::HandleMouseEvent ( const SDL_MouseButtonEvent &  mouseEvent)
virtual

Handle mouse clicks, run through the active entities find which was clicked, and call its response function

Parameters
mouseEventThe mouse event that we're processing

Reimplemented in EntityEditor.

void EntityManager::HandleMouseEvent ( const SDL_MouseMotionEvent &  mouseEvent)
virtual

Handle Mouse motion, check if the mouse entered/exited an Entity

Parameters
mouseEventThe mouse event that we're processing
void EntityManager::Move ( float  deltaT)
virtual

Move the entities

Parameters
deltaTThe time elapsed
void EntityManager::Register ( std::shared_ptr< Entity obj)

Register an Entity to be managed by the manager

Parameters
objThe Entity to register
void EntityManager::Register ( std::shared_ptr< Camera camera)

Register the scene camera with the manager so that it can be used in checking which objects to deal with

Parameters
cameraThe scene camera
void EntityManager::Remove ( std::shared_ptr< Entity entity)

Remove an Entity with the shared_ptr passed

Parameters
entityThe shared_ptr of the Entity to remove
Json::Value EntityManager::Save ( )

Serialize all the game object data to a Json::Value and return it

Returns
Json::Value containing the gameobject data
void EntityManager::SetCollisionMaps ( Map map)

Setup Entity collision maps

Parameters
mapThe map to get the collision maps from

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