[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" |
---|
[8511] | 20 | #include <ctime> |
---|
[8177] | 21 | |
---|
| 22 | namespace orxonox |
---|
| 23 | { |
---|
[8466] | 24 | /** |
---|
| 25 | @brief |
---|
| 26 | A PortalEndPoint serves as portal entrance and/or exit. |
---|
| 27 | |
---|
| 28 | @ingroup Portals |
---|
| 29 | */ |
---|
| 30 | |
---|
[8243] | 31 | class _PortalsExport PortalEndPoint : public StaticEntity |
---|
[8177] | 32 | { |
---|
| 33 | public: |
---|
| 34 | PortalEndPoint(BaseObject* creator); |
---|
| 35 | virtual ~PortalEndPoint(); |
---|
| 36 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[8457] | 37 | inline void setTarget(const std::string & target) //!< add types which are allowed to activate the PortalEndPoint |
---|
[8243] | 38 | { |
---|
[8457] | 39 | this->trigger_->addTarget(target); |
---|
[8243] | 40 | } |
---|
| 41 | |
---|
| 42 | void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); |
---|
[8454] | 43 | static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint |
---|
[8511] | 44 | inline void setReenterDelay(unsigned int seconds) |
---|
| 45 | { |
---|
| 46 | this->reenterDelay_ = seconds; |
---|
| 47 | } |
---|
| 48 | inline unsigned int getReenterDelay() |
---|
| 49 | { |
---|
| 50 | return this->reenterDelay_; |
---|
| 51 | } |
---|
[8177] | 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 | } |
---|
[8454] | 61 | |
---|
| 62 | /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object |
---|
[8243] | 63 | inline void setTemplate(const std::string & name) |
---|
| 64 | { |
---|
| 65 | this->templateName_ = name; |
---|
| 66 | this->addTemplate(name); |
---|
| 67 | } |
---|
[8454] | 68 | |
---|
| 69 | /// \brief Get the name of the attached design template |
---|
[8243] | 70 | inline const std::string & getTemplate() |
---|
| 71 | { |
---|
| 72 | return this->templateName_; |
---|
| 73 | } |
---|
[8454] | 74 | |
---|
| 75 | /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed |
---|
[8511] | 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 | */ |
---|
[8243] | 79 | bool execute(bool bTriggered, BaseObject* trigger); |
---|
[8454] | 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 */ |
---|
[8243] | 83 | void jumpOut(MobileEntity * entity); |
---|
[8511] | 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); |
---|
[8177] | 89 | protected: |
---|
[8290] | 90 | |
---|
[8177] | 91 | private: |
---|
[8454] | 92 | static const std::string EVENTFUNCTIONNAME; //!< = "execute" |
---|
[8290] | 93 | |
---|
[8454] | 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 |
---|
[8290] | 97 | |
---|
[8511] | 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_; |
---|
[8177] | 101 | }; |
---|
| 102 | |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #endif /* _Portals_H__ */ |
---|