|
Zappy GUI
C++ graphic client: renderer, camera, network
|
Represents the current state of the game. Knows the world state, some metadata, and how to apply events to update itself. Also tracks whether it has been modified since the last time it was cleared (dirty flag). More...
#include <GameState.hpp>
Collaboration diagram for GameState:Public Member Functions | |
| void | applyEvent (const Event &e) |
| Applies an event to the game state, modifying it accordingly and setting the dirty flag. | |
| bool | isDirty () const |
| Checks if the game state has been modified since the last time it was cleared (dirty flag). | |
| void | clearDirty () const |
| Sets the dirty flag to false. | |
Public Attributes | |
| WorldState | world |
| int | timeUnit = -1 |
| std::string | winnerTeam = "" |
| int | gameDurationSeconds = -1 |
| int64_t | gameDurationTicks = -1 |
| float | tileSize = 1.0f |
| unsigned int | serverUptimeSeconds = 0 |
| bool | receivedStuResponse = false |
Static Private Member Functions | |
| static void | _pushBehavior (VisualState &visual, std::unique_ptr< IBehavior > b) |
Private Attributes | |
| bool | dirty = false |
Represents the current state of the game. Knows the world state, some metadata, and how to apply events to update itself. Also tracks whether it has been modified since the last time it was cleared (dirty flag).
Definition at line 15 of file GameState.hpp.
|
private |
Definition at line 256 of file GameState.cpp.
References WorldState::eggs, EggDeath::id, and world.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 250 of file GameState.cpp.
References WorldState::eggs, EggHatch::id, and world.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 236 of file GameState.cpp.
References _pushBehavior(), EggNew::eggId, WorldState::eggs, WorldState::height, Egg::id, EggNew::playerId, WorldState::players, tileSize, RenderingHelper::tileToWorld(), timeUnit, WorldState::width, world, EggNew::x, and EggNew::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 262 of file GameState.cpp.
References winnerTeam, and GameEnd::winningTeam.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 189 of file GameState.cpp.
References WorldState::players, IncantationEnd::success, world, IncantationEnd::x, and IncantationEnd::y.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 168 of file GameState.cpp.
References _pushBehavior(), WorldState::height, IncantationStart::playerIds, WorldState::players, tileSize, timeUnit, WorldState::width, world, IncantationStart::x, and IncantationStart::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 81 of file GameState.cpp.
References MapSize::height, WorldState::height, WorldState::tiles, MapSize::width, WorldState::width, and world.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 156 of file GameState.cpp.
References _pushBehavior(), WorldState::height, PlayerBroadcast::id, WorldState::players, timeUnit, WorldState::width, and world.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 223 of file GameState.cpp.
References _pushBehavior(), VisualState::behaviors, WorldState::dyingPlayers, PlayerDeath::id, WorldState::players, timeUnit, and world.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 151 of file GameState.cpp.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 200 of file GameState.cpp.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 143 of file GameState.cpp.
References PlayerInventory::id, PlayerInventory::inventory, WorldState::players, and world.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 134 of file GameState.cpp.
References _pushBehavior(), PlayerLevel::id, PlayerLevel::level, WorldState::players, timeUnit, and world.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 92 of file GameState.cpp.
References WorldState::height, PlayerNew::id, PlayerNew::orientation, WorldState::players, tileSize, RenderingHelper::tileToWorld(), toAngle(), WorldState::width, world, PlayerNew::x, and PlayerNew::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 105 of file GameState.cpp.
References _pushBehavior(), VisualState::angle, VisualState::behaviors, WorldState::height, PlayerPosition::id, Player::orientation, PlayerPosition::orientation, WorldState::players, tileSize, timeUnit, toAngle(), WorldState::width, world, Player::x, PlayerPosition::x, Player::y, and PlayerPosition::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 205 of file GameState.cpp.
References WorldState::at(), PlayerResourceDrop::playerId, WorldState::players, PlayerResourceDrop::resourceId, and world.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 214 of file GameState.cpp.
References WorldState::at(), PlayerResourceTake::playerId, WorldState::players, PlayerResourceTake::resourceId, and world.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 270 of file GameState.cpp.
References _pushBehavior(), ServerSpawnedEgg::eggId, WorldState::eggs, WorldState::height, Egg::id, ServerSpawnedEgg::team, tileSize, RenderingHelper::tileToWorld(), timeUnit, WorldState::width, world, ServerSpawnedEgg::x, and ServerSpawnedEgg::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 264 of file GameState.cpp.
References receivedStuResponse, serverUptimeSeconds, and ServerUptime::uptimeSeconds.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 90 of file GameState.cpp.
References TeamName::name, WorldState::teams, and world.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 88 of file GameState.cpp.
References WorldState::at(), TileContent::resources, world, TileContent::x, and TileContent::y.
Referenced by applyEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 258 of file GameState.cpp.
References TimeUnit::timeUnit, and timeUnit.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 260 of file GameState.cpp.
References TimeUnitChange::timeUnit, and timeUnit.
Referenced by applyEvent().
Here is the caller graph for this function:
|
private |
Definition at line 280 of file GameState.cpp.
References gameDurationSeconds, gameDurationTicks, WinDuration::seconds, and WinDuration::ticks.
Referenced by applyEvent().
Here is the caller graph for this function:
|
staticprivate |
Definition at line 286 of file GameState.cpp.
References VisualState::behaviors.
Referenced by _applyEggNew(), _applyIncantationStart(), _applyPlayerBroadcast(), _applyPlayerDeath(), _applyPlayerLevel(), _applyPlayerPosition(), and _applyServerSpawnedEgg().
Here is the caller graph for this function:| void GameState::applyEvent | ( | const Event & | e | ) |
Applies an event to the game state, modifying it accordingly and setting the dirty flag.
Definition at line 17 of file GameState.cpp.
References _applyEggDeath(), _applyEggHatch(), _applyEggNew(), _applyGameEnd(), _applyIncantationEnd(), _applyIncantationStart(), _applyMapSize(), _applyPlayerBroadcast(), _applyPlayerDeath(), _applyPlayerExpulsion(), _applyPlayerFork(), _applyPlayerInventory(), _applyPlayerLevel(), _applyPlayerNew(), _applyPlayerPosition(), _applyPlayerResourceDrop(), _applyPlayerResourceTake(), _applyServerSpawnedEgg(), _applyServerUptime(), _applyTeamName(), _applyTileContent(), _applyTimeUnit(), _applyTimeUnitChange(), _applyWinDuration(), and dirty.
Referenced by App::run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Sets the dirty flag to false.
Definition at line 44 of file GameState.hpp.
References dirty.
Referenced by HeadlessRenderer::render().
Here is the caller graph for this function:
|
inline |
Checks if the game state has been modified since the last time it was cleared (dirty flag).
Definition at line 37 of file GameState.hpp.
References dirty.
Referenced by HeadlessRenderer::render().
Here is the caller graph for this function:
|
mutableprivate |
Definition at line 47 of file GameState.hpp.
Referenced by applyEvent(), clearDirty(), and isDirty().
| int GameState::gameDurationSeconds = -1 |
Definition at line 20 of file GameState.hpp.
Referenced by _applyWinDuration(), and RaylibRenderer::_render2D().
| int64_t GameState::gameDurationTicks = -1 |
Definition at line 21 of file GameState.hpp.
Referenced by _applyWinDuration(), and RaylibRenderer::_render2D().
| bool GameState::receivedStuResponse = false |
Definition at line 24 of file GameState.hpp.
Referenced by _applyServerUptime(), and App::_trySendStu().
| unsigned int GameState::serverUptimeSeconds = 0 |
Definition at line 23 of file GameState.hpp.
Referenced by _applyServerUptime(), and RaylibRenderer::render().
| float GameState::tileSize = 1.0f |
Definition at line 22 of file GameState.hpp.
Referenced by _applyEggNew(), _applyIncantationStart(), _applyPlayerNew(), _applyPlayerPosition(), and _applyServerSpawnedEgg().
| int GameState::timeUnit = -1 |
Definition at line 18 of file GameState.hpp.
Referenced by _applyEggNew(), _applyIncantationStart(), _applyPlayerBroadcast(), _applyPlayerDeath(), _applyPlayerLevel(), _applyPlayerPosition(), _applyServerSpawnedEgg(), _applyTimeUnit(), _applyTimeUnitChange(), RaylibRenderer::_drawSpeedSlider(), HeadlessRenderer::render(), and RaylibRenderer::render().
| std::string GameState::winnerTeam = "" |
Definition at line 19 of file GameState.hpp.
Referenced by _applyGameEnd(), RaylibRenderer::_render2D(), and HeadlessRenderer::render().
| WorldState GameState::world |
Definition at line 17 of file GameState.hpp.
Referenced by _applyEggDeath(), _applyEggHatch(), _applyEggNew(), _applyIncantationEnd(), _applyIncantationStart(), _applyMapSize(), _applyPlayerBroadcast(), _applyPlayerDeath(), _applyPlayerInventory(), _applyPlayerLevel(), _applyPlayerNew(), _applyPlayerPosition(), _applyPlayerResourceDrop(), _applyPlayerResourceTake(), _applyServerSpawnedEgg(), _applyTeamName(), _applyTileContent(), RaylibRenderer::_drawSelectionHighlight(), RaylibRenderer::_groupLabelAnchor(), RaylibRenderer::_groupPlayersByVisualProximity(), RaylibRenderer::_initTeamColors(), RaylibRenderer::_render2D(), RaylibRenderer::_render3D(), SelectionFinder::findFromRay(), RaylibRenderer::handleInput(), HeadlessRenderer::render(), and RaylibRenderer::render().