Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2005, 5:18:37 PM (18 years ago)
Author:
bensch
Message:

controll: playable interface work

File:
1 edited

Legend:

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

    r5889 r5895  
    1414*/
    1515
    16 #include "weapons/weapon_manager.h"
    1716
    1817#include "playable.h"
     18
     19#include "weapons/weapon_manager.h"
    1920#include "event_handler.h"
    2021#include "player.h"
     
    2930{
    3031  delete this->weaponMan;
     32
     33  if (this->currentPlayer)
     34  {
     35    PRINTF(2)("There is Still a Player subscribed to this Playable (%s::%s)\n", this->getClassName(), this->getName());
     36
     37  }
    3138}
    3239
     
    3643  PRINTF(4)("PLAYABLE INIT\n");
    3744  this->weaponMan = new WeaponManager(this);
     45
     46  this->currentPlayer = NULL;
    3847}
    3948
     
    4150 * subscribe to all events the controllable needs
    4251 */
    43 void Playable::subscribeEvents(Player* player)
     52bool Playable::subscribePlayer(Player* player)
    4453{
    45   /*EventHandler*/
    46   EventHandler* evh = EventHandler::getInstance();
    47   std::list<int>::iterator ev;
    48   for (ev = this->events.begin(); ev != events.end(); ev++)
     54  if (this->currentPlayer != NULL)
    4955  {
    50     evh->subscribe(player, ES_GAME, (*ev));
     56    PRINTF(1)("Already registered Player:%s to this Playable (%s:%s)\n", this->currentPlayer->getName(), this->getClassName(), this->getName());
     57    return false;
    5158  }
     59  else
     60  {
     61    this->currentPlayer = player;
     62    /*EventHandler*/
     63    EventHandler* evh = EventHandler::getInstance();
     64    std::list<int>::iterator ev;
     65    for (ev = this->events.begin(); ev != events.end(); ev++)
     66      evh->subscribe(player, ES_GAME, (*ev));
    5267
     68    return true;
     69  }
    5370}
    5471
Note: See TracChangeset for help on using the changeset viewer.