Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 20, 2009, 1:02:09 AM (14 years ago)
Author:
scheusso
Message:

rocket now steerable also on client
AIController shoots again now ;)
fire network function is now in CE instead of Pawn
some changes in PlayerInfo that allow controlling of temporary objects (such as Rocket)

File:
1 edited

Legend:

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

    r6087 r6101  
    5151        this->controllableEntity_ = 0;
    5252        this->controllableEntityID_ = OBJECTID_UNKNOWN;
    53         this->temporaryControllableEntity_ = 0;
    54         this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
     53        this->oldControllableEntity_ = 0;
    5554
    5655        this->gtinfo_ = 0;
     
    8281        registerVariable(this->name_,                 VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    8382        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));
    85         registerVariable(this->bReadyToSpawn_,        VariableDirection::ToServer);
    8683        registerVariable(this->gtinfoID_,             VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
    8784    }
     
    151148            return;
    152149
     150        if (this->oldControllableEntity_)
     151            this->stopTemporaryControl();
    153152        if (this->controllableEntity_)
    154153            this->stopControl();
     
    172171            return;
    173172       
    174         assert( this->temporaryControllableEntity_==0 );
    175 
    176         this->temporaryControllableEntity_ = entity;
    177         this->temporaryControllableEntityID_ = entity->getObjectID();
     173//         assert( this->temporaryControllableEntity_==0 );
     174
     175        this->oldControllableEntity_ = this->controllableEntity_;
     176        this->controllableEntity_ = entity;
     177        this->controllableEntityID_ = entity->getObjectID();
    178178
    179179        entity->setPlayer(this);
    180180
    181         this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    182 
    183181        if (this->controller_)
    184182            this->controller_->setControllableEntity(entity);
     
    189187    void PlayerInfo::stopControl()
    190188    {
     189        if ( this->oldControllableEntity_ )
     190            this->stopTemporaryControl();
     191       
    191192        ControllableEntity* entity = this->controllableEntity_;
    192193
     
    200201            this->controller_->setControllableEntity(0);
    201202
    202         entity->removePlayer();
     203        if ( GameMode::isMaster() )
     204            entity->removePlayer();
    203205
    204206        this->changedControllableEntity();
     
    207209    void PlayerInfo::stopTemporaryControl()
    208210    {
    209         ControllableEntity* entity = this->temporaryControllableEntity_;
    210 
    211         if (!entity)
    212             return;
    213 
    214         this->temporaryControllableEntity_ = 0;
    215         this->temporaryControllableEntityID_ = OBJECTID_UNKNOWN;
     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;
    216219
    217220        if ( this->controllableEntity_ && this->controller_)
    218221            this->controller_->setControllableEntity(this->controllableEntity_);
    219222
    220         entity->removePlayer();
     223        if ( GameMode::isMaster() )
     224            entity->removePlayer();
    221225       
    222226        this->changedControllableEntity();
     
    237241    }
    238242
    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 
    254243
    255244    void PlayerInfo::networkcallback_changedgtinfoID()
    256245    {
    257         CCOUT(0) << "changedcontrollableentityid" << endl;
    258246        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
    259247        {
Note: See TracChangeset for help on using the changeset viewer.