Changeset 9805 in orxonox.OLD for branches/new_class_id/src/world_entities/projectiles
- Timestamp:
- Sep 24, 2006, 3:21:12 PM (18 years ago)
- Location:
- branches/new_class_id/src/world_entities/projectiles
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/world_entities/projectiles/projectile.cc
r9783 r9805 22 22 #include "world_entities/weapons/weapon.h" 23 23 #include "model.h" 24 #include " util/loading/resource_manager.h"24 #include "sound/resource_sound_buffer.h" 25 25 26 26 #include "debug.h" … … 44 44 this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points 45 45 46 this->explosionBuffer = NULL;47 this->engineBuffer = NULL;48 49 46 //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 50 47 } … … 56 53 Projectile::~Projectile () 57 54 { 58 if (this->explosionBuffer != NULL)59 ResourceManager::getInstance()->unload(this->explosionBuffer);60 if (this->engineBuffer != NULL)61 ResourceManager::getInstance()->unload(this->engineBuffer);62 55 /* 63 56 do not delete the test projectModel, since it is pnode … … 70 63 void Projectile::loadExplosionSound(const std::string& explosionSound) 71 64 { 72 if (this->explosionBuffer != NULL) 73 ResourceManager::getInstance()->unload(this->explosionBuffer); 74 75 else if (!explosionSound.empty()) 76 { 77 this->explosionBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(explosionSound, WAV); 78 if (this->explosionBuffer != NULL) 79 { 80 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", explosionSound.c_str(), this->getCName()); 81 } 82 else 83 { 84 PRINTF(2)("Failed to load sound %s to explosion %s.\n.", explosionSound.c_str(), this->getCName()); 85 } 86 } 65 if (!explosionSound.empty()) 66 this->explosionBuffer = OrxSound::ResourceSoundBuffer(explosionSound); 87 67 else 88 this->explosionBuffer = NULL;68 this->explosionBuffer = OrxSound::SoundBuffer(); 89 69 } 90 70 … … 92 72 void Projectile::loadEngineSound(const std::string& engineSound) 93 73 { 94 if (this->engineBuffer != NULL) 95 ResourceManager::getInstance()->unload(this->engineBuffer); 96 97 else if (!engineSound.empty()) 98 { 99 this->engineBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(engineSound, WAV); 100 if (this->engineBuffer != NULL) 101 { 102 PRINTF(4)("Loaded sound %s to Pickup: %s.\n", engineSound.c_str(), this->getCName()); 103 } 104 else 105 { 106 PRINTF(2)("Failed to load sound %s to engine %s.\n.", engineSound.c_str(), this->getCName()); 107 } 108 } 74 if (!engineSound.empty()) 75 this->engineBuffer = OrxSound::ResourceSoundBuffer(engineSound); 109 76 else 110 this->engineBuffer = NULL;77 this->engineBuffer = OrxSound::SoundBuffer(); 111 78 } 112 79 … … 140 107 //Vector offsetVel = 141 108 this->velocity = velocity; 142 // offsetVel.normalize();109 // offsetVel.normalize(); 143 110 //this->velocity += (offsetVel * 50.0); 144 111 } … … 174 141 void Projectile::destroy (WorldEntity* killer) 175 142 { 176 if (this->explosionBuffer != NULL)143 if (this->explosionBuffer.loaded()) 177 144 this->soundSource.play(this->explosionBuffer); 178 145 } -
branches/new_class_id/src/world_entities/projectiles/projectile.h
r9715 r9805 67 67 OrxSound::SoundSource soundSource; 68 68 private: 69 OrxSound::SoundBuffer *explosionBuffer;70 OrxSound::SoundBuffer *engineBuffer;69 OrxSound::SoundBuffer explosionBuffer; 70 OrxSound::SoundBuffer engineBuffer; 71 71 }; 72 72
Note: See TracChangeset
for help on using the changeset viewer.