- Timestamp:
- Apr 6, 2011, 11:06:45 PM (14 years ago)
- Location:
- code/branches/portals/src/orxonox/worldentities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/portals/src/orxonox/worldentities/PortalEndPoint.cc
r8177 r8198 11 11 { 12 12 RegisterObject(PortalEndPoint); 13 trigger_.setDistance(10);14 trigger_.setStayActive(true);15 13 } 16 14 … … 29 27 if(mode == XMLPort::LoadObject) 30 28 { 31 idMap_s[this->id_] = this;29 PortalEndPoint::idMap_s[this->id_] = this; 32 30 } 33 31 } 32 33 void PortalEndPoint::tick(float dt) 34 { 35 SUPER(PortalEndPoint, tick); 36 } 37 38 void PortalEndPoint::jumpOut(WorldEntity* entity) 39 { 40 this->recentlyJumpedOut_.insert(entity); 41 entity->setPosition(this->getPosition()); 42 } 43 44 bool PortalEndPoint::hasRecentlyJumpedOut(WorldEntity* entity) 45 { 46 if(this->recentlyJumpedOut_.find(entity) == this->recentlyJumpedOut_.end()) 47 { 48 return false; 49 } 50 else 51 return true; 52 } 53 34 54 } -
code/branches/portals/src/orxonox/worldentities/PortalEndPoint.h
r8177 r8198 8 8 #include "StaticEntity.h" 9 9 #include "graphics/Billboard.h" 10 #include "objects/triggers/DistanceMultiTrigger.h" 11 #include "tools/interfaces/Tickable.h" 10 #include "../../modules/objects/triggers/DistanceMultiTrigger.h" 12 11 13 12 namespace orxonox 14 13 { 15 class _OrxonoxExport PortalEndPoint : public StaticEntity14 class _OrxonoxExport PortalEndPoint : public DistanceMultiTrigger 16 15 { 17 16 public: … … 20 19 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 21 20 //virtual void tick(float dt); 22 static std::map<unsigned int, PortalEndPoint *> idMap_s; 21 static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< maps integer id values to portalendpoints 23 22 inline void setID(unsigned int id) 24 23 { … … 30 29 return this->id_; 31 30 } 31 void jumpOut(WorldEntity * entity); //!< relocate an entity to the position of the endpoint and add it to the set of recentlyPortedOut entities 32 void tick(float dt); 33 bool hasRecentlyJumpedOut(WorldEntity * entity); //!< check if a certain entity recently jumped out of this endpoint 32 34 protected: 33 35 private: 34 36 unsigned int id_; 35 std::set<WorldEntity *> recentlyJumpedOut_; 36 std::string material_; 37 std::set<WorldEntity *> 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 37 38 Billboard billboard_; 38 DistanceMultiTrigger trigger_;39 39 }; 40 40 -
code/branches/portals/src/orxonox/worldentities/PortalLink.cc
r8177 r8198 1 1 #include "PortalLink.h" 2 2 #include "core/XMLPort.h" 3 #include "objects/triggers/MultiTriggerContainer.h" 3 4 4 5 namespace orxonox … … 29 30 } 30 31 31 void PortalLink::use(WorldEntity * entity)32 {33 34 }35 32 void PortalLink::tick(float dt) 36 33 { 37 34 SUPER(PortalLink, tick) 38 35 } 36 37 void PortalLink::processEvent(Event& event) 38 { 39 SUPER(PortalLink, processEvent); 40 if(!event.activate_) 41 { 42 return; 43 } 44 MultiTriggerContainer * origin = dynamic_cast<MultiTriggerContainer *>(event.originator_); 45 if(!origin) 46 { 47 return; 48 } 49 PortalEndPoint * eventFrom = dynamic_cast<PortalEndPoint *>(origin->getOriginator()); 50 WorldEntity * eventEntity = dynamic_cast<WorldEntity *>(origin->getData()); 51 if(eventFrom != this->from_ || !eventEntity || eventFrom->hasRecentlyJumpedOut(eventEntity) == true) 52 { 53 return; 54 } 55 to_->jumpOut(entity); 56 } 57 39 58 } -
code/branches/portals/src/orxonox/worldentities/PortalLink.h
r8177 r8198 6 6 #include "core/BaseObject.h" 7 7 #include "PortalEndPoint.h" 8 #include "objects/eventsystem/EventListener.h" 8 9 9 10 #include <set> … … 11 12 namespace orxonox 12 13 { 13 class _OrxonoxExport PortalLink : public BaseObject14 class _OrxonoxExport PortalLink : public EventListener 14 15 { 15 16 public: … … 36 37 } 37 38 void use(WorldEntity * entity); 39 virtual void processEvent(Event& event); 38 40 protected: 39 41 private: … … 44 46 float activationRadius_; 45 47 std::set<WorldEntity *> recentlyPorted; 48 ObjectList<WorldEntity>::iterator it_; 46 49 bool isNowPortable(WorldEntity * ent); 47 50 };
Note: See TracChangeset
for help on using the changeset viewer.