Changeset 12284 for code/branches/Boxhead_FS19/src/modules/weapons/projectiles/HoverGunProjectile.cc
- Timestamp:
- Apr 4, 2019, 5:13:42 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Boxhead_FS19/src/modules/weapons/projectiles/HoverGunProjectile.cc
r12273 r12284 21 21 * 22 22 * Author: 23 * Joel Smely23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 34 34 #include "HoverGunProjectile.h" 35 35 36 #include "core/config/ConfigValueIncludes.h" 36 37 #include "core/CoreIncludes.h" 38 #include "core/GameMode.h" 37 39 #include "core/command/Executor.h" 38 #include "util/Convert.h" 40 41 #include "worldentities/pawns/Pawn.h" 39 42 40 43 namespace orxonox … … 42 45 RegisterClass(HoverGunProjectile); 43 46 44 HoverGunProjectile::HoverGunProjectile(Context* context) : BillboardProjectile(context)47 HoverGunProjectile::HoverGunProjectile(Context* context) : MovableEntity(context), BasicProjectile() 45 48 { 46 49 RegisterObject(HoverGunProjectile); 47 50 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))); 51 this->setConfigValues(); 53 52 54 registerVariables(); 53 // Get notification about collisions 54 if (GameMode::isMaster()) 55 { 56 this->setMass(0.0000000001f); 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(2.0f); 64 this->attachCollisionShape(collisionShape_); 65 66 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this))); 67 } 55 68 } 56 69 57 void HoverGunProjectile::registerVariables()70 HoverGunProjectile::~HoverGunProjectile() 58 71 { 59 registerVariable(this->materialBase_);60 72 } 61 73 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) 74 void HoverGunProjectile::setConfigValues() 69 75 { 70 this->materialBase_ = material; 71 72 BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_)); 76 SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive"); 73 77 } 74 78 75 /** 76 @brief 77 Change the texture. 78 */ 79 void HoverGunProjectile::changeTexture() 79 80 bool HoverGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 80 81 { 81 this->textureIndex_++; 82 if (this->textureIndex_ > this->maxTextureIndex_) 83 this->textureIndex_ = 1; 82 return this->processCollision(otherObject, contactPoint, cs); 83 } 84 84 85 this->setMaterial(this->materialBase_); 85 void HoverGunProjectile::setCollisionShapeRadius(float radius) 86 { 87 if (collisionShape_ != nullptr && radius > 0) 88 { 89 collisionShape_->setRadius(radius); 90 } 86 91 } 87 92 }
Note: See TracChangeset
for help on using the changeset viewer.