Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/infos/PlayerInfo.cc

    r5929 r6417  
    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    }
     
    139139        this->controller_->setPlayer(this);
    140140        if (this->controllableEntity_)
     141        {
    141142            this->controller_->setControllableEntity(this->controllableEntity_);
     143            this->controllableEntity_->setController(this->controller_);
     144        }
    142145        this->changedController();
    143146    }
     
    148151            return;
    149152
     153        if (this->oldControllableEntity_)
     154            this->stopTemporaryControl();
    150155        if (this->controllableEntity_)
    151156            this->stopControl();
     
    159164
    160165        if (this->controller_)
     166        {
    161167            this->controller_->setControllableEntity(entity);
     168            this->controllableEntity_->setController(this->controller_);
     169        }
     170
     171        this->changedControllableEntity();
     172    }
     173
     174    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
     175    {
     176        if (!entity)
     177            return;
     178
     179//         assert( this->temporaryControllableEntity_==0 );
     180
     181        this->oldControllableEntity_ = this->controllableEntity_;
     182        this->controllableEntity_ = entity;
     183        this->controllableEntityID_ = entity->getObjectID();
     184
     185        entity->setPlayer(this);
     186
     187        if (this->controller_)
     188            this->controller_->setControllableEntity(entity);
    162189
    163190        this->changedControllableEntity();
     
    166193    void PlayerInfo::stopControl()
    167194    {
     195        if ( this->oldControllableEntity_ )
     196            this->stopTemporaryControl();
     197
    168198        ControllableEntity* entity = this->controllableEntity_;
    169199
     
    171201            return;
    172202
     203        this->controllableEntity_->setController(0);
    173204        this->controllableEntity_ = 0;
    174205        this->controllableEntityID_ = OBJECTID_UNKNOWN;
     
    177208            this->controller_->setControllableEntity(0);
    178209
    179         entity->removePlayer();
     210        if ( GameMode::isMaster() )
     211            entity->removePlayer();
     212
     213        this->changedControllableEntity();
     214    }
     215
     216    void PlayerInfo::stopTemporaryControl()
     217    {
     218        ControllableEntity* entity = this->controllableEntity_;
     219
     220        assert( this->controllableEntity_ && this->oldControllableEntity_ );
     221        if( !entity || !this->oldControllableEntity_ )
     222            return;
     223
     224        this->controllableEntity_ = this->oldControllableEntity_;
     225        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
     226        this->oldControllableEntity_ = 0;
     227
     228        if ( this->controllableEntity_ && this->controller_)
     229            this->controller_->setControllableEntity(this->controllableEntity_);
     230
     231        if ( GameMode::isMaster() )
     232            entity->removePlayer();
    180233
    181234        this->changedControllableEntity();
     
    196249    }
    197250
     251
    198252    void PlayerInfo::networkcallback_changedgtinfoID()
    199253    {
Note: See TracChangeset for help on using the changeset viewer.