Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 30, 2010, 3:57:05 PM (14 years ago)
Author:
gnadler
Message:

documentation & formatting commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc

    r7019 r7021  
    4545namespace orxonox
    4646{
     47        /**
     48    @file
     49    @brief
     50        SimpleRocket, follows direction from a Rocketcontroller, has fuel for 80% of its lifetime, afterwords it's fire disappears.
     51    @author
     52       Gabriel Nadler (Original file: Oli Scheuss)
     53    */
    4754    CreateFactory(SimpleRocket);
    48     // create the factory for the SimpleRocket
    49 
    50     /**
    51     @brief
    52         Constructor. Registers the object and initializes some default values.
    53     */
     55
     56
    5457    SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
    5558    {
     
    5962        this->bDestroy_ = false;
    6063        this->lifetime_ = 120;
     64
    6165        this->setMass(15);
    6266        COUT(4) << "simplerocket constructed\n";
    63         this->maxLife_=90;
    6467
    6568        if (GameMode::isMaster())
     
    9295
    9396    }
    94    
    95 
    96 
    97 
     97
     98
     99   
     100    /**
     101    * @brief updates state of rocket, disables fire if no fuel
     102    * @param dt tick-length
     103    */
    98104    void SimpleRocket::tick(float dt)
    99105    {
     
    102108        if ( GameMode::isMaster() )
    103109        {
    104             if (this->getVelocity().squaredLength() >130000)
    105                 this->maxLife_-=dt; //if Velocity bigger than about 360, uses a lot more "fuel" :)
    106            
     110
    107111
    108112            this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
     
    110114            this->localAngularVelocity_ = 0;
    111115
    112            
     116       
    113117            if (this->fuel_)
    114118            {
    115                 if (this->destroyTimer_.getRemainingTime()<  this->lifetime_-this->maxLife_ )
     119                if (this->destroyTimer_.getRemainingTime()<  (static_cast<float>(this->FUEL_PERCENTAGE)/100) *this->lifetime_ )
    116120                    this->fuel_=false;
    117             }
    118             else
     121            } else
    119122                this->disableFire();
    120123
    121             if( this->bDestroy_ )
     124            if( this->bDestroy_ ) 
    122125                this->destroy();
    123126        }
     
    125128    }
    126129
     130    /**
     131    * @brief Sets the Acceleration to 0 and detaches the fire
     132    * @return void
     133    */
    127134    void SimpleRocket::disableFire()
    128135    {
    129         this->setAcceleration(0,0,0);
    130         this->fire_->destroy();
    131         this->fire_ = 0;
    132 //         this->fire_->detachFromParent();
     136        this->setAcceleration(0,0,0);       
     137        this->fire_->detachFromParent();
    133138    }
    134139
     
    144149            {
    145150                this->getController()->destroy();
    146                 COUT(4)<< "simplerocket destroyed\n";
    147151            }
    148152        }
     
    162166    {
    163167        this->owner_ = owner;
    164         //this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
    165168        this->player_ = this->owner_->getPlayer();
    166169    }
     170
    167171
    168172
Note: See TracChangeset for help on using the changeset viewer.