Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6082


Ignore:
Timestamp:
Nov 17, 2009, 10:57:44 PM (14 years ago)
Author:
scheusso
Message:

some fixes in Rocket
there are two new function ins PlayerInfo: startTemporaryControl and stopTemporaryControl which expand start/stop-Control but without removing the player from the currently controlled controllable entity

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

Legend:

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

    r6081 r6082  
    5555        this->setVelocity(0,0,-100);
    5656        this->model_ = new Model(this);
    57         this->model_->setMeshSource("can.mesh");
     57        this->model_->setMeshSource("rocket_test.mesh");
    5858        this->attach(this->model_);
    5959        this->lifetime_ = 100;
     60        this->bDestroy_ = false;
    6061       
    6162        if (GameMode::isMaster())
     
    7475       
    7576        this->camPosition_ = new CameraPosition(this);
    76         this->camPosition_->setPosition(0,0,0);
     77        this->camPosition_->setPosition(0,10,40);
    7778        this->attach( this->camPosition_ );
    7879        this->addCameraPosition( this->camPosition_ );
     
    9091            this->model_->destroy();
    9192           
    92             if (GameMode::isMaster() && this->owner_)
    93                 this->owner_->getPlayer()->startControl(this->originalControllableEntity_);
     93            if (GameMode::isMaster() && this->player_)
     94                this->player_->stopTemporaryControl();
    9495            this->camPosition_->destroy();
    9596        }
     
    109110    {
    110111        this->owner_ = owner;
    111            
     112       
    112113        this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
    113         this->originalControllableEntity_->setDestroyWhenPlayerLeft( false );
    114         this->owner_->getPlayer()->startControl(this);
     114        this->player_ = this->owner_->getPlayer();
     115        this->owner_->getPlayer()->startTemporaryControl(this);
    115116    }
    116117
     
    126127       
    127128        this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
    128         this->setVelocity( (this->getOrientation()*WorldEntity::FRONT)*100 );
     129        this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
    129130        this->localAngularVelocity_ = 0;
    130 //         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    131 //         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    132 //         if (this->localLinearAcceleration_.z() > 0)
    133 //             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    134 //         else
    135 //             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    136 //         this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    137 //         this->localLinearAcceleration_.setValue(0, 0, 0);
    138 //     
    139 //         this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
    140 //         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
     131       
     132        if( this->bDestroy_ )
     133            this->destroy();
    141134    }
    142135   
     
    147140            if (otherObject == this->owner_)
    148141                return false;
    149 
     142           
    150143            this->bDestroy_ = true;
    151144
     
    177170            if (victim)
    178171                victim->damage(dmg, this->owner_);
     172//             this->destroy();
    179173        }
    180174        return false;
     
    195189    void Rocket::rotateYaw(const Vector2& value)
    196190    {
    197         this->localAngularVelocity_.y = value.x;
     191        this->localAngularVelocity_.y += value.x;
    198192    }
    199193
     
    206200    void Rocket::rotatePitch(const Vector2& value)
    207201    {
    208         this->localAngularVelocity_.x = value.x;
     202        this->localAngularVelocity_.x += value.x;
    209203    }
    210204
     
    217211    void Rocket::rotateRoll(const Vector2& value)
    218212    {
    219         this->localAngularVelocity_.z = value.x;
     213        this->localAngularVelocity_.z += value.x;
    220214    }
    221215   
  • code/branches/particles2/src/modules/weapons/projectiles/Rocket.h

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

    r5929 r6082  
    163163        this->changedControllableEntity();
    164164    }
     165   
     166    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
     167    {
     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();
     178
     179        entity->setPlayer(this);
     180
     181        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
     182
     183        if (this->controller_)
     184            this->controller_->setControllableEntity(entity);
     185
     186        this->changedControllableEntity();
     187    }
    165188
    166189    void PlayerInfo::stopControl()
     
    178201
    179202        entity->removePlayer();
    180 
     203       
     204        if ( this->oldControllableEntity_ )
     205        {
     206            this->oldControllableEntity_->removePlayer();
     207            this->oldControllableEntity_ = 0;
     208        }
     209
     210        this->changedControllableEntity();
     211    }
     212   
     213    void PlayerInfo::stopTemporaryControl()
     214    {
     215        ControllableEntity* entity = this->controllableEntity_;
     216
     217        if (!entity)
     218            return;
     219
     220        this->controllableEntity_ = this->oldControllableEntity_.get();
     221        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
     222
     223        if (this->controller_)
     224            this->controller_->setControllableEntity(this->controllableEntity_);
     225
     226        entity->removePlayer();
     227       
    181228        this->changedControllableEntity();
    182229    }
  • code/branches/particles2/src/orxonox/infos/PlayerInfo.h

    r5929 r6082  
    6969            void startControl(ControllableEntity* entity);
    7070            void stopControl();
     71            void startTemporaryControl(ControllableEntity* entity);
     72            void stopTemporaryControl();
    7173
    7274            inline ControllableEntity* getControllableEntity() const
     
    9698            Controller* controller_;
    9799            ControllableEntity* controllableEntity_;
     100            WeakPtr<ControllableEntity> oldControllableEntity_;
    98101            unsigned int controllableEntityID_;
    99102
Note: See TracChangeset for help on using the changeset viewer.