Raylib Bubbles
C++11 Raylib bubble shooter game.
GameActionMgr Class Reference

Manages game actions and allows them to interact with the game board if necessary. More...

#include <action.hpp>

Classes

struct  ActionType
 Represents an action to be taken by the game. More...
 
struct  AnimState
 Represents the state of an object to be animated. More...
 

Public Member Functions

 GameActionMgr (PlacedBoard &boardData)
 Constructs a GameActionMgr object with the given dimensions and a reference to the game board. More...
 
Iterator methods for sequential access to animation states.
std::vector< ActionType >::iterator begin ()
 Builds an iterator to the beginning of the actions container. More...
 
std::vector< ActionType >::iterator end ()
 Builds an iterator to the end of the actions container. More...
 
General methods.
size_t size () const
 Returns the number of actions currently in the manager. More...
 
Action management methods.
size_t enqueue (ActionType action)
 Adds an action to the manager. More...
 
void step (const float scale=1.0f)
 Steps all managed actions forward, by calling their step() methods. More...
 
void prune ()
 Prunes all actions that are no longer needed, using their shouldPrune() methods. More...
 
bool find (const size_t id) const
 Checks if an action is still ongoing (was not pruned). More...
 

Detailed Description

Manages game actions and allows them to interact with the game board if necessary.

This class allows management of game actions (animations that can reference the board) through a simple interface, making it straightforward to add, step and prune actions.

See also
GameBoard

Constructor & Destructor Documentation

◆ GameActionMgr()

GameActionMgr::GameActionMgr ( PlacedBoard boardData)

Constructs a GameActionMgr object with the given dimensions and a reference to the game board.

Parameters
boardDataA reference to the placed game board object, which wraps the board dimensions with a board reference.
Note
An additional gravity parameter is read from the configuration file, to be used for actions affected by gravity.
See also
PlacedBoard

Member Function Documentation

◆ begin()

std::vector<ActionType>::iterator GameActionMgr::begin ( )
inline

Builds an iterator to the beginning of the actions container.

Returns
An iterator to the beginning of all contents of actions.

◆ end()

std::vector<ActionType>::iterator GameActionMgr::end ( )
inline

Builds an iterator to the end of the actions container.

Returns
An iterator to the end of all contents of actions.

◆ enqueue()

size_t GameActionMgr::enqueue ( ActionType  action)

Adds an action to the manager.

Parameters
actionThe action to be added.
Returns
A random(ish) id to later check whether the action is over with find().
See also
ActionType

◆ find()

bool GameActionMgr::find ( const size_t  id) const

Checks if an action is still ongoing (was not pruned).

Parameters
idThe id of the previously enqueued action to check.
Todo:
Inefficient O(n) linear traversal (but better cache linearity/access time)
Returns
True if the action is active, false if it was pruned.

◆ prune()

void GameActionMgr::prune ( )

Prunes all actions that are no longer needed, using their shouldPrune() methods.

See also
ActionType, ActionType::shouldPrune(), ActionType::PruneType

◆ size()

size_t GameActionMgr::size ( ) const

Returns the number of actions currently in the manager.

Returns
The number of actions currently in the manager.

◆ step()

void GameActionMgr::step ( const float  scale = 1.0f)

Steps all managed actions forward, by calling their step() methods.

Parameters
scaleThe scale to step the actions by, for delta time calculations.
See also
ActionType, ActionType::step()

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