[8466] | 1 | /** |
---|
| 2 | * @file PortalEndPoint.h |
---|
| 3 | * @brief Declaration of the PortalEndPoint class. |
---|
| 4 | * @ingroup Portals |
---|
| 5 | */ |
---|
| 6 | |
---|
[8177] | 7 | #ifndef _PortalEndPoint_H__ |
---|
| 8 | #define _PortalEndPoint_H__ |
---|
| 9 | |
---|
[8200] | 10 | #include "portals/PortalsPrereqs.h" |
---|
| 11 | |
---|
[8177] | 12 | #include <set> |
---|
| 13 | #include <string> |
---|
| 14 | #include <map> |
---|
| 15 | |
---|
[8200] | 16 | #include "worldentities/StaticEntity.h" |
---|
[8177] | 17 | #include "graphics/Billboard.h" |
---|
[8200] | 18 | #include "objects/triggers/DistanceMultiTrigger.h" |
---|
[8243] | 19 | #include "core/EventIncludes.h" |
---|
[8177] | 20 | |
---|
| 21 | namespace orxonox |
---|
| 22 | { |
---|
[8466] | 23 | /** |
---|
| 24 | @brief |
---|
| 25 | A PortalEndPoint serves as portal entrance and/or exit. |
---|
| 26 | |
---|
| 27 | @ingroup Portals |
---|
| 28 | */ |
---|
| 29 | |
---|
[8243] | 30 | class _PortalsExport PortalEndPoint : public StaticEntity |
---|
[8177] | 31 | { |
---|
| 32 | public: |
---|
| 33 | PortalEndPoint(BaseObject* creator); |
---|
| 34 | virtual ~PortalEndPoint(); |
---|
| 35 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[8457] | 36 | inline void setTarget(const std::string & target) //!< add types which are allowed to activate the PortalEndPoint |
---|
[8243] | 37 | { |
---|
[8457] | 38 | this->trigger_->addTarget(target); |
---|
[8243] | 39 | } |
---|
| 40 | |
---|
| 41 | void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[8454] | 42 | static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint |
---|
[8177] | 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 | } |
---|
[8454] | 52 | |
---|
| 53 | /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object |
---|
[8243] | 54 | inline void setTemplate(const std::string & name) |
---|
| 55 | { |
---|
| 56 | this->templateName_ = name; |
---|
| 57 | this->addTemplate(name); |
---|
| 58 | } |
---|
[8454] | 59 | |
---|
| 60 | /// \brief Get the name of the attached design template |
---|
[8243] | 61 | inline const std::string & getTemplate() |
---|
| 62 | { |
---|
| 63 | return this->templateName_; |
---|
| 64 | } |
---|
[8454] | 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 */ |
---|
[8243] | 72 | bool execute(bool bTriggered, BaseObject* trigger); |
---|
[8454] | 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 */ |
---|
[8243] | 76 | void jumpOut(MobileEntity * entity); |
---|
[8177] | 77 | protected: |
---|
[8290] | 78 | |
---|
[8177] | 79 | private: |
---|
[8454] | 80 | static const std::string EVENTFUNCTIONNAME; //!< = "execute" |
---|
[8290] | 81 | |
---|
[8454] | 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 |
---|
[8290] | 85 | |
---|
[8243] | 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 |
---|
[8177] | 87 | }; |
---|
| 88 | |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | #endif /* _Portals_H__ */ |
---|