Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/portals2/src/modules/portals/PortalEndPoint.h @ 8511

Last change on this file since 8511 was 8511, checked in by anbueche, 13 years ago

added reenter delay, added comments

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1/**
2 *  @file PortalEndPoint.h
3 *  @brief Declaration of the PortalEndPoint class.
4 *  @ingroup Portals
5 */
6
7#ifndef _PortalEndPoint_H__
8#define _PortalEndPoint_H__
9
10#include "portals/PortalsPrereqs.h"
11
12#include <set>
13#include <string>
14#include <map>
15
16#include "worldentities/StaticEntity.h"
17#include "graphics/Billboard.h"
18#include "objects/triggers/DistanceMultiTrigger.h"
19#include "core/EventIncludes.h"
20#include <ctime>
21
22namespace orxonox
23{
24    /**
25     @brief
26     A PortalEndPoint serves as portal entrance and/or exit.
27     
28     @ingroup Portals
29     */
30   
31    class _PortalsExport PortalEndPoint : public StaticEntity
32    {
33        public:
34            PortalEndPoint(BaseObject* creator);
35            virtual ~PortalEndPoint();
36            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
37            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
38            {
39                this->trigger_->addTarget(target);
40            }
41           
42            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
43            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
44            inline void setReenterDelay(unsigned int seconds)
45            {
46                this->reenterDelay_ = seconds;
47            }
48            inline unsigned int getReenterDelay()
49            {
50                return this->reenterDelay_;
51            }
52            inline void setID(unsigned int id)
53            {
54                this->id_ = id;
55            }
56           
57            inline unsigned int getID() const
58            {
59                return this->id_;
60            }
61           
62            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
63            inline void setTemplate(const std::string & name)
64            {
65                this->templateName_ = name;
66                this->addTemplate(name);
67            }
68
69            /// \brief Get the name of the attached design template
70            inline const std::string & getTemplate()
71            {
72                return this->templateName_;
73            }
74
75            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
76                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
77                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
78            */
79            bool execute(bool bTriggered, BaseObject* trigger);
80
81            /*! \brief Let an Entity jump out of this portal no matter where it was before
82             * \param entity The Entity which should jump out of this portal */
83            void jumpOut(MobileEntity * entity);
84           
85            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
86                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
87            */
88            bool letsEnter(MobileEntity* entity);
89        protected:
90           
91        private:
92            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
93           
94            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
95            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
96            std::string templateName_;            //!< The name of the design template used for this endpoint
97
98            int reenterDelay_;
99            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
100            std::set<MobileEntity *> recentlyJumpedOut_;
101    };
102
103}
104
105#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.