Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/orxonox/objects/quest/QuestEffectBeacon.h @ 2581

Last change on this file since 2581 was 2251, checked in by dafrick, 16 years ago

Some cleanup…

File size: 4.8 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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file QuestEffectBeacon.h
31    @brief
32    Definition of the QuestEffectBeacon class.
33*/
34
35#ifndef _QuestEffectBeacon_H__
36#define _QuestEffectBeacon_H__
37
38#include "OrxonoxPrereqs.h"
39
40#include "orxonox/objects/worldentities/PositionableEntity.h"
41
42namespace QuestEffectBeaconStatus
43{
44
45    //! The status of the beacon, can be either active or inactive.
46    enum Enum
47    {
48        inactive,
49        active
50    };
51
52}
53
54namespace orxonox {
55
56    /**
57    @brief
58        A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number QuestEffects on players meeting the condition(s).
59        The conditions under which the QuestEffects are invoked on the player are defined by Triggers.
60        A QuestEffectBeacon can be executed a defined number of times.
61        A QuestEffectBeacon can be inactive or active.
62       
63    Creating a QuestEffectBeacon through XML goes as follows:
64   
65    <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
66            <effects>
67                <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
68                ...
69                <QuestEffect />
70            </effects>
71            <events>
72        <execute>
73            <EventListener event=eventIdString />
74        </execute>
75        </events>
76        <attached>
77           <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
78        </attached>
79    </QuestEffectBeacon>
80    @author
81        Damian 'Mozork' Frick
82    */
83    class _OrxonoxExport QuestEffectBeacon : public PositionableEntity
84    {
85    public:
86        QuestEffectBeacon(BaseObject* creator);
87        virtual ~QuestEffectBeacon();
88       
89        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
90       
91        virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
92       
93        bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
94       
95        /**
96        @brief Tests whether the QuestEffectBeacon is active.
97        @return Returns true if the QuestEffectBeacon is active, fals if not.
98        */
99        inline bool isActive(void)
100           { return this->status_ == QuestEffectBeaconStatus::active; }
101       
102        bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
103       
104    protected:
105            bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
106           
107            /**
108            @brief Returns the number of times the QUestEffectBeacon can still be executed.
109            @return Returns the number of times the QUestEffectBeacon can still be executed.
110            */
111            inline const int & getTimes(void) const
112                { return this->times_; }
113
114        private:
115            static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
116       
117            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
118            int times_; //!< Number of times the beacon can be exectued.
119            QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
120           
121            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
122            bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
123           
124            const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
125   
126    };
127
128}
129
130#endif /* _QuestEffectBeacon_H__ */
Note: See TracBrowser for help on using the repository browser.