Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8474 was 8466, checked in by anbueche, 14 years ago

comments added

  • Property svn:executable set to *
File size: 3.6 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
21namespace orxonox
22{
23    /**
24     @brief
25     A PortalEndPoint serves as portal entrance and/or exit.
26     
27     @ingroup Portals
28     */
29   
30    class _PortalsExport PortalEndPoint : public StaticEntity
31    {
32        public:
33            PortalEndPoint(BaseObject* creator);
34            virtual ~PortalEndPoint();
35            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
36            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
37            {
38                this->trigger_->addTarget(target);
39            }
40           
41            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
42            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
43            inline void setID(unsigned int id)
44            {
45                this->id_ = id;
46            }
47           
48            inline unsigned int getID() const
49            {
50                return this->id_;
51            }
52           
53            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
54            inline void setTemplate(const std::string & name)
55            {
56                this->templateName_ = name;
57                this->addTemplate(name);
58            }
59
60            /// \brief Get the name of the attached design template
61            inline const std::string & getTemplate()
62            {
63                return this->templateName_;
64            }
65
66            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
67             * \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
68             * \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
69             *
70             * if bTriggered is \c true the triggering entity enters this portal (if it is an entrance)
71             * otherwise the triggering entity is removed from the set of entities who recently jumped out of this portal */
72            bool execute(bool bTriggered, BaseObject* trigger);
73
74            /*! \brief Let an Entity jump out of this portal no matter where it was before
75             * \param entity The Entity which should jump out of this portal */
76            void jumpOut(MobileEntity * entity);
77        protected:
78           
79        private:
80            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
81           
82            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
83            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
84            std::string templateName_;            //!< The name of the design template used for this endpoint
85
86            std::set<MobileEntity *> recentlyJumpedOut_; //!< Entities which recently jumped out of this EndPoint, hence they shouldn't be pulled in again if the endpoint is the beginning of a link
87    };
88
89}
90
91#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.