Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/animated_space_boundaries/src/modules/portals/PortalEndPoint.h @ 10181

Last change on this file since 10181 was 8645, checked in by landauf, 14 years ago

set svn:eol-style to native, removed svn:executable property. no code changes.

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