Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 24, 2006, 3:21:12 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: SoundSource completely added as a Resource

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  
    2222#include "world_entities/weapons/weapon.h"
    2323#include "model.h"
    24 #include "util/loading/resource_manager.h"
     24#include "sound/resource_sound_buffer.h"
    2525
    2626#include "debug.h"
     
    4444  this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points
    4545
    46   this->explosionBuffer = NULL;
    47   this->engineBuffer = NULL;
    48 
    4946  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    5047}
     
    5653Projectile::~Projectile ()
    5754{
    58   if (this->explosionBuffer != NULL)
    59     ResourceManager::getInstance()->unload(this->explosionBuffer);
    60   if (this->engineBuffer != NULL)
    61     ResourceManager::getInstance()->unload(this->engineBuffer);
    6255  /*
    6356     do not delete the test projectModel, since it is pnode
     
    7063void Projectile::loadExplosionSound(const std::string& explosionSound)
    7164{
    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);
    8767  else
    88     this->explosionBuffer = NULL;
     68    this->explosionBuffer = OrxSound::SoundBuffer();
    8969}
    9070
     
    9272void Projectile::loadEngineSound(const std::string& engineSound)
    9373{
    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);
    10976  else
    110     this->engineBuffer = NULL;
     77    this->engineBuffer = OrxSound::SoundBuffer();
    11178}
    11279
     
    140107  //Vector offsetVel =
    141108  this->velocity = velocity;
    142  // offsetVel.normalize();
     109  // offsetVel.normalize();
    143110  //this->velocity += (offsetVel * 50.0);
    144111}
     
    174141void Projectile::destroy (WorldEntity* killer)
    175142{
    176   if (this->explosionBuffer != NULL)
     143  if (this->explosionBuffer.loaded())
    177144    this->soundSource.play(this->explosionBuffer);
    178145}
  • branches/new_class_id/src/world_entities/projectiles/projectile.h

    r9715 r9805  
    6767    OrxSound::SoundSource  soundSource;
    6868  private:
    69     OrxSound::SoundBuffer* explosionBuffer;
    70     OrxSound::SoundBuffer* engineBuffer;
     69    OrxSound::SoundBuffer  explosionBuffer;
     70    OrxSound::SoundBuffer  engineBuffer;
    7171};
    7272
Note: See TracChangeset for help on using the changeset viewer.