Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6101


Ignore:
Timestamp:
Nov 20, 2009, 1:02:09 AM (15 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)

Location:
code/branches/particles2/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc

    r6098 r6101  
    137137        SUPER(Rocket, tick, dt);
    138138       
    139         if( GameMode::isMaster() )
     139        if( this->hasLocalController() )
    140140        {
    141141            this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
     
    196196    }
    197197   
    198     void Rocket::fire(unsigned int firemode)
     198    void Rocket::fired(unsigned int firemode)
    199199    {
    200200        if (this->owner_)
  • code/branches/particles2/src/modules/weapons/projectiles/Rocket.h

    r6087 r6101  
    110110            inline float getDamage() const
    111111                { return this->damage_; }
    112             virtual void fire(unsigned int firemode);
     112            virtual void fired(unsigned int firemode);
    113113           
    114114        private:
  • code/branches/particles2/src/orxonox/controllers/AIController.cc

    r6087 r6101  
    109109
    110110        if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
    111 //             this->getControllableEntity()->fire(0);
     111            this->getControllableEntity()->fire(0);
    112112
    113113        SUPER(AIController, tick, dt);
  • code/branches/particles2/src/orxonox/controllers/HumanController.cc

    r5929 r6101  
    145145    void HumanController::fire(unsigned int firemode)
    146146    {
    147         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     147        if( HumanController::localController_s && HumanController::localController_s->controllableEntity_ )
    148148            HumanController::localController_s->controllableEntity_->fire(firemode);
    149149    }
  • 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        {
  • code/branches/particles2/src/orxonox/infos/PlayerInfo.h

    r6087 r6101  
    9292        private:
    9393            void networkcallback_changedcontrollableentityID();
    94             void networkcallback_changedtemporarycontrollableentityID();
    9594            void networkcallback_changedgtinfoID();
    9695            void updateGametypeInfo();
     
    9998            Controller* controller_;
    10099            ControllableEntity* controllableEntity_;
    101             ControllableEntity* temporaryControllableEntity_;
     100            ControllableEntity* oldControllableEntity_;
    102101            unsigned int controllableEntityID_;
    103             unsigned int temporaryControllableEntityID_;
    104102
    105103            const GametypeInfo* gtinfo_;
  • code/branches/particles2/src/orxonox/worldentities/ControllableEntity.cc

    r5929 r6101  
    3636#include "core/GameMode.h"
    3737#include "core/XMLPort.h"
     38#include "network/NetworkFunction.h"
    3839
    3940#include "Scene.h"
     
    4748{
    4849    CreateFactory(ControllableEntity);
     50
     51    registerMemberNetworkFunction( ControllableEntity, fire );
    4952
    5053    ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
     
    217220            this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    218221    }
     222   
     223    void ControllableEntity::fire(unsigned int firemode)
     224    {
     225        if(GameMode::isMaster())
     226        {
     227            this->fired(firemode);
     228        }
     229        else
     230        {
     231            callMemberNetworkFunction(ControllableEntity, fire, this->getObjectID(), 0, firemode);
     232        }
     233    }
    219234
    220235    void ControllableEntity::setPlayer(PlayerInfo* player)
  • code/branches/particles2/src/orxonox/worldentities/ControllableEntity.h

    r5929 r6101  
    8484                { this->rotateRoll(Vector2(value, 0)); }
    8585
    86             virtual void fire(unsigned int firemode) {}
     86            void fire(unsigned int firemode);
     87            virtual void fired(unsigned int firemode) {}
    8788            virtual void reload() {}
    8889
  • code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.cc

    r6078 r6101  
    5252    CreateFactory(Pawn);
    5353
    54     registerMemberNetworkFunction( Pawn, doFire );
    55 
    5654    Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
    5755    {
     
    263261    }
    264262
    265     void Pawn::fire(unsigned int firemode)
    266     {
    267         this->doFire(firemode);
    268     }
    269 
    270     void Pawn::doFire(uint8_t firemode)
    271     {
    272         if(GameMode::isMaster())
    273         {
    274             if (this->weaponSystem_)
    275                 this->weaponSystem_->fire(firemode);
    276         }
    277         else
    278         {
    279             callMemberNetworkFunction(Pawn, doFire, this->getObjectID(), 0, firemode);
    280             if (this->weaponSystem_)
    281                 this->weaponSystem_->fire(firemode);
    282         }
     263    void Pawn::fired(unsigned int firemode)
     264    {
     265        if (this->weaponSystem_)
     266            this->weaponSystem_->fire(firemode);
    283267    }
    284268
  • code/branches/particles2/src/orxonox/worldentities/pawns/Pawn.h

    r6078 r6101  
    7979            virtual void kill();
    8080
    81             virtual void fire(unsigned int firemode);
     81            virtual void fired(unsigned int firemode);
    8282            virtual void reload();
    83             virtual void doFire(uint8_t firemode);
    8483            virtual void postSpawn();
    8584
  • code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.cc

    r5929 r6101  
    189189    }
    190190
    191     void Spectator::fire(unsigned int firemode)
     191    void Spectator::fired(unsigned int firemode)
    192192    {
    193193        if (this->getPlayer())
  • code/branches/particles2/src/orxonox/worldentities/pawns/Spectator.h

    r5781 r6101  
    5555            virtual void rotateRoll(const Vector2& value);
    5656
    57             virtual void fire(unsigned int firemode);
     57            virtual void fired(unsigned int firemode);
    5858            virtual void greet();
    5959
Note: See TracChangeset for help on using the changeset viewer.