Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8289 for code/branches


Ignore:
Timestamp:
Apr 21, 2011, 10:45:42 PM (14 years ago)
Author:
dafrick
Message:

Adding possibility to have a string of temporaryControls.

Location:
code/branches/dockingsystem2/src/orxonox/infos
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.cc

    r8196 r8289  
    5151        this->controllableEntity_ = 0;
    5252        this->controllableEntityID_ = OBJECTID_UNKNOWN;
    53         this->oldControllableEntity_ = 0;
    5453
    5554        this->gtinfo_ = 0;
     
    151150            return;
    152151
    153         if (this->oldControllableEntity_)
     152        while (this->previousControllableEntity_.size() > 0)
    154153            this->stopTemporaryControl();
     154       
    155155        if (this->controllableEntity_)
    156156            this->stopControl();
     
    176176        if (!entity)
    177177            return;
    178 
    179         assert( this->oldControllableEntity_==0 );
    180 
    181         this->oldControllableEntity_ = this->controllableEntity_;
     178       
     179        this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
    182180        this->controllableEntity_ = entity;
    183181        this->controllableEntityID_ = entity->getObjectID();
     
    194192    void PlayerInfo::stopControl()
    195193    {
    196         if ( this->oldControllableEntity_ )
     194        while ( this->previousControllableEntity_.size() > 0)
    197195            this->stopTemporaryControl();
    198196
     
    219217        ControllableEntity* entity = this->controllableEntity_;
    220218
    221         assert( this->controllableEntity_ && this->oldControllableEntity_ );
    222         if( !entity || !this->oldControllableEntity_ )
     219        assert(this->controllableEntity_ != NULL);
     220        if( !entity || this->previousControllableEntity_.size() == 0 )
    223221            return;
    224222
    225223        this->controllableEntity_->setController(0);
    226 
    227         this->controllableEntity_ = this->oldControllableEntity_;
     224       
     225        this->controllableEntity_ = this->previousControllableEntity_.back();
     226        do {
     227            this->controllableEntity_ = this->previousControllableEntity_.back();
     228        } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0);
    228229        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
    229         this->oldControllableEntity_ = 0;
    230 
    231         if ( this->controllableEntity_ && this->controller_)
     230        this->previousControllableEntity_.pop_back();
     231
     232        if ( this->controllableEntity_ != NULL && this->controller_ != NULL)
    232233            this->controller_->setControllableEntity(this->controllableEntity_);
    233234
  • code/branches/dockingsystem2/src/orxonox/infos/PlayerInfo.h

    r7163 r8289  
    9898            Controller* controller_;
    9999            ControllableEntity* controllableEntity_;
    100             ControllableEntity* oldControllableEntity_;
     100            std::vector< WeakPtr<ControllableEntity> > previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent.
    101101            unsigned int controllableEntityID_;
    102102
Note: See TracChangeset for help on using the changeset viewer.