Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/pickupsFS14/src/libraries/core/GameState.h @ 10034

Last change on this file since 10034 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
Line 
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
31@ingroup Management CoreGame
32@brief
33    Definition of GameState class.
34*/
35
36#ifndef _GameState_H__
37#define _GameState_H__
38
39#include "CorePrereqs.h"
40
41#include <map>
42#include <string>
43#include "util/UtilPrereqs.h"
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    */
61    class _CoreExport GameState
62    {
63        friend class Game;
64
65    public:
66        /**
67        @brief
68            Gives information about what the GameState is currently doing
69        */
70        struct State
71        {
72            unsigned active       : 1;
73            unsigned activating   : 1;
74            unsigned deactivating : 1;
75            unsigned updating     : 1;
76            unsigned suspended    : 1;
77            unsigned topState     : 1;
78        };
79
80    public:
81        GameState(const GameStateInfo& info);
82        virtual ~GameState();
83
84        const std::string& getName()   const;
85        State getActivity()            const { return activity_; }
86        const GameStateInfo& getInfo() const { return info_; }
87
88    protected:
89        virtual void activate() { }
90        virtual void deactivate() { }
91        virtual void update(const Clock& time) { }
92
93    private:
94        void setActivity(State activity);
95        void activateInternal();
96        void deactivateInternal();
97        void updateInternal(const Clock& time);
98
99        const GameStateInfo& info_;
100        State                activity_;
101    };
102}
103
104#endif /* _GameState_H__ */
Note: See TracBrowser for help on using the repository browser.