Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2009, 5:42:50 PM (15 years ago)
Author:
landauf
Message:

Cleaned up setPlayer/removePlayer interface between PlayerInfo and ControllableEntity. The whole control is now up to the PlayerInfo, the respective functions in ControllableEntity are now protected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r2973 r3038  
    6262        if (this->BaseObject::isInitialized())
    6363        {
    64             this->stopControl(this->controllableEntity_);
     64            this->stopControl();
    6565
    6666            if (this->controller_)
     
    142142    }
    143143
    144     void PlayerInfo::startControl(ControllableEntity* entity, bool callback)
    145     {
    146         if (entity == this->controllableEntity_)
     144    void PlayerInfo::startControl(ControllableEntity* entity)
     145    {
     146        if (!entity || entity == this->controllableEntity_)
    147147            return;
    148148
    149149        if (this->controllableEntity_)
    150             this->stopControl(this->controllableEntity_, callback);
     150            this->stopControl();
    151151
    152152        this->controllableEntity_ = entity;
    153 
    154         if (entity)
    155         {
    156             this->controllableEntityID_ = entity->getObjectID();
    157             entity->setPlayer(this);
    158             this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    159         }
    160         else
    161         {
    162             this->controllableEntityID_ = OBJECTID_UNKNOWN;
    163         }
     153        this->controllableEntityID_ = entity->getObjectID();
     154
     155        entity->setPlayer(this);
     156
     157        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    164158
    165159        if (this->controller_)
     
    169163    }
    170164
    171     void PlayerInfo::stopControl(ControllableEntity* entity, bool callback)
    172     {
    173         if (entity && this->controllableEntity_ == entity)
    174         {
    175             this->controllableEntity_ = 0;
    176             this->controllableEntityID_ = OBJECTID_UNKNOWN;
    177 
    178             if (this->controller_)
    179                 this->controller_->setControllableEntity(0);
    180 
    181             if (callback)
    182                 entity->removePlayer();
    183 
    184             this->changedControllableEntity();
    185         }
     165    void PlayerInfo::stopControl()
     166    {
     167        ControllableEntity* entity = this->controllableEntity_;
     168
     169        if (!entity)
     170            return;
     171
     172        this->controllableEntity_ = 0;
     173        this->controllableEntityID_ = OBJECTID_UNKNOWN;
     174
     175        if (this->controller_)
     176            this->controller_->setControllableEntity(0);
     177
     178        entity->removePlayer();
     179
     180        this->changedControllableEntity();
    186181    }
    187182
     
    192187            Synchronisable* temp = Synchronisable::getSynchronisable(this->controllableEntityID_);
    193188            ControllableEntity* entity = dynamic_cast<ControllableEntity*>(temp);
    194 
    195189            this->startControl(entity);
    196190        }
    197191        else
    198192        {
    199             this->stopControl(this->controllableEntity_);
     193            this->stopControl();
    200194        }
    201195    }
Note: See TracChangeset for help on using the changeset viewer.