Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
ObjectManager Class Reference

#include <objectmanager.hpp>

Public Member Functions

 ObjectManager ()
 
 ~ObjectManager ()
 
SpecificID createObject (Object *object)
 Creates a new object with the specified type. More...
 
bool removeObject (EntityID globalID)
 Attempts to remove an object with the given EntityID. More...
 
bool removeObject (Object **object_dbl_ptr)
 Attempts to remove an object pointed to by the pointer pointed to by the given Object double pointer. If successful, it will set the given Object pointer to nullptr. (use to avoid dangling Object pointers) More...
 
bool replaceObject (EntityID globalID, Object *object)
 Replaces the object with the given EntityID with the given Object, if there currently exists an object with the given EntityID. The original object is deleted. More...
 
ObjectgetObject (EntityID globalID)
 Attempts to retrieve the object with the given EntityID. More...
 
ObjectgetBaseObject (SpecificID base_objectID)
 Attempts to retrieve the Object with the given SpecificID. More...
 
ItemgetItem (SpecificID itemID)
 Attempts to retrieve the Item with the given SpecificID. More...
 
SolidSurfacegetSolidSurface (SpecificID surfaceID)
 Attempts to retrieve the SolidSurface with the given SpecificID. More...
 
PlayergetPlayer (SpecificID playerID)
 Attempts to retrieve the Player with the given SpecificID. More...
 
DungeonMastergetDM ()
 Get the Dungeon Master pointer. More...
 
EnemygetEnemy (SpecificID enemyID)
 Attempts to retrieve the Enemy with the given SpecificID. More...
 
TorchlightgetTorchlight (SpecificID torchlightID)
 Attempts to retrieve the Torchlight with the given SpecificID. More...
 
TrapgetTrap (SpecificID trapID)
 Attempts to retrieve the Trap with the given SpecificID. More...
 
SmartVector< Object * > getObjects ()
 Get a list of all objects in this game instance at the current timestep. More...
 
SmartVector< Object * > getMovableObjects ()
 Get a list of all objects in this game instance at the current timestep that are MOVABLE. More...
 
SmartVector< Item * > getItems ()
 Get a list of all items in this game instance at the current timestep. More...
 
SmartVector< SolidSurface * > getSolidSurfaces ()
 Get a list of all SolidSurfaces in this game instance at the current timestep. More...
 
SmartVector< Player * > getPlayers ()
 Get a list of all Players in this game instance at the current timestep. More...
 
SmartVector< Enemy * > getEnemies ()
 Get a list of all Enemies in this game instance at the current timestep. More...
 
SmartVector< Trap * > getTraps ()
 Get a list of all Traps in this game instance at the current timestep. More...
 
SmartVector< Projectile * > getProjectiles ()
 Get a list of all Projectiles in this game instance at the current timestep. More...
 
SmartVector< Torchlight * > getTorchlights ()
 Get a list of all Projectiles in this game instance at the current timestep. More...
 
SmartVector< WeaponCollider * > getWeaponColliders ()
 Get a list of all WeaponCollider in this game instance at the current timestep. More...
 
SmartVector< Exit * > getExits ()
 Get a list of all Exits in this game instance at the current timestep. More...
 
bool moveObject (Object *object, glm::vec3 newCornerPosition)
 Attempts to move the given Object to the given corner position, updating its GridCell position vector and the cellToObjects hashmap. More...
 
std::vector< glm::ivec2 > objectGridCells (Object *object)
 Given an object, his function will return a vector of positions of GridCells that are currently occupied by this object. More...
 
std::vector< boost::optional< SharedObject > > toShared ()
 Generates a list of SharedObjects that corresponds to all objects in the game instance. More...
 

Data Fields

std::unordered_map< glm::ivec2, std::vector< Object * > > cellToObjects
 Hashmap that maps GridCell (x, y) positions to a vector of Objects that occupy / overlap that GridCell. More...
 

Constructor & Destructor Documentation

◆ ObjectManager()

ObjectManager::ObjectManager ( )

