The class responsible for managing and reporting the state of the game. It owns its own instance of GameOfUrModel, and acts as the interface between it and engine-specific objects.
More...
#include <ur_controller.hpp>
|
|
| UrController () |
| | Constructs a new UrController aspect.
|
| |
| std::shared_ptr< BaseSimObjectAspect > | clone () const override |
| | Constructs an UrController object using this one as its blueprint.
|
| |
| const GameOfUrModel & | getModel () const |
| | Gets a const reference to the underlying data model of this object.
|
| |
| std::unique_ptr< UrPlayerControls > | createControls () |
| | Creates an instance of UrPlayerControls, which exposes methods which allow (controlled) interaction with this aspect, corresponding with an ID known by the underlying data model.
|
| |
|
| static std::string | getSimObjectAspectTypeName () |
| | Gets the aspect type string associated with this object.
|
| |
| static std::shared_ptr< BaseSimObjectAspect > | create (const nlohmann::json &jsonAspectProperties) |
| | Creates an UrController based on its JSON description.
|
| |
|
|
ToyMaker::Signal | mSigControllerReady { *this, "ControllerReady" } |
| | Signal emitted by this object when it is ready to be interacted with by other objects.
|
| |
| ToyMaker::SignalObserver< const std::string & > | mObserveViewSubscribed |
| | Observer to a signal emitted by views interested in events broadcasted by this object.
|
| |
|
ToyMaker::Signal< GamePhaseData > | mSigPhaseUpdated { *this, "PhaseUpdated" } |
| | Signal emitted when a the game data model reports a change to its phase.
|
| |
|
ToyMaker::Signal< GameScoreData > | mSigScoreUpdated { *this, "ScoreUpdated" } |
| | Signal emitted when the game data model reports a change in score.
|
| |
|
ToyMaker::Signal< PlayerData > | mSigPlayerUpdated { *this, "PlayerUpdated" } |
| | Signal emitted when information associated with a player changes.
|
| |
|
ToyMaker::Signal< DiceData > | mSigDiceUpdated { *this, "DiceUpdated" } |
| | Signal emitted when the game data model reports a change in the state of its dice.
|
| |
|
ToyMaker::Signal< MoveResultData > | mSigMoveMade { *this, "MoveMade" } |
| | Signal emitted when the game data model reports a move successfully executed.
|
| |
|
ToyMaker::Signal | mSigViewUpdateStarted { *this, "ViewUpdateStarted" } |
| | Signal emitted when this controller begins waiting for view updates related to the latest game state change to complete.
|
| |
| ToyMaker::SignalObserver< const std::string & > | mObserveViewUpdateCompleted |
| | Observer which receives signals from its subscribed views when they report their updates are complete.
|
| |
|
ToyMaker::Signal< GamePhaseData > | mSigMovePrompted { *this, "MovePrompted" } |
| | Signal emitted when the controller expects a player to act, either via the game UI or some other source.
|
| |
|
| bool | viewUpdatesComplete () const |
| | Returns whether all the views connected with this controller have reported completion of their updates.
|
| |
| void | onViewSubscribed (const std::string &subscriber) |
| | Adds a view which is interested in receiving information about events regarding changes in the state of the game.
|
| |
| void | onLaunchPieceAttempted (PlayerID player, PieceIdentity piece, glm::u8vec2 launchLocation=glm::u8vec2{0, 0}) |
| | Attempts to launch a game piece to the board.
|
| |
| void | onMoveBoardPieceAttempted (PlayerID player, PieceIdentity piece) |
| | Attempts to move a piece present on the board according to the current roll.
|
| |
| void | onNextTurnAttempted (PlayerID player) |
| | Attempts to end the current turn and move to the next one.
|
| |
| void | onDiceRollAttempted (PlayerID player) |
| | Attempts to roll the dice.
|
| |
| void | onViewUpdatesCompleted (const std::string &viewName) |
| | The callback, invoked by a subscribed view, where the view reports that it has completed all view changes related to the latest change in game state.
|
| |
|
void | onActivated () override |
| | Initializes the game data model.
|
| |
|
|
GameOfUrModel | mModel {} |
| | The game data model this aspect is an interface to.
|
| |
| uint8_t | mControlsCreated {0} |
| | The number of controls connected with this object created over its lifetime.
|
| |
|
std::string | mSceneManagerPath {} |
| | The path to the scene manager, responsible for navigating between the different game screens in this project.
|
| |
| std::map< std::string, bool > | mViewUpdated {} |
| | Flags corresponding with various views subscribed with this object.
|
| |
The class responsible for managing and reporting the state of the game. It owns its own instance of GameOfUrModel, and acts as the interface between it and engine-specific objects.
◆ clone()
| std::shared_ptr< ToyMaker::BaseSimObjectAspect > UrController::clone |
( |
| ) |
const |
|
override |
Constructs an UrController object using this one as its blueprint.
- Returns
- std::shared_ptr<BaseSimObjectAspect> The newly constructed UrController aspect.
◆ create()
| std::shared_ptr< ToyMaker::BaseSimObjectAspect > UrController::create |
( |
const nlohmann::json & | jsonAspectProperties | ) |
|
|
static |
Creates an UrController based on its JSON description.
- Parameters
-
| jsonAspectProperties | The JSON description of this instance of UrController. |
- Returns
- std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.
◆ createControls()
Creates an instance of UrPlayerControls, which exposes methods which allow (controlled) interaction with this aspect, corresponding with an ID known by the underlying data model.
No more than two such player controls can exist for a single instance of this controller.
- Returns
- std::unique_ptr<UrPlayerControls> The interface between this controller and a player of the game.
◆ getModel()
Gets a const reference to the underlying data model of this object.
- Returns
- const GameOfUrModel& A const reference to the underlying game data model.
◆ getSimObjectAspectTypeName()
| static std::string UrController::getSimObjectAspectTypeName |
( |
| ) |
|
|
inlinestatic |
Gets the aspect type string associated with this object.
- Returns
- std::string The aspect type string associated with this class.
◆ onDiceRollAttempted()
| void UrController::onDiceRollAttempted |
( |
PlayerID | player | ) |
|
|
private |
Attempts to roll the dice.
- Parameters
-
| player | The player requesting the dice roll. |
◆ onLaunchPieceAttempted()
| void UrController::onLaunchPieceAttempted |
( |
PlayerID | player, |
|
|
PieceIdentity | piece, |
|
|
glm::u8vec2 | launchLocation = glm::u8vec2{0,0} ) |
|
private |
Attempts to launch a game piece to the board.
- Parameters
-
| player | The player requesting the launch. |
| piece | The piece being launched. |
| launchLocation | The game board grid location to which the player wants the piece launched. |
◆ onMoveBoardPieceAttempted()
Attempts to move a piece present on the board according to the current roll.
- Parameters
-
| player | The player requesting the move. |
| piece | The piece on the game board being moved. |
◆ onNextTurnAttempted()
| void UrController::onNextTurnAttempted |
( |
PlayerID | player | ) |
|
|
private |
Attempts to end the current turn and move to the next one.
- Parameters
-
| player | The player requesting the end of the turn. |
◆ onViewSubscribed()
| void UrController::onViewSubscribed |
( |
const std::string & | subscriber | ) |
|
|
private |
Adds a view which is interested in receiving information about events regarding changes in the state of the game.
- Parameters
-
| subscriber | A view interested in game-state changes. |
◆ onViewUpdatesCompleted()
| void UrController::onViewUpdatesCompleted |
( |
const std::string & | viewName | ) |
|
|
private |
The callback, invoked by a subscribed view, where the view reports that it has completed all view changes related to the latest change in game state.
- Parameters
-
| viewName | The name of the view which has completed its view updates. |
◆ viewUpdatesComplete()
| bool UrController::viewUpdatesComplete |
( |
| ) |
const |
|
private |
Returns whether all the views connected with this controller have reported completion of their updates.
- Return values
-
| true | All associated views have reported completion of their updates. |
| false | One or more views have not reported completion of their updates. |
◆ mControlsCreated
| uint8_t UrController::mControlsCreated {0} |
|
private |
The number of controls connected with this object created over its lifetime.
More than two is an error.
◆ mObserveViewSubscribed
| ToyMaker::SignalObserver<const std::string&> UrController::mObserveViewSubscribed |
Initial value:{
*this, "ViewSubscribedObserved",
}
void onViewSubscribed(const std::string &subscriber)
Adds a view which is interested in receiving information about events regarding changes in the state ...
Definition ur_controller.cpp:28
Observer to a signal emitted by views interested in events broadcasted by this object.
◆ mObserveViewUpdateCompleted
| ToyMaker::SignalObserver<const std::string&> UrController::mObserveViewUpdateCompleted |
Initial value:{
*this, "ViewUpdateCompletedObserved",
}
void onViewUpdatesCompleted(const std::string &viewName)
The callback, invoked by a subscribed view, where the view reports that it has completed all view cha...
Definition ur_controller.cpp:32
Observer which receives signals from its subscribed views when they report their updates are complete.
◆ mViewUpdated
| std::map<std::string, bool> UrController::mViewUpdated {} |
|
private |
Flags corresponding with various views subscribed with this object.
All the subscribed views must report that their update has taken place before the controller allows more game events to occur.
The documentation for this class was generated from the following files: