Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 18, 2009, 1:34:14 PM (15 years ago)
Author:
scheusso
Message:

changes in PlayerInfo and Rocket (and scene)
not yet working in network though

File:
1 edited

Legend:

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

    r6082 r6087  
    5050        this->controller_ = 0;
    5151        this->controllableEntity_ = 0;
    52         this->controllableEntityID_ = CLIENTID_UNKNOWN;
     52        this->controllableEntityID_ = OBJECTID_UNKNOWN;
     53        this->temporaryControllableEntity_ = 0;
     54        this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
    5355
    5456        this->gtinfo_ = 0;
     
    8082        registerVariable(this->name_,                 VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    8183        registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     84        registerVariable(this->temporaryControllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    8285        registerVariable(this->bReadyToSpawn_,        VariableDirection::ToServer);
    8386        registerVariable(this->gtinfoID_,             VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
     
    166169    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
    167170    {
    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();
     171        if (!entity)
     172            return;
     173       
     174        assert( this->temporaryControllableEntity_==0 );
     175
     176        this->temporaryControllableEntity_ = entity;
     177        this->temporaryControllableEntityID_ = entity->getObjectID();
    178178
    179179        entity->setPlayer(this);
     
    201201
    202202        entity->removePlayer();
    203        
    204         if ( this->oldControllableEntity_ )
    205         {
    206             this->oldControllableEntity_->removePlayer();
    207             this->oldControllableEntity_ = 0;
    208         }
    209203
    210204        this->changedControllableEntity();
     
    213207    void PlayerInfo::stopTemporaryControl()
    214208    {
    215         ControllableEntity* entity = this->controllableEntity_;
     209        ControllableEntity* entity = this->temporaryControllableEntity_;
    216210
    217211        if (!entity)
    218212            return;
    219213
    220         this->controllableEntity_ = this->oldControllableEntity_.get();
    221         this->controllableEntityID_ = this->controllableEntity_->getObjectID();
    222 
    223         if (this->controller_)
     214        this->temporaryControllableEntity_ = 0;
     215        this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
     216
     217        if ( this->controllableEntity_ && this->controller_)
    224218            this->controller_->setControllableEntity(this->controllableEntity_);
    225219
     
    228222        this->changedControllableEntity();
    229223    }
    230 
     224   
    231225    void PlayerInfo::networkcallback_changedcontrollableentityID()
    232226    {
     
    243237    }
    244238
     239    void PlayerInfo::networkcallback_changedtemporarycontrollableentityID()
     240    {
     241        CCOUT(0) << "changedtemporarycontrollableentityid" << endl;
     242        if (this->temporaryControllableEntityID_ != OBJECTID_UNKNOWN)
     243        {
     244            Synchronisable* temp = Synchronisable::getSynchronisable(this->temporaryControllableEntityID_);
     245            ControllableEntity* entity = orxonox_cast<ControllableEntity*>(temp);
     246            this->startTemporaryControl(entity);
     247        }
     248        else
     249        {
     250            this->stopTemporaryControl();
     251        }
     252    }
     253
     254
    245255    void PlayerInfo::networkcallback_changedgtinfoID()
    246256    {
     257        CCOUT(0) << "changedcontrollableentityid" << endl;
    247258        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
    248259        {
Note: See TracChangeset for help on using the changeset viewer.