[2428] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
[8706] | 25 | * Damian 'Mozork' Frick |
---|
[2428] | 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[8706] | 29 | /** |
---|
| 30 | @file GametypeInfo.h |
---|
| 31 | @brief Definition of the GametypeInfo class |
---|
| 32 | */ |
---|
| 33 | |
---|
[2428] | 34 | #ifndef _GametypeInfo_H__ |
---|
| 35 | #define _GametypeInfo_H__ |
---|
| 36 | |
---|
| 37 | #include "OrxonoxPrereqs.h" |
---|
| 38 | |
---|
[3196] | 39 | #include <string> |
---|
[8706] | 40 | |
---|
[2428] | 41 | #include "Info.h" |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
[8706] | 45 | |
---|
| 46 | /** |
---|
| 47 | @brief |
---|
| 48 | The GametypeInfo class keeps track of the state of the game and provides facilities to inform the player about it. |
---|
| 49 | |
---|
| 50 | @author |
---|
| 51 | Fabian 'x3n' Landau |
---|
| 52 | @author |
---|
| 53 | Damian 'Mozork' Frick |
---|
| 54 | */ |
---|
[2428] | 55 | class _OrxonoxExport GametypeInfo : public Info |
---|
| 56 | { |
---|
| 57 | friend class Gametype; |
---|
| 58 | |
---|
| 59 | public: |
---|
[9667] | 60 | GametypeInfo(Context* context); |
---|
[2428] | 61 | virtual ~GametypeInfo(); |
---|
| 62 | |
---|
[8706] | 63 | /** |
---|
| 64 | @brief Get whether the game has started yet. |
---|
| 65 | @return Returns true if the game has started, false if not. |
---|
| 66 | */ |
---|
[2428] | 67 | inline bool hasStarted() const |
---|
| 68 | { return this->bStarted_; } |
---|
[8706] | 69 | void changedStarted(void); // Is called when the game has changed to started. |
---|
[9348] | 70 | |
---|
[8706] | 71 | /** |
---|
| 72 | @brief Get whether the game has ended yet. |
---|
| 73 | @return Returns true if the game has ended, false if not. |
---|
| 74 | */ |
---|
[2428] | 75 | inline bool hasEnded() const |
---|
| 76 | { return this->bEnded_; } |
---|
[8706] | 77 | void changedEnded(void); // Is called when the game has changed to ended. |
---|
[2428] | 78 | |
---|
[8706] | 79 | /** |
---|
| 80 | @brief Get whether the start countdown is currently running. |
---|
| 81 | @return Returns true if the countdown is running, false if not. |
---|
| 82 | */ |
---|
[2428] | 83 | inline bool isStartCountdownRunning() const |
---|
| 84 | { return this->bStartCountdownRunning_; } |
---|
[11358] | 85 | |
---|
[8706] | 86 | void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped. |
---|
| 87 | |
---|
| 88 | /** |
---|
| 89 | @brief Get the current value of the start countdown. |
---|
| 90 | @return Returns the current value of the start countdown. |
---|
| 91 | */ |
---|
[2428] | 92 | inline float getStartCountdown() const |
---|
| 93 | { return this->startCountdown_; } |
---|
| 94 | |
---|
[8706] | 95 | /** |
---|
| 96 | @brief Get the current start countdown counter. |
---|
| 97 | The start countdown counter only has integer values that correspond to the actually displayed countdown. |
---|
| 98 | @return Returns the current integer countdown counter. |
---|
| 99 | */ |
---|
| 100 | inline unsigned int getStartCountdownCounter() const |
---|
| 101 | { return this->counter_; } |
---|
| 102 | void changedCountdownCounter(void); // Is called when the start countdown counter has changed. |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | @brief Get whether the local player is ready to spawn. |
---|
| 106 | @return Returns true if the player is ready to spawn, false if not. |
---|
| 107 | */ |
---|
| 108 | inline bool isReadyToSpawn() const |
---|
| 109 | { return this->readyToSpawn_; } |
---|
| 110 | void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status. |
---|
[9348] | 111 | |
---|
[8706] | 112 | /** |
---|
| 113 | @brief Get whether the local player is spawned. |
---|
| 114 | @return Returns true if the local player is currently spawned, false if not. |
---|
| 115 | */ |
---|
| 116 | inline bool isSpawned() const |
---|
| 117 | { return this->spawned_; } |
---|
| 118 | void changedSpawned(bool spawned); // Inform the GametypeInfo that the local player has changed its spawned status. |
---|
| 119 | |
---|
[2826] | 120 | inline const std::string& getHUDTemplate() const |
---|
| 121 | { return this->hudtemplate_; } |
---|
| 122 | |
---|
[9348] | 123 | void sendAnnounceMessage(const std::string& message) const; |
---|
| 124 | void sendAnnounceMessage(const std::string& message, unsigned int clientID) const; |
---|
| 125 | void sendKillMessage(const std::string& message, unsigned int clientID) const; |
---|
| 126 | void sendDeathMessage(const std::string& message, unsigned int clientID) const; |
---|
| 127 | void sendStaticMessage(const std::string& message, unsigned int clientID, const ColourValue& colour) const; |
---|
| 128 | void sendFadingMessage(const std::string& message, unsigned int clientID) const; |
---|
[3099] | 129 | |
---|
[9348] | 130 | void dispatchAnnounceMessage(const std::string& message) const; |
---|
| 131 | void dispatchKillMessage(const std::string& message) const; |
---|
| 132 | void dispatchDeathMessage(const std::string& message) const; |
---|
| 133 | void dispatchStaticMessage(const std::string& message,const ColourValue& colour) const; |
---|
| 134 | void dispatchFadingMessage(const std::string& message) const; |
---|
[11358] | 135 | void setStartCountdown(float countdown); // Set the start countdown to the input value. |
---|
[9348] | 136 | |
---|
[11358] | 137 | |
---|
[8706] | 138 | protected: |
---|
| 139 | void start(void); // Inform the GametypeInfo that the game has started. |
---|
| 140 | void end(void); // Inform the GametypeInfo that the game has ended. |
---|
| 141 | void countdownStartCountdown(float countDown); // Count down the start countdown by the specified value. |
---|
| 142 | void countDown(); // Count down the start countdown counter. |
---|
| 143 | void startStartCountdown(void); // Inform the GametypeInfo about the start of the start countdown. |
---|
| 144 | void stopStartCountdown(void); // Inform the GametypeInfo about the stop of the start countdown. |
---|
| 145 | void playerReadyToSpawn(PlayerInfo* player); // Inform the GametypeInfo about a player that is ready to spawn. |
---|
| 146 | void pawnKilled(PlayerInfo* player); // Inform the GametypeInfo about a player whose Pawn has been killed. |
---|
| 147 | void playerSpawned(PlayerInfo* player); // Inform the GametypeInfo about a player that has spawned. |
---|
| 148 | void playerEntered(PlayerInfo* player); // Inform the GametypeInfo about a player that has entered, |
---|
[3099] | 149 | |
---|
[8706] | 150 | inline void setHUDTemplate(const std::string& templateName) |
---|
| 151 | { this->hudtemplate_ = templateName; }; |
---|
| 152 | |
---|
[2428] | 153 | private: |
---|
[7163] | 154 | void registerVariables(); |
---|
[8706] | 155 | void setSpawnedHelper(PlayerInfo* player, bool spawned); // Helper method. Sends changedReadyToSpawn notifiers over the network. |
---|
| 156 | void setReadyToSpawnHelper(PlayerInfo* player, bool ready); // Helper method. Sends changedSpawned notifiers over the network. |
---|
[7163] | 157 | |
---|
[8706] | 158 | static const std::string NOTIFICATION_SENDER; //!< The name of the sender for the sending of notifications. |
---|
| 159 | |
---|
| 160 | bool bStarted_; //!< Whether the game has started, |
---|
| 161 | bool bEnded_; //!< Whether the game has ended. |
---|
| 162 | bool bStartCountdownRunning_; //!< Whether the start countdown is running. |
---|
| 163 | float startCountdown_; //!< The current value of the start countdown. |
---|
| 164 | unsigned int counter_; //!< The current integer value of the start countdown, the start countdown counter. |
---|
[2826] | 165 | std::string hudtemplate_; |
---|
[9348] | 166 | |
---|
[8706] | 167 | std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned. |
---|
| 168 | bool spawned_; //!< Whether the local Player is currently spawned. |
---|
| 169 | bool readyToSpawn_; //!< Whether the local Player is ready to spawn. |
---|
[2428] | 170 | }; |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | #endif /* _GametypeInfo_H__ */ |
---|