Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/GameState.h @ 9589

Last change on this file since 9589 was 7401, checked in by landauf, 14 years ago

merged doc branch back to trunk

  • Property svn:eol-style set to native
File size: 3.0 KB
RevLine 
[1660]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 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30@file
[7401]31@ingroup Management CoreGame
[1660]32@brief
33    Definition of GameState class.
34*/
35
36#ifndef _GameState_H__
37#define _GameState_H__
38
39#include "CorePrereqs.h"
40
[3196]41#include <map>
[1660]42#include <string>
[5929]43#include "util/UtilPrereqs.h"
[1660]44
45namespace orxonox
46{
47    /**
48    @brief
49        An implementation of a tree to manage game states.
50        This leads to a certain hierarchy that is created at runtime.
51        To actually use the structure, you will have to derive from it and
52        implement 'enter', 'leave' and 'tick'. The latter corresponds to an
53        update function.
54
55        Internally the tree is managed by two maps per node: One stores all its
56        children, grandchildren, etc. by name of the state. The other maps these
57        children states to the actual child of the node.
58        An example: Foo is a grandchildren of Bar and Foofoo is the Foo's parent.
59        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
60    */
[2896]61    class _CoreExport GameState
[1660]62    {
[2896]63        friend class Game;
[1672]64
[1660]65    public:
[1672]66        /**
67        @brief
68            Gives information about what the GameState is currently doing
69        */
[2896]70        struct State
[1670]71        {
[2896]72            unsigned active       : 1;
73            unsigned activating   : 1;
74            unsigned deactivating : 1;
75            unsigned updating     : 1;
76            unsigned suspended    : 1;
77            unsigned topState     : 1;
[1670]78        };
79
[1672]80    public:
[3370]81        GameState(const GameStateInfo& info);
[2896]82        virtual ~GameState();
[1660]83
[3370]84        const std::string& getName()   const;
85        State getActivity()            const { return activity_; }
86        const GameStateInfo& getInfo() const { return info_; }
[1660]87
88    protected:
[3280]89        virtual void activate() { }
90        virtual void deactivate() { }
91        virtual void update(const Clock& time) { }
[1660]92
93    private:
[2896]94        void setActivity(State activity);
95        void activateInternal();
96        void deactivateInternal();
97        void updateInternal(const Clock& time);
[1688]98
[3370]99        const GameStateInfo& info_;
100        State                activity_;
[1660]101    };
102}
103
104#endif /* _GameState_H__ */
Note: See TracBrowser for help on using the repository browser.