Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6986 in orxonox.OLD for trunk/src/world_entities/player.cc


Ignore:
Timestamp:
Feb 2, 2006, 5:58:33 PM (18 years ago)
Author:
bensch
Message:

trunk: brainfuck: interface to Playable much bea now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/player.cc

    r6985 r6986  
    4949Player::~Player ()
    5050{
    51 
     51  this->setPlayable(NULL);
    5252}
    5353
     
    5555bool Player::setPlayable(Playable* playable)
    5656{
    57   if(playable != NULL && playable->subscribePlayer(this))
     57  if (this->playable == playable)
     58    return false;
     59
     60  // get out of the current Playable
     61  if (this->playable != NULL)
    5862  {
     63    printf("Player gets ejected from Playable\n");
     64    this->hud.setEnergyWidget(NULL);
     65    this->hud.setWeaponManager(NULL);
     66
     67    Playable* ejectedPlayable = this->playable;
     68
     69    this->playable = NULL;
     70    ejectedPlayable->setPlayer(NULL);
     71  }
     72
     73  if (playable != NULL)
     74  {
     75    printf("Enter new Playable\n");
    5976      this->playable = playable;
    6077      this->hud.setEnergyWidget(this->playable->getHealthWidget());
    6178      this->hud.setWeaponManager(this->playable->getWeaponManager());
     79
     80      this->playable->setPlayer(this);
    6281      return true;
    6382  }
    64   else
    65     return false;
     83
     84  printf("no change\n");
     85  return true;
    6686}
    6787
    68 bool Player::disconnectPlayable()
     88bool Player::eject()
    6989 {
    70    if(this->playable == NULL) return true;
     90   this->setPlayable(NULL);
     91 }
    7192
    72    if(this->playable->unsubscribePlayer(this))
    73    {
    74      this->playable = NULL;
    75      this->hud.setEnergyWidget(NULL);
    76      this->hud.setWeaponManager(NULL);
    77      return true;
    78    }
    79    else
    80      return false;
    81  }
    8293
    8394 void Player::weaponConfigChanged()
     
    99110       {
    100111
    101          this->disconnectPlayable();
    102112         this->setPlayable(dynamic_cast<Playable*>(*node));
    103113
Note: See TracChangeset for help on using the changeset viewer.