Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 4, 2019, 3:51:04 PM (5 years ago)
Author:
cwaupoti
Message:

comment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Boxhead_FS19/src/modules/weapons/projectiles/HoverGunProjectile.cc

    r12262 r12273  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Joel Smely
    2424 *   Co-authors:
    25  *      simonmie
     25 *      ...
    2626 *
    2727 */
    2828
    2929/**
    30     @file Projectile.h
    31     @brief Implementation of the Projectile class.
     30    @file HoverGunProjectile.h
     31    @brief Implementation of the HoverGunProjectile class.
    3232*/
    3333
    3434#include "HoverGunProjectile.h"
    3535
    36 #include "core/config/ConfigValueIncludes.h"
    3736#include "core/CoreIncludes.h"
    38 #include "core/GameMode.h"
    3937#include "core/command/Executor.h"
    40 
    41 #include "worldentities/pawns/Pawn.h"
     38#include "util/Convert.h"
    4239
    4340namespace orxonox
     
    4542    RegisterClass(HoverGunProjectile);
    4643
    47     HoverGunProjectile::HoverGunProjectile(Context* context) : MovableEntity(context), BasicProjectile()
     44    HoverGunProjectile::HoverGunProjectile(Context* context) : BillboardProjectile(context)
    4845    {
    4946        RegisterObject(HoverGunProjectile);
    5047
    51         this->setConfigValues();
     48        this->textureIndex_ = 1;
     49        this->setMass(0.1f);
     50        this->setCollisionType(CollisionType::Dynamic);
     51        this->maxTextureIndex_ = 8;
     52        this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&HoverGunProjectile::changeTexture, this)));
    5253
    53         // Get notification about collisions
    54         if (GameMode::isMaster())
    55         {
    56             this->setMass(0.1f);
    57             this->enableCollisionCallback();
    58             this->setCollisionResponse(false);
    59             this->setCollisionType(CollisionType::Dynamic);
    60 
    61             // Create a sphere collision shape and attach it to the projectile.
    62             collisionShape_ = new SphereCollisionShape(this->getContext());
    63             setCollisionShapeRadius(8.0f);
    64             this->attachCollisionShape(collisionShape_);
    65 
    66             this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
    67         }
     54        registerVariables();
    6855    }
    6956
    70     HoverGunProjectile::~HoverGunProjectile()
     57    void HoverGunProjectile::registerVariables()
    7158    {
     59        registerVariable(this->materialBase_);
    7260    }
    7361
    74     void HoverGunProjectile::setConfigValues()
     62    /**
     63    @brief
     64        Set the material.
     65    @param material
     66        The name of the material. Material names with 1 to 8 appended must exist.
     67    */
     68    void HoverGunProjectile::setMaterial(const std::string& material)
    7569    {
    76         SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive");
     70        this->materialBase_ = material;
     71
     72        BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
    7773    }
    7874
    79     void HoverGunProjectile::tick(float dt)
     75    /**
     76    @brief
     77        Change the texture.
     78    */
     79    void HoverGunProjectile::changeTexture()
    8080    {
    81         SUPER(Projectile, tick, dt);
     81        this->textureIndex_++;
     82        if (this->textureIndex_ > this->maxTextureIndex_)
     83            this->textureIndex_ = 1;
    8284
    83         if (!this->isActive())
    84             return;
    85 
    86         this->destroyCheck();
    87     }
    88 
    89     bool HoverGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    90     {
    91         return this->processCollision(otherObject, contactPoint, cs);
    92     }
    93 
    94     void HoverGunProjectile::setCollisionShapeRadius(float radius)
    95     {
    96         if (collisionShape_ != nullptr && radius > 0)
    97         {
    98             collisionShape_->setRadius(radius);
    99         }       
     85        this->setMaterial(this->materialBase_);
    10086    }
    10187}
Note: See TracChangeset for help on using the changeset viewer.