Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6852 was 6800, checked in by dafrick, 15 years ago

Created a new class of triggers called Multitriggers.
MultiTriggers are triggers which (as opposed to normal triggers) have a state for each object triggering the MultiTrigger, that means, that a MultiTrigger can be triggered for two different Players, while not being triggered for a third.
To go with this MultiTrigger I created a data structure (MultitriggerContainer), which helps relaying important information to the objects, that receive the Events of the trigger.
Also there is a MultiDistanceTrigger, which is just the DistanceTrigger as a MultiTrigger.

To make this work I had to make some adjustements to the eventsystem, namely an EventState can now be either an EventState (as it was before) or an EventSink, which means that every efent arriving at the EventState is processed as opposed to just the ones which change the state.
There is a new makro (XMLPortEventSink) to create an EventState with sink behaviour. It can be used exacly as the XMLPortEventState makro.

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