Changeset 8767 for code/trunk/src/modules/portals
- Timestamp:
- Jul 20, 2011, 11:27:45 PM (13 years ago)
- Location:
- code/trunk/src/modules/portals
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/portals/PortalEndPoint.cc
r8706 r8767 28 28 29 29 #include "PortalEndPoint.h" 30 31 #include <ctime> 32 33 #include "core/CoreIncludes.h" 30 34 #include "core/XMLPort.h" 35 36 #include "worldentities/MobileEntity.h" 37 31 38 #include "objects/triggers/MultiTriggerContainer.h" 39 32 40 #include "portals/PortalLink.h" 33 #include "worldentities/MobileEntity.h"34 #include <ctime>35 41 36 42 namespace orxonox 37 43 { 38 44 CreateFactory(PortalEndPoint); 39 45 40 46 /*static*/ const std::string PortalEndPoint::EVENTFUNCTIONNAME = "execute"; 41 47 … … 45 51 { 46 52 RegisterObject(PortalEndPoint); 47 53 48 54 this->trigger_ = new DistanceMultiTrigger(this); 49 55 this->trigger_->setName("portal"); 50 this->attach(t rigger_);56 this->attach(this->trigger_); 51 57 52 58 this->setRadarObjectColour(ColourValue::White); … … 54 60 this->setRadarVisibility(true); 55 61 } 56 62 57 63 PortalEndPoint::~PortalEndPoint() 58 64 { … … 64 70 { 65 71 SUPER(PortalEndPoint, XMLPort, xmlelement, mode); 66 72 67 73 XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode); 68 74 XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode); … … 70 76 XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode); 71 77 XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn"); 72 78 73 79 // Add the DistanceMultiTrigger as event source. 74 80 this->addEventSource(this->trigger_, EVENTFUNCTIONNAME); 75 81 76 82 if(mode == XMLPort::LoadObject) 77 83 { … … 83 89 { 84 90 SUPER(PortalEndPoint, XMLEventPort, xmlelement, mode); 85 91 86 92 XMLPortEventSink(PortalEndPoint, BaseObject, EVENTFUNCTIONNAME, execute, xmlelement, mode); 87 93 } … … 91 97 if(!this->isActive()) 92 98 return true; 93 99 94 100 MultiTriggerContainer * cont = orxonox_cast<MultiTriggerContainer *>(trigger); 95 101 if(cont == 0) 96 102 return true; 97 103 98 104 DistanceMultiTrigger * originatingTrigger = orxonox_cast<DistanceMultiTrigger *>(cont->getOriginator()); 99 105 if(originatingTrigger == 0) … … 101 107 return true; 102 108 } 103 109 104 110 MobileEntity * entity = orxonox_cast<MobileEntity *>(cont->getData()); 105 111 if(entity == 0) 106 112 return true; 107 113 108 114 if(bTriggered) 109 115 { … … 117 123 this->recentlyJumpedOut_.erase(entity); 118 124 } 119 125 120 126 return true; 121 127 } … … 124 130 { 125 131 SUPER(PortalEndPoint, changedActivity); 126 132 127 133 this->setRadarVisibility(this->isActive()); 128 134 } -
code/trunk/src/modules/portals/PortalEndPoint.h
r8706 r8767 38 38 #include "portals/PortalsPrereqs.h" 39 39 40 #include <map> 40 41 #include <set> 41 42 #include <string> 42 #include <map> 43 44 #include "core/EventIncludes.h" 43 45 44 46 #include "worldentities/StaticEntity.h" 45 47 #include "interfaces/RadarViewable.h" 46 #include "graphics/Billboard.h"47 48 #include "objects/triggers/DistanceMultiTrigger.h" 48 #include "core/EventIncludes.h"49 #include <ctime>50 49 51 50 namespace orxonox … … 54 53 @brief 55 54 A PortalEndPoint serves as portal entrance and/or exit. 56 55 57 56 @ingroup Portals 58 57 */ 59 58 60 59 class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable 61 60 { … … 63 62 PortalEndPoint(BaseObject* creator); 64 63 virtual ~PortalEndPoint(); 65 64 66 65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 67 66 virtual void changedActivity(void); 68 67 69 68 inline void setTarget(const std::string & target) //!< add types which are allowed to activate the PortalEndPoint 70 69 { this->trigger_->addTarget(target); } 71 70 72 71 void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 73 72 static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint … … 78 77 inline void setID(unsigned int id) 79 78 { this->id_ = id; } 80 79 81 80 inline unsigned int getID() const 82 81 { return this->id_; } 83 82 84 83 /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object 85 84 inline void setTemplate(const std::string & name) … … 99 98 * \param entity The Entity which should jump out of this portal */ 100 99 void jumpOut(MobileEntity * entity); 101 100 102 101 /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint? 103 102 @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise … … 105 104 bool letsEnter(MobileEntity* entity); 106 105 protected: 107 106 108 107 private: 109 108 static const std::string EVENTFUNCTIONNAME; //!< = "execute" 110 109 111 110 unsigned int id_; //!< the hopefully (depends on the writer of the levelfile) unique id, which is used to establish links between PortalEndPoints 112 111 DistanceMultiTrigger * trigger_; //!< the DistanceMultiTrigger which notices near entities of the defined type -
code/trunk/src/modules/portals/PortalLink.cc
r8706 r8767 28 28 29 29 #include "PortalLink.h" 30 31 #include "core/CoreIncludes.h" 30 32 #include "core/XMLPort.h" 31 #include "objects/triggers/MultiTriggerContainer.h" 33 32 34 #include "worldentities/MobileEntity.h" 33 35 … … 37 39 38 40 std::map<PortalEndPoint *, PortalEndPoint *> PortalLink::links_s; 39 41 40 42 PortalLink::PortalLink(BaseObject* creator) : BaseObject(creator), fromID_(0), toID_(0), from_(0), to_(0) 41 43 { 42 44 RegisterObject(PortalLink); 43 45 } 44 46 45 47 PortalLink::~PortalLink() 46 48 { 47 49 48 50 } 49 51 50 52 void PortalLink::XMLPort(Element& xmlelement, XMLPort::Mode mode) 51 53 { … … 54 56 XMLPortParam(PortalLink, "toID", setToID, getToID, xmlelement, mode); 55 57 58 // Beware: This means, that the PortalEndPoints must exist before the PortalLink is created. 56 59 if(mode == XMLPort::LoadObject) 57 60 { … … 65 68 { 66 69 if(entrance == 0) 67 {68 70 return; 69 } 70 71 71 72 std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance); 72 73 73 if(endpoints == PortalLink::links_s.end()) // entrance has no corresponding exit 74 74 return; -
code/trunk/src/modules/portals/PortalLink.h
r8706 r8767 37 37 38 38 #include "portals/PortalsPrereqs.h" 39 #include "tools/interfaces/Tickable.h"40 #include "core/BaseObject.h"41 #include "PortalEndPoint.h"42 #include "objects/eventsystem/EventListener.h"43 39 44 40 #include <map> 41 42 #include "PortalEndPoint.h" 43 44 #include "core/BaseObject.h" 45 45 46 46 namespace orxonox … … 57 57 virtual ~PortalLink(); 58 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 59 59 60 inline void setFromID(unsigned int from) //!< set the ID of the PortalEndPoint which should act as the entrance of this link 60 { 61 this->fromID_ = from; 62 } 61 { this->fromID_ = from; } 63 62 inline unsigned int getFromID(unsigned int) const 64 { 65 return this->fromID_; 66 } 63 { return this->fromID_; } 67 64 inline void setToID(unsigned int to) //!< set the ID of the PortalEndPoint which should act as the exit of this link 68 { 69 this->toID_ = to; 70 } 65 { this->toID_ = to; } 71 66 inline unsigned int getToID(unsigned int) const 72 { 73 return this->toID_; 74 } 67 { return this->toID_; } 75 68 /*! \brief Let an entity enter a certain PortalEndPoint 76 69 \param entity pointer to the entity which is entering a PortalEndPoint
Note: See TracChangeset
for help on using the changeset viewer.