Changeset 5896 in orxonox.OLD for branches/spaceshipcontrol
- Timestamp:
- Dec 3, 2005, 5:26:52 PM (19 years ago)
- Location:
- branches/spaceshipcontrol/src/world_entities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/spaceshipcontrol/src/world_entities/playable.cc
r5895 r5896 71 71 72 72 /** 73 * subscribe to all events the controllable needs 74 */ 75 bool Playable::unsubscribePlayer(Player* player) 76 { 77 if (this->currentPlayer != player) 78 { 79 PRINTF(1)("not the right Player to unregister from this Playable (%s:%s)\n", this->currentPlayer->getName(), this->getClassName(), this->getName()); 80 return false; 81 } 82 83 else 84 { 85 /*EventHandler*/ 86 EventHandler* evh = EventHandler::getInstance(); 87 std::list<int>::iterator ev; 88 for (ev = this->events.begin(); ev != events.end(); ev++) 89 evh->unsubscribe( ES_GAME, (*ev)); 90 91 this->currentPlayer = NULL; 92 return true; 93 } 94 } 95 96 /** 73 97 * add an event to the event list 74 98 */ 75 99 void Playable::registerEvent(int eventType) 76 100 { 77 101 this->events.push_back(eventType); 78 102 103 if (this->currentPlayer != NULL) 104 EventHandler::getInstance()->subscribe(this->currentPlayer, ES_GAME, eventType); 105 } 106 107 /** 108 * add an event to the event list 109 */ 110 void Playable::unregisterEvent(int eventType) 111 { 112 this->events.push_back(eventType); 113 114 if (this->currentPlayer != NULL) 115 EventHandler::getInstance()->unsubscribe(ES_GAME, eventType); 79 116 } 80 117 81 118 82 -
branches/spaceshipcontrol/src/world_entities/playable.h
r5895 r5896 32 32 33 33 bool subscribePlayer(Player* player); 34 bool unsubscribePlayer(Player* player); 34 35 35 36 virtual void process(const Event &event) {} //= 0;
Note: See TracChangeset
for help on using the changeset viewer.