Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/PLehmann_FS16/src/modules/portals/PortalEndPoint.h @ 12141

Last change on this file since 12141 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 5.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 *      Andreas Büchel
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30 *  @file PortalEndPoint.h
31 *  @brief Declaration of the PortalEndPoint class.
32 *  @ingroup Portals
33 */
34
35#ifndef _PortalEndPoint_H__
36#define _PortalEndPoint_H__
37
38#include "portals/PortalsPrereqs.h"
39
40#include <map>
41#include <set>
42#include <string>
43
44#include "core/EventIncludes.h"
45
46#include "worldentities/StaticEntity.h"
47#include "interfaces/RadarViewable.h"
48#include "objects/triggers/DistanceMultiTrigger.h"
49
50namespace orxonox
51{
52    /**
53     @brief
54     A PortalEndPoint serves as portal entrance and/or exit.
55
56     @ingroup Portals
57     */
58
59    class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
60    {
61        public:
62            PortalEndPoint(Context* context);
63            virtual ~PortalEndPoint();
64
65            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
66            virtual void changedActivity(void) override;
67
68            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
69                { this->trigger_->addTarget(target); }
70
71            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
72            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
73            inline void setReenterDelay(unsigned int seconds)
74                { this->reenterDelay_ = seconds; }
75            inline unsigned int getReenterDelay()
76                { return this->reenterDelay_; }
77            inline void setID(unsigned int id)
78                { this->id_ = id; }
79
80            inline unsigned int getID() const
81                { return this->id_; }
82
83            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
84            inline void setTemplate(const std::string & name)
85                { this->templateName_ = name; this->addTemplate(name); }
86
87            /// \brief Get the name of the attached design template
88            inline const std::string & getTemplate()
89                { return this->templateName_; }
90
91            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
92                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
93                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
94            */
95            bool execute(bool bTriggered, BaseObject* trigger);
96
97            /*! \brief Let an Entity jump out of this portal no matter where it was before
98             * \param entity The Entity which should jump out of this portal */
99            void jumpOut(MobileEntity * entity);
100
101            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
102                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
103            */
104            bool letsEnter(MobileEntity* entity);
105        protected:
106
107        private:
108            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
109
110            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
111            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
112            std::string templateName_;            //!< The name of the design template used for this endpoint
113
114            int reenterDelay_;
115            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
116            std::set<MobileEntity *> recentlyJumpedOut_;   //!< Stores the entities witch recently jumped out of this PortalEndPoint and haven't left the activation radius yet. This is needed in order to prevent them from beeing pulled into the PortalEndPoint they have just come out of.
117
118            WorldSound* portalSound_;
119    };
120
121}
122
123#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.