◆ ~ObjectManager()

ObjectManager::~ObjectManager ( )

Member Function Documentation

◆ createObject()

SpecificID ObjectManager::createObject ( Object object)

Creates a new object with the specified type.

Note
This method assigns a unique global EntityID and a type-specific SpecificID to the newly created object (NOTE: the Object constructor does NOT do this!)
this is a public wrapper for the _createObject() method.
Parameters
objectpointer to the newly created object to add to the ObjectManager.
idboost::optional<EntityID> which is by default boost::none. If given a value for a specific EntityID, the new object will be added with the given EntityID. Note that this may
Returns
the SpecificID of the newly created object

◆ getBaseObject()

Object * ObjectManager::getBaseObject ( SpecificID  base_objectID)

Attempts to retrieve the Object with the given SpecificID.

Parameters
base_objectIDSpecificID of the Object to retrieve
Returns
A pointer to the Object with the given SpecificID or nullptr if none exists.

◆ getDM()

DungeonMaster * ObjectManager::getDM ( )

Get the Dungeon Master pointer.

Returns
A pointer to the Dungeon Master

◆ getEnemies()

SmartVector< Enemy * > ObjectManager::getEnemies ( )

Get a list of all Enemies in this game instance at the current timestep.

Returns
SmartVector of Enemy pointers of all Enemy objects in the game instance.

◆ getEnemy()

Enemy * ObjectManager::getEnemy ( SpecificID  enemyID)

Attempts to retrieve the Enemy with the given SpecificID.

Parameters
enemyIDSpecificID of the Enemy to retrieve
Returns
A pointer

◆ getExits()

SmartVector< Exit * > ObjectManager::getExits ( )

Get a list of all Exits in this game instance at the current timestep.

Returns
SmartVector of Exit pointers of all Exit objects in the game instance.

◆ getItem()

Item * ObjectManager::getItem ( SpecificID  itemID)

Attempts to retrieve the Item with the given SpecificID.

Parameters
itemIDSpecificID of the Item to retrieve
Returns
A pointer to the Item with the given SpecificID or nullptr if none exists.

◆ getItems()

SmartVector< Item * > ObjectManager::getItems ( )

Get a list of all items in this game instance at the current timestep.

Returns
SmartVector of Item pointers of all items in the game instance.

◆ getMovableObjects()

SmartVector< Object * > ObjectManager::getMovableObjects ( )

Get a list of all objects in this game instance at the current timestep that are MOVABLE.

Returns
SmartVector of Object pointers of all objects in the game instance that are MOVABLE.

◆ getObject()

Object * ObjectManager::getObject ( EntityID  globalID)

Attempts to retrieve the object with the given EntityID.

Parameters
globalIDEntityID of the object to retrieve
Returns
A pointer to the object with the given EntityID or nullptr if none exists.

◆ getObjects()

SmartVector< Object * > ObjectManager::getObjects ( )

Get a list of all objects in this game instance at the current timestep.

Returns
SmartVector of Object pointers of all objects in the game instance.

◆ getPlayer()

Player * ObjectManager::getPlayer ( SpecificID  playerID)

Attempts to retrieve the Player with the given SpecificID.

Parameters
playerIDSpecificID of the Player to retrieve
Returns
A pointer to the Player with the given SpecificID or nullptr if none exists.

◆ getPlayers()

SmartVector< Player * > ObjectManager::getPlayers ( )

Get a list of all Players in this game instance at the current timestep.

Returns
SmartVector of Player pointers of all Player objects in the game instance.

◆ getProjectiles()

SmartVector< Projectile * > ObjectManager::getProjectiles ( )

Get a list of all Projectiles in this game instance at the current timestep.

Returns
SmartVector of Projectile pointers of all Projectile objects in the game instance.

◆ getSolidSurface()

SolidSurface * ObjectManager::getSolidSurface ( SpecificID  surfaceID)

Attempts to retrieve the SolidSurface with the given SpecificID.

Parameters
surfaceIDSpecificID of the SolidSurface to retrieve
Returns
A pointer to the SolidSurface with the given SpecificID or nullptr if none exists.

