Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 20, 2009, 5:20:11 PM (15 years ago)
Author:
rgrieder
Message:

Merged particles2 branch to presentation2.

Location:
code/branches/presentation2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2

  • code/branches/presentation2/src/orxonox/infos/PlayerInfo.cc

    r5929 r6107  
    5050        this->controller_ = 0;
    5151        this->controllableEntity_ = 0;
    52         this->controllableEntityID_ = CLIENTID_UNKNOWN;
     52        this->controllableEntityID_ = OBJECTID_UNKNOWN;
     53        this->oldControllableEntity_ = 0;
    5354
    5455        this->gtinfo_ = 0;
     
    8081        registerVariable(this->name_,                 VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    8182        registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    82         registerVariable(this->bReadyToSpawn_,        VariableDirection::ToServer);
    8383        registerVariable(this->gtinfoID_,             VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
    8484    }
     
    148148            return;
    149149
     150        if (this->oldControllableEntity_)
     151            this->stopTemporaryControl();
    150152        if (this->controllableEntity_)
    151153            this->stopControl();
     
    163165        this->changedControllableEntity();
    164166    }
     167   
     168    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
     169    {
     170        if (!entity)
     171            return;
     172       
     173//         assert( this->temporaryControllableEntity_==0 );
     174
     175        this->oldControllableEntity_ = this->controllableEntity_;
     176        this->controllableEntity_ = entity;
     177        this->controllableEntityID_ = entity->getObjectID();
     178
     179        entity->setPlayer(this);
     180
     181        if (this->controller_)
     182            this->controller_->setControllableEntity(entity);
     183
     184        this->changedControllableEntity();
     185    }
    165186
    166187    void PlayerInfo::stopControl()
    167188    {
     189        if ( this->oldControllableEntity_ )
     190            this->stopTemporaryControl();
     191       
    168192        ControllableEntity* entity = this->controllableEntity_;
    169193
     
    177201            this->controller_->setControllableEntity(0);
    178202
    179         entity->removePlayer();
    180 
    181         this->changedControllableEntity();
    182     }
    183 
     203        if ( GameMode::isMaster() )
     204            entity->removePlayer();
     205
     206        this->changedControllableEntity();
     207    }
     208   
     209    void PlayerInfo::stopTemporaryControl()
     210    {
     211        ControllableEntity* entity = this->controllableEntity_;
     212
     213        if (!entity || !this->oldControllableEntity_)
     214            return;
     215
     216        this->controllableEntity_ = this->oldControllableEntity_;
     217        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
     218        this->oldControllableEntity_ = 0;
     219
     220        if ( this->controllableEntity_ && this->controller_)
     221            this->controller_->setControllableEntity(this->controllableEntity_);
     222
     223        if ( GameMode::isMaster() )
     224            entity->removePlayer();
     225       
     226        this->changedControllableEntity();
     227    }
     228   
    184229    void PlayerInfo::networkcallback_changedcontrollableentityID()
    185230    {
     
    196241    }
    197242
     243
    198244    void PlayerInfo::networkcallback_changedgtinfoID()
    199245    {
  • code/branches/presentation2/src/orxonox/infos/PlayerInfo.h

    r5929 r6107  
    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            ControllableEntity* oldControllableEntity_;
    98101            unsigned int controllableEntityID_;
    99102
Note: See TracChangeset for help on using the changeset viewer.