Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.h @ 10817

Last change on this file since 10817 was 10817, checked in by muemart, 9 years ago

Run clang-modernize -add-override
A few notes:

  • There are probably some overrides missing, especially in funky templatey code
  • Virtual methods with wrong signatures were not fixed, needs to be done by hand (only warnings get emitted)
  • Property svn:eol-style set to native
File size: 6.8 KB
RevLine 
[2072]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:
25 *      ...
26 *
27 */
28
29#ifndef _Gametype_H__
30#define _Gametype_H__
31
32#include "OrxonoxPrereqs.h"
33
34#include <map>
[3196]35#include <set>
36#include <string>
[2072]37
38#include "core/BaseObject.h"
[9667]39#include "core/class/SubclassIdentifier.h"
[5693]40#include "tools/interfaces/Tickable.h"
[5735]41#include "infos/GametypeInfo.h"
[9980]42#include "tools/Timer.h"
[10281]43#include "gamestates/GSLevelMemento.h"
[2072]44
45namespace orxonox
46{
[2171]47    namespace PlayerState
48    {
[3280]49        enum Value
[2171]50        {
51            Uninitialized,
52            Joined,
53            Alive,
54            Dead
55        };
56    }
57
[2662]58    struct Player
59    {
60        PlayerInfo* info_;
[3280]61        PlayerState::Value state_;
[2662]62        int frags_;
63        int killed_;
64    };
65
[10281]66    class _OrxonoxExport Gametype : public BaseObject, public Tickable, public GSLevelMemento
[2072]67    {
68        friend class PlayerInfo;
69
70        public:
[9667]71            Gametype(Context* context);
[5929]72            virtual ~Gametype();
[2072]73
[10624]74            virtual void init();
75
[2662]76            void setConfigValues();
77
[10817]78            virtual void tick(float dt) override;
[2072]79
[2662]80            inline const GametypeInfo* getGametypeInfo() const
[5929]81                { return this->gtinfo_; }
[2662]82
[2072]83            inline bool hasStarted() const
[8706]84                { return this->gtinfo_->hasStarted(); }
[2072]85            inline bool hasEnded() const
[8706]86                { return this->gtinfo_->hasEnded(); }
[2072]87
88            virtual void start();
89            virtual void end();
90            virtual void playerEntered(PlayerInfo* player);
[2826]91            virtual bool playerLeft(PlayerInfo* player);
[2072]92            virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
93            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
[2826]94            virtual bool playerChangedName(PlayerInfo* player);
[2072]95
[9348]96            virtual void playerScored(PlayerInfo* player, int score = 1);
[2072]97
[10768]98            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = nullptr);
99            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = nullptr);
100            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = nullptr);
[2826]101
[10768]102            virtual void pawnKilled(Pawn* victim, Pawn* killer = nullptr);
[2072]103            virtual void pawnPreSpawn(Pawn* pawn);
104            virtual void pawnPostSpawn(Pawn* pawn);
[2826]105            virtual void playerPreSpawn(PlayerInfo* player);
106            virtual void playerPostSpawn(PlayerInfo* player);
[2072]107
[2826]108            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
109            virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);
110
[2662]111            inline const std::map<PlayerInfo*, Player>& getPlayers() const
[2072]112                { return this->players_; }
113
[2890]114            int getScore(PlayerInfo* player) const;
115
[2072]116            inline void registerSpawnPoint(SpawnPoint* spawnpoint)
117                { this->spawnpoints_.insert(spawnpoint); }
118
119            inline bool isStartCountdownRunning() const
[8706]120                { return this->gtinfo_->isStartCountdownRunning(); }
[2072]121            inline float getStartCountdown() const
[8706]122                { return this->gtinfo_->getStartCountdown(); }
[2072]123
[2826]124            inline void setHUDTemplate(const std::string& name)
[8706]125                { this->gtinfo_->setHUDTemplate(name); }
[2826]126            inline const std::string& getHUDTemplate() const
[8706]127                { return this->gtinfo_->getHUDTemplate(); }
[2826]128
[9016]129            virtual void addBots(unsigned int amount);
[2662]130            void killBots(unsigned int amount = 0);
131
[3033]132            virtual void addTime(float t);
133            virtual void removeTime(float t);
134
135            inline  void startTimer()
[5693]136            {
[3033]137                this->time_ = this->timeLimit_;
138                this->timerIsActive_ = true;
139            }
140
141            inline void stopTimer()
142              { this->timerIsActive_ = false; }
143
144            inline float getTime()
145              { return this->time_; }
146
147            inline bool getTimerIsActive()
148              { return timerIsActive_; }
149
150            inline void setTimeLimit(float t)
151              { this->timeLimit_ = t; }
152
[8178]153            //inline bool getForceSpawn()
[9016]154            //  { return this->bForceSpawn_; }
[8178]155
[3033]156            virtual void resetTimer();
157            virtual void resetTimer(float t);
158
[9348]159            /**
160            @brief Get number of Players in game.
161            */
[9260]162            inline unsigned int getNumberOfPlayers() const
[9348]163                { return this->players_.size(); }
[9977]164            void showMenu();
[9016]165
[9348]166
[2826]167        protected:
[2072]168            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
169
[2826]170            virtual void assignDefaultPawnsIfNeeded();
171            virtual void checkStart();
172            virtual void spawnPlayer(PlayerInfo* player);
[3033]173            virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player);
[2826]174            virtual void spawnPlayersIfRequested();
175            virtual void spawnDeadPlayersIfRequested();
[2072]176
[10817]177            virtual GSLevelMementoState* exportMementoState() override;
178            virtual void importMementoState(const std::vector<GSLevelMementoState*>& states) override;
[10281]179
[10624]180            WeakPtr<GametypeInfo> gtinfo_;
[2662]181
[2072]182            bool bAutoStart_;
183            bool bForceSpawn_;
[9977]184            bool bAutoEnd_;
[2072]185
[3033]186            float time_;
187            float timeLimit_;
188            bool timerIsActive_;
189
[2072]190            float initialStartCountdown_;
[2662]191            unsigned int numberOfBots_;
[2839]192            SubclassIdentifier<Bot> botclass_;
[2072]193
[2662]194            std::map<PlayerInfo*, Player> players_;
[2072]195            std::set<SpawnPoint*> spawnpoints_;
196            SubclassIdentifier<ControllableEntity> defaultControllableEntity_;
[2662]197
198            OverlayGroup* scoreboard_;
199
200            // Config Values
201            std::string scoreboardTemplate_;
[7801]202
[9980]203            Timer showMenuTimer_;
[2072]204    };
[10281]205
206    /**
207        @brief Keeps position and orientation of the camera, as well as the name of current scene.
208    */
209    struct _OrxonoxExport GametypeMementoState : public GSLevelMementoState
210    {
211        Vector3 cameraPosition_;
212        Quaternion cameraOrientation_;
213        std::string sceneName_;
214    };
[2072]215}
216
217#endif /* _Gametype_H__ */
Note: See TracBrowser for help on using the repository browser.