◆ getSolidSurfaces()

SmartVector< SolidSurface * > ObjectManager::getSolidSurfaces ( )

Get a list of all SolidSurfaces in this game instance at the current timestep.

Returns
SmartVector of SolidSurface pointers of all SolidSurface objects in the game instance.

◆ getTorchlight()

Torchlight * ObjectManager::getTorchlight ( SpecificID  torchlightID)

Attempts to retrieve the Torchlight with the given SpecificID.

Parameters
torchlightIDSpecificID of the Torchlight to retrieve
Returns
A pointer

◆ getTorchlights()

SmartVector< Torchlight * > ObjectManager::getTorchlights ( )

Get a list of all Projectiles in this game instance at the current timestep.

Returns
SmartVector of Projectile pointers of all Projectile objects in the game instance

◆ getTrap()

Trap * ObjectManager::getTrap ( SpecificID  trapID)

Attempts to retrieve the Trap with the given SpecificID.

Parameters
trapIDlSpecificID of the Trap to retrieve
Returns
A pointer

◆ getTraps()

SmartVector< Trap * > ObjectManager::getTraps ( )

Get a list of all Traps in this game instance at the current timestep.

Returns
SmartVector of Trap pointers of all Trap objects in the game instance.

◆ getWeaponColliders()

SmartVector< WeaponCollider * > ObjectManager::getWeaponColliders ( )

Get a list of all WeaponCollider in this game instance at the current timestep.

Returns
SmartVector of WeaponCollider pointers of all WeaponCollider objects in the game instance.

◆ moveObject()

bool ObjectManager::moveObject ( Object object,
glm::vec3  newCornerPosition 
)

Attempts to move the given Object to the given corner position, updating its GridCell position vector and the cellToObjects hashmap.

Parameters
objectPointer to the Object to move.
newCornerPositionThe new corner position the Object to which the Object will be moved.
Note
This function does NOT perform collision detection!
Returns
true if sccessfully moved the object to the new corner position and false if the object pointer is nullptr.

◆ objectGridCells()

std::vector< glm::ivec2 > ObjectManager::objectGridCells ( Object object)

Given an object, his function will return a vector of positions of GridCells that are currently occupied by this object.

Parameters
objectPointer to the Object whose occupied GridCell position vector will be calculated.
Returns
A vector of positions of GridCells currently occupied by this object. If the object pointer is nullptr, an empty vector will be returned.

◆ removeObject() [1/2]

bool ObjectManager::removeObject ( EntityID  globalID)

Attempts to remove an object with the given EntityID.

Parameters
globalIDEntityID of the object to remove.
Returns
true if the object was successfully removed and false otherwise.

◆ removeObject() [2/2]

bool ObjectManager::removeObject ( Object **  object_dbl_ptr)

Attempts to remove an object pointed to by the pointer pointed to by the given Object double pointer. If successful, it will set the given Object pointer to nullptr. (use to avoid dangling Object pointers)

Parameters
object_dbl_ptrDouble pointer to the object to remove
Returns
true if the object was successfully removed and false otherwise.

◆ replaceObject()

bool ObjectManager::replaceObject ( EntityID  globalID,
Object object 
)

Replaces the object with the given EntityID with the given Object, if there currently exists an object with the given EntityID. The original object is deleted.

Parameters
globalIDEntityID of object to replace.
objectPointer to new object that will replace the existing one.
Returns
true if replacement was successful and false otherwise.

◆ toShared()

std::vector< boost::optional< SharedObject > > ObjectManager::toShared ( )

Generates a list of SharedObjects that corresponds to all objects in the game instance.

Returns
Returns a std::vector<SharedObject> that corresponds to all objects in the game instance.

Field Documentation

◆ cellToObjects

std::unordered_map<glm::ivec2, std::vector<Object*> > ObjectManager::cellToObjects

Hashmap that maps GridCell (x, y) positions to a vector of Objects that occupy / overlap that GridCell.


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