Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
BoardLocations Class Reference

The aspect responsible for mapping points on the 3D game board to their equivalent coordinates on the game board data model. More...

#include <board_locations.hpp>

Inheritance diagram for BoardLocations:
ToyMaker::SimObjectAspect< BoardLocations > ILeftClickable ToyMaker::BaseSimObjectAspect ToyMaker::SignalTracker ToyMaker::IActionHandler

Public Member Functions

std::shared_ptr< BaseSimObjectAspect > clone () const override
 Uses this aspect's data to construct a new aspect.
 
bool onPointerLeftClick (glm::vec4 clickLocation) override
 Responds to left click events by logging them to the console, translating the location of the click to their game board grid coordinates.
 
bool onPointerLeftRelease (glm::vec4 clickLocation) override
 Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent game board coordinates, if possible.
 
glm::uvec2 boardPointToGridIndices (glm::vec2 point) const
 Given the 2D coordinates of a point relative to the top surface of the board, returns the equivalent game board data model grid coordinates.
 
glm::vec4 gridIndicesToBoardPoint (glm::u8vec2 gridIndices) const
 Translates game board data model grid coordinates to their real world 3D coordinates equivalent.
 
- Public Member Functions inherited from ToyMaker::BaseSimObjectAspect
virtual ~BaseSimObjectAspect ()=default
 Destroys this object.
 
virtual void simulationUpdate (uint32_t simStepMillis)
 Overriding this allows an aspect to respond to simulation updates.
 
virtual void variableUpdate (uint32_t variableStepMillis)
 Overriding this allows an aspect to respond to variable updates.
 
bool handleAction (const ActionData &actionData, const ActionDefinition &actionDefinition) override final
 Pipes an action received from the InputManager via our SimObject to all that action's handler methods on this aspect.
 
