Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6087 for code


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

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

Legend:

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

    r6086 r6087  
    5252        RegisterObject(Rocket);// - register the Rocket class to the core
    5353       
    54         this->setCollisionType(WorldEntity::Kinematic);
    55         this->setVelocity(0,0,-100);
    56         this->model_ = new Model(this);
    57         this->model_->setMeshSource("rocket_test.mesh");
    58         this->attach(this->model_);
    59         this->lifetime_ = 100;
    60         this->bDestroy_ = false;
    61        
    6254        if (GameMode::isMaster())
    6355        {
     56            this->setCollisionType(WorldEntity::Kinematic);
     57            this->setVelocity(0,0,-100);
     58            this->lifetime_ = 100;
     59            this->bDestroy_ = false;
     60       
     61            this->model_ = new Model(this);
     62            this->model_->setMeshSource("rocket_test.mesh");
     63            this->attach(this->model_);
     64       
    6465            this->enableCollisionCallback();
    6566            this->setCollisionResponse(false);
     
    7677        this->camPosition_ = new CameraPosition(this);
    7778        this->camPosition_->setPosition(0,10,40);
     79        this->camPosition_->setSyncMode(0x0);
    7880        this->attach( this->camPosition_ );
    7981        this->addCameraPosition( this->camPosition_ );
     
    8890        if(this->isInitialized())
    8991        {
    90             this->collisionShape_->destroy();
    91             this->model_->destroy();
    9292           
    93             if (GameMode::isMaster() && this->player_)
     93            if (GameMode::isMaster() && this->player_.get())
     94            {
     95                this->model_->destroy();
     96                this->collisionShape_->destroy();
    9497                this->player_->stopTemporaryControl();
     98            }
    9599            this->camPosition_->destroy();
    96100        }
     
    110114    {
    111115        this->owner_ = owner;
    112        
    113116        this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
    114117        this->player_ = this->owner_->getPlayer();
     
    126129        SUPER(Rocket, tick, dt);
    127130       
    128         this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
    129         this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
    130         this->localAngularVelocity_ = 0;
    131        
    132         if( this->bDestroy_ )
    133             this->destroy();
     131        if( GameMode::isMaster() )
     132        {
     133            this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
     134            this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
     135            this->localAngularVelocity_ = 0;
     136           
     137            if( this->bDestroy_ )
     138                this->destroy();
     139        }
    134140    }
    135141   
     
    180186            this->destroy();
    181187    }
     188   
     189    void Rocket::fire(unsigned int firemode)
     190    {
     191        if (this->owner_)
     192        {
     193            {
     194                ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     195                effect->setPosition(this->getPosition());
     196                effect->setOrientation(this->getOrientation());
     197                effect->setDestroyAfterLife(true);
     198                effect->setSource("Orxonox/explosion3");
     199                effect->setLifetime(2.0f);
     200            }
     201            {
     202                ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     203                effect->setPosition(this->getPosition());
     204                effect->setOrientation(this->getOrientation());
     205                effect->setDestroyAfterLife(true);
     206                effect->setSource("Orxonox/smoke4");
     207                effect->setLifetime(3.0f);
     208            }
     209            this->destroy();
     210        }
     211    }
    182212
    183213    /**
  • code/branches/particles2/src/modules/weapons/projectiles/Rocket.h

    r6082 r6087  
    110110            inline float getDamage() const
    111111                { return this->damage_; }
    112             virtual void fire(unsigned int firemode) { this->destroy(); }
     112            virtual void fire(unsigned int firemode);
    113113           
    114114        private:
     
    122122            CameraPosition* camPosition_;
    123123            ConeCollisionShape* collisionShape_;
    124             PlayerInfo* player_;
     124            WeakPtr<PlayerInfo> player_;
    125125            Timer destroyTimer_;
    126126            float lifetime_;
  • code/branches/particles2/src/orxonox/Scene.cc

    r5929 r6087  
    334334    {
    335335        // get the WorldEntity pointers
    336         WorldEntity* object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
    337         assert(orxonox_cast<WorldEntity*>(object0));
    338         WorldEntity* object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
    339         assert(orxonox_cast<WorldEntity*>(object1));
     336        SmartPtr<WorldEntity> object0 = static_cast<WorldEntity*>(colObj0->getUserPointer());
     337        SmartPtr<WorldEntity> object1 = static_cast<WorldEntity*>(colObj1->getUserPointer());
    340338
    341339        // false means that bullet will assume we didn't modify the contact
  • code/branches/particles2/src/orxonox/controllers/AIController.cc

    r5929 r6087  
    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/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        {
  • code/branches/particles2/src/orxonox/infos/PlayerInfo.h

    r6082 r6087  
    9292        private:
    9393            void networkcallback_changedcontrollableentityID();
     94            void networkcallback_changedtemporarycontrollableentityID();
    9495            void networkcallback_changedgtinfoID();
    9596            void updateGametypeInfo();
     
    9899            Controller* controller_;
    99100            ControllableEntity* controllableEntity_;
    100             WeakPtr<ControllableEntity> oldControllableEntity_;
     101            ControllableEntity* temporaryControllableEntity_;
    101102            unsigned int controllableEntityID_;
     103            unsigned int temporaryControllableEntityID_;
    102104
    103105            const GametypeInfo* gtinfo_;
Note: See TracChangeset for help on using the changeset viewer.