Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5896 in orxonox.OLD for branches/spaceshipcontrol/src


Ignore:
Timestamp:
Dec 3, 2005, 5:26:52 PM (19 years ago)
Author:
bensch
Message:

controll: more elaborate playable

Location:
branches/spaceshipcontrol/src/world_entities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/playable.cc

    r5895 r5896  
    7171
    7272/**
     73 * subscribe to all events the controllable needs
     74 */
     75bool 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/**
    7397 * add an event to the event list
    7498 */
    75  void Playable::registerEvent(int eventType)
     99void Playable::registerEvent(int eventType)
    76100{
    77101  this->events.push_back(eventType);
    78102
     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 */
     110void Playable::unregisterEvent(int eventType)
     111{
     112  this->events.push_back(eventType);
     113
     114  if (this->currentPlayer != NULL)
     115    EventHandler::getInstance()->unsubscribe(ES_GAME, eventType);
    79116}
    80117
    81118
    82 
  • branches/spaceshipcontrol/src/world_entities/playable.h

    r5895 r5896  
    3232
    3333    bool subscribePlayer(Player* player);
     34    bool unsubscribePlayer(Player* player);
    3435
    3536    virtual void process(const Event &event) {} //= 0;
Note: See TracChangeset for help on using the changeset viewer.