Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/questsystem/QuestEffectBeacon.h @ 10512

Last change on this file since 10512 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 5.5 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 Definition of the QuestEffectBeacon class.
32    @ingroup Questsystem
33*/
34
35#ifndef _QuestEffectBeacon_H__
36#define _QuestEffectBeacon_H__
37
38#include "questsystem/QuestsystemPrereqs.h"
39
40#include <list>
41#include "worldentities/StaticEntity.h"
42
43namespace orxonox
44{
45
46    /**
47    @brief
48        The status of the @ref orxonox::QuestEffectBeacon "QuestEffectBeacon", can be either active or inactive.
49
50    @ingroup Questsystem
51    */
52    namespace QuestEffectBeaconStatus
53    {
54        enum Value
55        {
56            Inactive, //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is inactive.
57            Active //!< The @ref orxonox::QuestEffectBeacon "QuestEffectBeacon" is active.
58        };
59    }
60
61    /**
62    @brief
63        A QuestEffectBeacon is a physical entity in the game which can (under some condition(s)) invoke a number of @ref orxonox::QuestEffect "QuestEffects" on players meeting the condition(s).
64        The conditions under which the @ref orxonox::QuestEffect "QuestEffects" are invoked on the player are defined by @ref orxonox::Trigger "Triggers" (or really any kind of entity firing events, e.g. @ref orxonox::EventListener "EventListeners"). The trigger the event originates from, however has to be a @ref orxonox::PlayerTrigger PlayerTrigger.
65        A QuestEffectBeacon can be executed a defined number of times.
66        A QuestEffectBeacon can be inactive or active. While inactive it can't be executed.
67
68        Creating a QuestEffectBeacon through XML goes as follows:
69        @code
70        <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.
71            <effects>
72                <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
73                ...
74                <QuestEffect />
75            </effects>
76            <events>
77                <execute>
78                    <EventListener event=eventIdString />
79                </execute>
80            </events>
81            <attached>
82                <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
83            </attached>
84        </QuestEffectBeacon>
85        @endcode
86
87    @author
88        Damian 'Mozork' Frick
89
90    @ingroup Questsystem
91    */
92    class _QuestsystemExport QuestEffectBeacon : public StaticEntity
93    {
94        public:
95            QuestEffectBeacon(Context* context);
96            virtual ~QuestEffectBeacon();
97
98            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
99            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
100
101            bool execute(bool bTriggered, BaseObject* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
102
103            /**
104            @brief Tests whether the QuestEffectBeacon is active.
105            @return Returns true if the QuestEffectBeacon is active, fals if not.
106            */
107            inline bool isActive(void)
108            { return this->status_ == QuestEffectBeaconStatus::Active; }
109
110            bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
111
112        protected:
113            bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
114
115            /**
116            @brief Returns the number of times the QUestEffectBeacon can still be executed.
117            @return Returns the number of times the QUestEffectBeacon can still be executed.
118            */
119            inline const int & getTimes(void) const
120                { return this->times_; }
121
122        private:
123            static const int INFINITE_TIME = -1; //!< Constant to avoid using magic numbers.
124
125            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
126            int times_; //!< Number of times the beacon can be exectued.
127            QuestEffectBeaconStatus::Value status_; //!< The status of the QuestEffectBeacon, Can be eighter active or inactive.
128
129            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
130            bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
131
132            const QuestEffect* getEffect(unsigned int index) const; //!< Get the QuestEffect at a given index.
133
134    };
135
136}
137
138#endif /* _QuestEffectBeacon_H__ */
Note: See TracBrowser for help on using the repository browser.