|
Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
|
The ServerGameState class contains all abstract game state data and logic for a single game state instance (i.e., for one match played by 4 players). More...
#include <servergamestate.hpp>
Public Member Functions | |
| ServerGameState () | |
| Creates a ServerGameState instance. The intial GamePhase is set to Lobby. More... | |
| ServerGameState (GamePhase start_phase) | |
| Creats a ServerGameState instance and sets the initial game phase to the given GamePhase. More... | |
| ServerGameState (GamePhase start_phase, const GameConfig &config) | |
| ServerGameState (GameConfig config) | |
| This is the ONLY constructor that initializes the maze from a maze_file argument. All other constructors must call it. More... | |
| ~ServerGameState () | |
| void | update (const EventList &events) |
| Updates this ServerGameState from the current timestep to the next one. More... | |
| void | markForDeletion (EntityID id) |
| tell the gamestate to delete this entity at the end of the tick More... | |
| void | markAsUpdated (EntityID id) |
| mark an entity as updated More... | |
| void | updateMovement () |
| bool | hasObjectCollided (Object *object, glm::vec3 newCornerPosition) |
| Detects whether a collision occurs with other objects when the given object moves to the given position. More... | |
| void | updateItems () |
| void | updateAttacks () |
| void | updateEnemies () |
| void | doProjectileTicks () |
| void | doTorchlightTicks () |
| void | updateTraps () |
| void | handleDeaths () |
| void | handleRespawns () |
| void | handleDM () |
| void | updateCompass () |
| void | tickStatuses () |
| void | spawnEnemies () |
| void | handleTickVelocity () |
| void | deleteEntities () |
| void | updatePlayerLightningInvulnerabilityStatus () |
| Updates player's lightning invulnerability status (sets to false once the player's lightning invulnerability duration is past) More... | |
| void | updateDungeonMasterParalysis () |
| Updates the DungeonMaster's paralysis status (sets to false once the DungeonMaster's paralysis duration is past) More... | |
| std::vector< SharedGameState > | generateSharedGameState (bool send_all) |
| Generate a SharedGameState object from this ServerGameState instance. More... | |
| SoundTable & | soundTable () |
| unsigned int | getTimestep () const |
| Returns the current timestep of this ServerGameState instance. More... | |
| GamePhase | getPhase () const |
| Returns the phase that this ServerGameState instance is currently in. More... | |
| void | setPhase (GamePhase phase) |
| setter for game phase More... | |
| MatchPhase | getMatchPhase () const |
| Returns the match phase that this ServerGameState instance is currently in. More... | |
| void | transitionToRelayRace () |
| Transitions this ServerGameState's match phase to MatchPhase::RelayRace and updates all necessary data. If the match phase is already MatchPhase::RelayRace, this method returns immediately. More... | |
| void | setPlayerVictory (bool playerVictory) |
| Sets the playerVictory boolean. More... | |
| void | addPlayerToLobby (LobbyPlayer player) |
| Adds a new LobbyPlayer to this ServerGameState's Lobby struct. This method will assign the new player's LobbyPlayer to the first free index in the Lobby.players vector. Note: this method will CAUSE THE SERVER TO CRASH if all LobbyPlayer indices are currently in use (i.e., if Lobby.max_players players have already connected to this server's lobby). More... | |
| void | updateLobbyPlayer (EntityID id, LobbyPlayer player) |
| Updates the LobbyPlayer with the given EntityID to the given LobbyPlayer struct. More... | |
| void | removePlayerFromLobby (EntityID id) |
| const Lobby & | getLobby () const |
| Trap * | placeTrapInCell (GridCell *cell, CellType type) |
| void | loadMaze (const Grid &grid) |
| Reads from maze file and initializes this ServerGameState's Grid instance, as well as creating all necessary environment objects. More... | |
| Grid & | getGrid () |
| Returns a reference to the Grid in use by this ServerGameState. More... | |
| std::string | to_string () |
| Creates a string representation of this ServerGameState object. More... | |
Data Fields | |
| ObjectManager | objects |
| ObjectManager instance that manages all objects in this game instance at the current timestep. More... | |
| std::unique_ptr< Spawner > | spawner |
| Controls the spawns for the enemies. More... | |
The ServerGameState class contains all abstract game state data and logic for a single game state instance (i.e., for one match played by 4 players).
| ServerGameState::ServerGameState | ( | ) |
Creates a ServerGameState instance. The intial GamePhase is set to Lobby.
|
explicit |
Creats a ServerGameState instance and sets the initial game phase to the given GamePhase.
| start_phase | GamePhase that the new ServerGameState instance will start in. |
| ServerGameState::ServerGameState | ( | GamePhase | start_phase, |
| const GameConfig & | config | ||
| ) |
|
explicit |
This is the ONLY constructor that initializes the maze from a maze_file argument. All other constructors must call it.
| maze_file | Name of maze file to load. (should be in maps/ directory). |
| ServerGameState::~ServerGameState | ( | ) |
| void ServerGameState::addPlayerToLobby | ( | LobbyPlayer | player | ) |
Adds a new LobbyPlayer to this ServerGameState's Lobby struct. This method will assign the new player's LobbyPlayer to the first free index in the Lobby.players vector. Note: this method will CAUSE THE SERVER TO CRASH if all LobbyPlayer indices are currently in use (i.e., if Lobby.max_players players have already connected to this server's lobby).
Reassign id to the specified name in the mapping. This is okay to call if the player is already in the mapping, as nothing will happen. If a player's name has changed, then this will update their name as well.
| player | LobbyPlayer struct of the new player to add to this ServerGameState instance's Lobby. |
| void ServerGameState::deleteEntities | ( | ) |
| void ServerGameState::doProjectileTicks | ( | ) |
| void ServerGameState::doTorchlightTicks | ( | ) |
| std::vector< SharedGameState > ServerGameState::generateSharedGameState | ( | bool | send_all | ) |
Generate a SharedGameState object from this ServerGameState instance.
| send_all | True if you should send a 100% update to the client, false if you should just send the updated objects |
NOTE: if send_all is false and you generate an update based on the diffs, this function will clear the updated_entities unordered_set for you
| Grid & ServerGameState::getGrid | ( | ) |
Returns a reference to the Grid in use by this ServerGameState.
| const Lobby & ServerGameState::getLobby | ( | ) | const |
| MatchPhase ServerGameState::getMatchPhase | ( | ) | const |
Returns the match phase that this ServerGameState instance is currently in.
| GamePhase ServerGameState::getPhase | ( | ) | const |
Returns the phase that this ServerGameState instance is currently in.
| unsigned int ServerGameState::getTimestep | ( | ) | const |
Returns the current timestep of this ServerGameState instance.
| void ServerGameState::handleDeaths | ( | ) |
| void ServerGameState::handleDM | ( | ) |
| void ServerGameState::handleRespawns | ( | ) |
| void ServerGameState::handleTickVelocity | ( | ) |
| bool ServerGameState::hasObjectCollided | ( | Object * | object, |
| glm::vec3 | newCornerPosition | ||
| ) |
Detects whether a collision occurs with other objects when the given object moves to the given position.
| object | Object to perform collision detection for |
| newCornerPosition | Corner position object moves to at which collision detection is performed |
Reads from maze file and initializes this ServerGameState's Grid instance, as well as creating all necessary environment objects.
tell the gamestate to delete this entity at the end of the tick
Removes a player from the lobby with the specified id.
| void ServerGameState::setPlayerVictory | ( | bool | playerVictory | ) |
Sets the playerVictory boolean.
| playerVictory | boolean value to set the playerVictory value to |
| SoundTable & ServerGameState::soundTable | ( | ) |
| void ServerGameState::spawnEnemies | ( | ) |
| void ServerGameState::tickStatuses | ( | ) |
| std::string ServerGameState::to_string | ( | ) |
Creates a string representation of this ServerGameState object.
| void ServerGameState::transitionToRelayRace | ( | ) |
Transitions this ServerGameState's match phase to MatchPhase::RelayRace and updates all necessary data. If the match phase is already MatchPhase::RelayRace, this method returns immediately.
Updates this ServerGameState from the current timestep to the next one.
| void ServerGameState::updateAttacks | ( | ) |
| void ServerGameState::updateCompass | ( | ) |
| void ServerGameState::updateDungeonMasterParalysis | ( | ) |
Updates the DungeonMaster's paralysis status (sets to false once the DungeonMaster's paralysis duration is past)
| void ServerGameState::updateEnemies | ( | ) |
| void ServerGameState::updateItems | ( | ) |
| void ServerGameState::updateLobbyPlayer | ( | EntityID | id, |
| LobbyPlayer | player | ||
| ) |
Updates the LobbyPlayer with the given EntityID to the given LobbyPlayer struct.
| id | EntityID of the LobbyPlayer to update |
| player | LobbyPlayer struct to copy to the current lobby player |
| void ServerGameState::updateMovement | ( | ) |
| void ServerGameState::updatePlayerLightningInvulnerabilityStatus | ( | ) |
Updates player's lightning invulnerability status (sets to false once the player's lightning invulnerability duration is past)
| void ServerGameState::updateTraps | ( | ) |
| ObjectManager ServerGameState::objects |
ObjectManager instance that manages all objects in this game instance at the current timestep.
| std::unique_ptr<Spawner> ServerGameState::spawner |
Controls the spawns for the enemies.