Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 17, 2009, 10:57:44 PM (15 years ago)
Author:
scheusso
Message:

some fixes in Rocket
there are two new function ins PlayerInfo: startTemporaryControl and stopTemporaryControl which expand start/stop-Control but without removing the player from the currently controlled controllable entity

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

Legend:

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

    r5929 r6082  
    163163        this->changedControllableEntity();
    164164    }
     165   
     166    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
     167    {
     168        if (!entity || entity == this->controllableEntity_)
     169            return;
     170
     171//         if (this->controllableEntity_)
     172//             this->stopControl();
     173
     174        this->oldControllableEntity_ = this->controllableEntity_;
     175
     176        this->controllableEntity_ = entity;
     177        this->controllableEntityID_ = entity->getObjectID();
     178
     179        entity->setPlayer(this);
     180
     181        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
     182
     183        if (this->controller_)
     184            this->controller_->setControllableEntity(entity);
     185
     186        this->changedControllableEntity();
     187    }
    165188
    166189    void PlayerInfo::stopControl()
     
    178201
    179202        entity->removePlayer();
    180 
     203       
     204        if ( this->oldControllableEntity_ )
     205        {
     206            this->oldControllableEntity_->removePlayer();
     207            this->oldControllableEntity_ = 0;
     208        }
     209
     210        this->changedControllableEntity();
     211    }
     212   
     213    void PlayerInfo::stopTemporaryControl()
     214    {
     215        ControllableEntity* entity = this->controllableEntity_;
     216
     217        if (!entity)
     218            return;
     219
     220        this->controllableEntity_ = this->oldControllableEntity_.get();
     221        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
     222
     223        if (this->controller_)
     224            this->controller_->setControllableEntity(this->controllableEntity_);
     225
     226        entity->removePlayer();
     227       
    181228        this->changedControllableEntity();
    182229    }
  • code/branches/particles2/src/orxonox/infos/PlayerInfo.h

    r5929 r6082  
    6969            void startControl(ControllableEntity* entity);
    7070            void stopControl();
     71            void startTemporaryControl(ControllableEntity* entity);
     72            void stopTemporaryControl();
    7173
    7274            inline ControllableEntity* getControllableEntity() const
     
    9698            Controller* controller_;
    9799            ControllableEntity* controllableEntity_;
     100            WeakPtr<ControllableEntity> oldControllableEntity_;
    98101            unsigned int controllableEntityID_;
    99102
Note: See TracChangeset for help on using the changeset viewer.