Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/gametypes/Gametype.h @ 6106

Last change on this file since 6106 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

  • Property svn:eol-style set to native
File size: 6.0 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"
[5929]39#include "core/SubclassIdentifier.h"
[5693]40#include "tools/interfaces/Tickable.h"
[5735]41#include "infos/GametypeInfo.h"
[2072]42
43namespace orxonox
44{
[2171]45    namespace PlayerState
46    {
[3280]47        enum Value
[2171]48        {
49            Uninitialized,
50            Joined,
51            Alive,
52            Dead
53        };
54    }
55
[2662]56    struct Player
57    {
58        PlayerInfo* info_;
[3280]59        PlayerState::Value state_;
[2662]60        int frags_;
61        int killed_;
62    };
63
[2072]64    class _OrxonoxExport Gametype : public BaseObject, public Tickable
65    {
66        friend class PlayerInfo;
67
68        public:
69            Gametype(BaseObject* creator);
[5929]70            virtual ~Gametype();
[2072]71
[2662]72            void setConfigValues();
73
[2072]74            virtual void tick(float dt);
75
[2662]76            inline const GametypeInfo* getGametypeInfo() const
[5929]77                { return this->gtinfo_; }
[2662]78
[2072]79            inline bool hasStarted() const
[5929]80                { return this->gtinfo_->bStarted_; }
[2072]81            inline bool hasEnded() const
[5929]82                { return this->gtinfo_->bEnded_; }
[2072]83
84            virtual void start();
85            virtual void end();
86            virtual void playerEntered(PlayerInfo* player);
[2826]87            virtual bool playerLeft(PlayerInfo* player);
[2072]88            virtual void playerSwitched(PlayerInfo* player, Gametype* newgametype);
89            virtual void playerSwitchedBack(PlayerInfo* player, Gametype* oldgametype);
[2826]90            virtual bool playerChangedName(PlayerInfo* player);
[2072]91
[2826]92            virtual void playerScored(PlayerInfo* player);
[2072]93
[2826]94            virtual bool allowPawnHit(Pawn* victim, Pawn* originator = 0);
95            virtual bool allowPawnDamage(Pawn* victim, Pawn* originator = 0);
96            virtual bool allowPawnDeath(Pawn* victim, Pawn* originator = 0);
97
[2072]98            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
99            virtual void pawnPreSpawn(Pawn* pawn);
100            virtual void pawnPostSpawn(Pawn* pawn);
[2826]101            virtual void playerPreSpawn(PlayerInfo* player);
102            virtual void playerPostSpawn(PlayerInfo* player);
[2072]103
[2826]104            virtual void playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn);
105            virtual void playerStopsControllingPawn(PlayerInfo* player, Pawn* pawn);
106
[2662]107            inline const std::map<PlayerInfo*, Player>& getPlayers() const
[2072]108                { return this->players_; }
109
[2890]110            int getScore(PlayerInfo* player) const;
111
[2072]112            inline void registerSpawnPoint(SpawnPoint* spawnpoint)
113                { this->spawnpoints_.insert(spawnpoint); }
114
115            inline bool isStartCountdownRunning() const
[5929]116                { return this->gtinfo_->bStartCountdownRunning_; }
[2072]117            inline float getStartCountdown() const
[5929]118                { return this->gtinfo_->startCountdown_; }
[2072]119
[2826]120            inline void setHUDTemplate(const std::string& name)
[5929]121                { this->gtinfo_->hudtemplate_ = name; }
[2826]122            inline const std::string& getHUDTemplate() const
[5929]123                { return this->gtinfo_->hudtemplate_; }
[2826]124
[2662]125            void addBots(unsigned int amount);
126            void killBots(unsigned int amount = 0);
127
128            inline unsigned int getNumberOfPlayers() const
129                { return this->players_.size(); }
130
[3033]131            virtual void addTime(float t);
132            virtual void removeTime(float t);
133
134            inline  void startTimer()
[5693]135            {
[3033]136                this->time_ = this->timeLimit_;
137                this->timerIsActive_ = true;
138            }
139
140            inline void stopTimer()
141              { this->timerIsActive_ = false; }
142
143            inline float getTime()
144              { return this->time_; }
145
146            inline bool getTimerIsActive()
147              { return timerIsActive_; }
148
149            inline void setTimeLimit(float t)
150              { this->timeLimit_ = t; }
151
152            virtual void resetTimer();
153            virtual void resetTimer(float t);
154
[2826]155        protected:
[2072]156            virtual SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
157
[2826]158            virtual void assignDefaultPawnsIfNeeded();
159            virtual void checkStart();
160            virtual void spawnPlayer(PlayerInfo* player);
[3033]161            virtual void spawnPlayerAsDefaultPawn(PlayerInfo* player);
[2826]162            virtual void spawnPlayersIfRequested();
163            virtual void spawnDeadPlayersIfRequested();
[2072]164
[5929]165            SmartPtr<GametypeInfo> gtinfo_;
[2662]166
[2072]167            bool bAutoStart_;
168            bool bForceSpawn_;
169
[3033]170            float time_;
171            float timeLimit_;
172            bool timerIsActive_;
173
[2072]174            float initialStartCountdown_;
[2662]175            unsigned int numberOfBots_;
[2839]176            SubclassIdentifier<Bot> botclass_;
[2072]177
[2662]178            std::map<PlayerInfo*, Player> players_;
[2072]179            std::set<SpawnPoint*> spawnpoints_;
180            SubclassIdentifier<ControllableEntity> defaultControllableEntity_;
[2662]181
182            OverlayGroup* scoreboard_;
183
184            // Config Values
185            std::string scoreboardTemplate_;
[5929]186           
187            /* HACK HACK HACK */
188            ConsoleCommand* hackAddBots_;
189            ConsoleCommand* hackKillBots_;
190            /* HACK HACK HACK */
[2072]191    };
192}
193
194#endif /* _Gametype_H__ */
Note: See TracBrowser for help on using the repository browser.