ViewportNodegetLocalViewport ()
 Returns the closest ancestor viewport to this node, if one exists (which it should, since this shouldn't be called until this aspect is attached to an active SimObject).
 
- Public Member Functions inherited from ToyMaker::SignalTracker
 SignalTracker ()
 Constructs a new SignalTracker object.
 
 SignalTracker (const SignalTracker &other)
 Constructs a new SignalTracker.
 
SignalTrackeroperator= (const SignalTracker &other)
 Copy assignment operator.
 
 SignalTracker (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, invalidating them from the other.
 
SignalTrackeroperator= (SignalTracker &&other)
 Moves resources from another SignalTracker into this one, destroying this tracker's resources in the process.
 
void connect (const std::string &theirSignal, const std::string &ourObserver, SignalTracker &other)
 Method that connects one of this objects SignalObservers to another tracker's Signal.
 

Static Public Member Functions

static std::string getSimObjectAspectTypeName ()
 Gets the aspect type string associated with this class.
 
static std::shared_ptr< BaseSimObjectAspect > create (const nlohmann::json &jsonAspectProperties)
 Constructs this aspect from its JSON description.
 

Public Attributes

ToyMaker::Signal< glm::u8vec2 > mSigBoardClicked { *this, "BoardClicked" }
 The event emitted signalling to the 3D viewport controller that a location on the board was clicked.
 

Private Member Functions

 BoardLocations ()
 Constructs a new Board Locations object.
 

Private Attributes

std::array< uint8_t, 3 > mRowLengths {4, 12, 4}
 The lengths of the 3 rows of the game board representing the number of valid houses on it.
 

Additional Inherited Members

- Protected Member Functions inherited from ToyMaker::SimObjectAspect< BoardLocations >
 SimObjectAspect (int explicitlyInitializeMe)
 
- Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
 BaseSimObjectAspect (const BaseSimObjectAspect &other)=delete
 
 BaseSimObjectAspect (BaseSimObjectAspect &&other)=delete
 
SimObjectgetSimObject ()
 Returns the sim object that this aspect is attached to.
 
template<typename TComponent>
void addComponent (const TComponent &component)
 Adds a component of some type to the underlying entity.
 
template<typename TComponent>
bool hasComponent ()
 Tests whether a component of some specific type is present on the object.
 
template<typename TComponent>
void updateComponent (const TComponent &component)
 Updates the value of a component belonging to this object to a new one.
 
template<typename TComponent>
TComponent getComponent (const float simulationProgress=1.f) const
 Gets the value of a component belonging to this object.
 
template<typename TComponent>
void removeComponent ()
 Removes a component of some type belonging to the underlying SimObject.
 
void addAspect (const nlohmann::json &jsonAspectProperties)
 Adds a new aspect to the underlying SimObject constructed based on its properties in JSON.
 
void addAspect (const BaseSimObjectAspect &aspect)
 Adds a new aspect to the underlying SimObject copied from an already existing aspect.
 
template<typename TSimObjectAspect>
bool hasAspect () const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
bool hasAspect (const std::string &aspectType) const
 Tests whether an aspect of a particular type is attached to the underlying SimObject.
 
template<typename TSimObjectAspect>
TSimObjectAspect & getAspect ()
 Gets an aspect of a particular type belonging to the underlying SimObject.
 
BaseSimObjectAspectgetAspect (const std::string &aspectType)
 Gets (a base class reference to) an aspect of a particular type belonging to the underlying SimObject.
 
template<typename TSimObjectAspect>
void removeAspect ()
 Removes an aspect from the underlying SimObject.
 
void addOrReplaceAspect (const BaseSimObjectAspect &aspect)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed as a copy of another.
 
void addOrReplaceAspect (const nlohmann::json &jsonAspectProperties)
 Adds or replaces an aspect on the underlying SimObject with a new aspect constructed from its JSON description.
 
std::weak_ptr< FixedActionBindingdeclareFixedActionBinding (const std::string &context, const std::string &action, std::function< bool(const ActionData &, const ActionDefinition &)>)
 Binds some method (or any function) present on this object to an action generated by the InputManager.
 
EntityID getEntityID () const
 Gets the ID of the ECSWorld Entity belonging to our SimObject.
 
std::weak_ptr< ECSWorldgetWorld () const
 Gets a weak reference to the ECSWorld to which our SimObject's entity belongs.
 
- Static Protected Member Functions inherited from ToyMaker::BaseSimObjectAspect
template<typename TSimObjectAspectDerived>
static void registerAspect ()
 Registers an implementation of an aspect with the SimSystem.
 

Detailed Description

The aspect responsible for mapping points on the 3D game board to their equivalent coordinates on the game board data model.

Member Function Documentation

◆ boardPointToGridIndices()

glm::uvec2 BoardLocations::boardPointToGridIndices ( glm::vec2 point) const

Given the 2D coordinates of a point relative to the top surface of the board, returns the equivalent game board data model grid coordinates.

Parameters
pointThe 2D coordinates of a point on the surface of the board.
Returns
glm::uvec2 The game board grid coordinates.

◆ clone()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > BoardLocations::clone ( ) const
overridevirtual

Uses this aspect's data to construct a new aspect.

Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

Implements ToyMaker::BaseSimObjectAspect.

◆ create()

std::shared_ptr< ToyMaker::BaseSimObjectAspect > BoardLocations::create ( const nlohmann::json & jsonAspectProperties)
static

Constructs this aspect from its JSON description.

This is its appearance in JSON:

{ "type": "BoardLocations" }
Parameters
jsonAspectPropertiesThis aspect's description in JSON.
Returns
std::shared_ptr<BaseSimObjectAspect> The newly constructed aspect.

◆ getSimObjectAspectTypeName()

static std::string BoardLocations::getSimObjectAspectTypeName ( )
inlinestatic

Gets the aspect type string associated with this class.

Returns
std::string This class' aspect type string.

◆ gridIndicesToBoardPoint()

glm::vec4 BoardLocations::gridIndicesToBoardPoint ( glm::u8vec2 gridIndices) const

Translates game board data model grid coordinates to their real world 3D coordinates equivalent.

Parameters
gridIndicesThe game board data model grid location.
Returns
glm::vec4 The equivalent 3D coordinates.

◆ onPointerLeftClick()

bool BoardLocations::onPointerLeftClick ( glm::vec4 clickLocation)
overridevirtual

Responds to left click events by logging them to the console, translating the location of the click to their game board grid coordinates.

Parameters
clickLocationThe 3D coordinates of the location on the board that was clicked.
Return values
trueThe location clicked corresponded to a real game board grid location.
falseThe location clicked did not correspond to a real game board grid location.

Implements ILeftClickable.

◆ onPointerLeftRelease()

bool BoardLocations::onPointerLeftRelease ( glm::vec4 clickLocation)
inlineoverridevirtual

Responds to a full left click by emitting mSigBoardClicked with the clicked location's equivalent game board coordinates, if possible.

Parameters
clickLocationThe 3D coordinates of the point on the board that was clicked.
Return values
trueThe clicked location caused mSigBoardClicked to be emitted.
falseNo signal was emitted as a result of this click.

Implements ILeftClickable.


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