Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

comments added

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#ifndef _PortalEndPoint_H__
2#define _PortalEndPoint_H__
3
4#include "portals/PortalsPrereqs.h"
5
6#include <set>
7#include <string>
8#include <map>
9
10#include "worldentities/StaticEntity.h"
11#include "graphics/Billboard.h"
12#include "objects/triggers/DistanceMultiTrigger.h"
13#include "core/EventIncludes.h"
14
15namespace orxonox
16{
17    class _PortalsExport PortalEndPoint : public StaticEntity
18    {
19        public:
20            PortalEndPoint(BaseObject* creator);
21            virtual ~PortalEndPoint();
22            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
23            inline void setTargets(const std::string & targets)                 //!< set types which are allowed to activate the PortalEndPoint
24            {
25                this->trigger_->addTargets(targets);
26            }
27           
28            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
29            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
30            inline void setID(unsigned int id)
31            {
32                this->id_ = id;
33            }
34           
35            inline unsigned int getID() const
36            {
37                return this->id_;
38            }
39           
40            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
41            inline void setTemplate(const std::string & name)
42            {
43                this->templateName_ = name;
44                this->addTemplate(name);
45            }
46
47            /// \brief Get the name of the attached design template
48            inline const std::string & getTemplate()
49            {
50                return this->templateName_;
51            }
52
53            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
54             * \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
55             * \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
56             *
57             * if bTriggered is \c true the triggering entity enters this portal (if it is an entrance)
58             * otherwise the triggering entity is removed from the set of entities who recently jumped out of this portal */
59            bool execute(bool bTriggered, BaseObject* trigger);
60
61            /*! \brief Let an Entity jump out of this portal no matter where it was before
62             * \param entity The Entity which should jump out of this portal */
63            void jumpOut(MobileEntity * entity);
64        protected:
65           
66        private:
67            static const std::string EVENTFUNCTIONNAME; //!< = "execute"
68           
69            unsigned int id_;            //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints
70            DistanceMultiTrigger * trigger_;      //!< the DistanceMultiTrigger which notices near entities of the defined type
71            std::string templateName_;            //!< The name of the design template used for this endpoint
72
73            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
74    };
75
76}
77
78#endif /* _Portals_H__ */
Note: See TracBrowser for help on using the repository browser.