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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/world_entities/weapons/weapon.cc

    r9757 r9805  
    2424#include "world_entities/projectiles/projectile.h"
    2525
    26 #include "util/loading/resource_manager.h"
    2726#include "util/loading/factory.h"
    2827#include "util/loading/load_param.h"
     
    3231#include "sound_source.h"
    3332#include "sound_buffer.h"
     33#include "resource_sound_buffer.h"
    3434
    3535#include "elements/glgui_energywidget.h"
     
    5959    if (this->animation[i] && Animation::objectList().exists(animation[i]))  //!< @todo this should check animation3D
    6060      delete this->animation[i];
    61   for (int i = 0; i < WA_ACTION_COUNT; i++)
    62     if (this->soundBuffers[i] != NULL && OrxSound::SoundBuffer::objectList().exists(this->soundBuffers[i]))
    63       ResourceManager::getInstance()->unload(this->soundBuffers[i]);
    6461
    6562  if (OrxSound::SoundSource::objectList().exists(this->soundSource))
     
    121118    this->animation[i] = NULL;                   //< No animation
    122119  }
    123   for (int i = 0; i < WA_ACTION_COUNT; i++)
    124     this->soundBuffers[i] = NULL;                  //< No Sounds
    125120
    126121  this->soundSource = new OrxSound::SoundSource(this);       //< Every Weapon has exacty one SoundSource.
     
    273268  if (action >= WA_ACTION_COUNT)
    274269    return;
    275   if (this->soundBuffers[action] != NULL)
    276     ResourceManager::getInstance()->unload(this->soundBuffers[action]);
    277270
    278271  else if (!soundFile.empty())
    279272  {
    280     this->soundBuffers[action] = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV);
    281     if (this->soundBuffers[action] != NULL)
     273    this->soundBuffers[action] = OrxSound::ResourceSoundBuffer(soundFile);
     274    if (this->soundBuffers[action].loaded())
    282275    {
    283276      PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action));
     
    289282  }
    290283  else
    291     this->soundBuffers[action] = NULL;
     284    this->soundBuffers[action] = OrxSound::SoundBuffer();
    292285}
    293286
     
    423416  {
    424417    case WA_SHOOT:
    425       return this->fireW();
    426       break;
     418    return this->fireW();
     419    break;
    427420    case WA_CHARGE:
    428       return this->chargeW();
    429       break;
     421    return this->chargeW();
     422    break;
    430423    case WA_RELOAD:
    431       return this->reloadW();
    432       break;
     424    return this->reloadW();
     425    break;
    433426    case WA_DEACTIVATE:
    434       return this->deactivateW();
    435       break;
     427    return this->deactivateW();
     428    break;
    436429    case WA_ACTIVATE:
    437       return this->activateW();
    438       break;
     430    return this->activateW();
     431    break;
    439432    default:
    440       PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
    441       return false;
     433    PRINTF(2)("Action %s Not Implemented yet \n", Weapon::actionToChar(action));
     434    return false;
    442435  }
    443436}
     
    452445  {
    453446    // play Sound
    454     if (likely(this->soundBuffers[WA_ACTIVATE] != NULL))
     447    if (likely(this->soundBuffers[WA_ACTIVATE].loaded()))
    455448      this->soundSource->play(this->soundBuffers[WA_ACTIVATE]);
    456449    this->updateWidgets();
     
    474467    PRINTF(4)("Deactivating the Weapon %s\n", this->getCName());
    475468    // play Sound
    476     if (this->soundBuffers[WA_DEACTIVATE] != NULL)
     469    if (this->soundBuffers[WA_DEACTIVATE].loaded())
    477470      this->soundSource->play(this->soundBuffers[WA_DEACTIVATE]);
    478471    // deactivate
     
    493486  {
    494487    // playing Sound
    495     if (this->soundBuffers[WA_CHARGE] != NULL)
     488    if (this->soundBuffers[WA_CHARGE].loaded())
    496489      this->soundSource->play(this->soundBuffers[WA_CHARGE]);
    497490
     
    518511  {
    519512    // playing Sound
    520     if (this->soundBuffers[WA_SHOOT] != NULL)
     513    if (this->soundBuffers[WA_SHOOT].loaded())
    521514      this->soundSource->play(this->soundBuffers[WA_SHOOT]);
    522515    this->updateWidgets();
     
    551544
    552545
    553   if (this->soundBuffers[WA_RELOAD] != NULL)
     546  if (this->soundBuffers[WA_RELOAD].loaded())
    554547    this->soundSource->play(this->soundBuffers[WA_RELOAD]);
    555548
     
    694687  {
    695688    case WA_SHOOT:
    696       return "shoot";
    697       break;
     689    return "shoot";
     690    break;
    698691    case WA_CHARGE:
    699       return "charge";
    700       break;
     692    return "charge";
     693    break;
    701694    case WA_RELOAD:
    702       return "reload";
    703       break;
     695    return "reload";
     696    break;
    704697    case WA_ACTIVATE:
    705       return "activate";
    706       break;
     698    return "activate";
     699    break;
    707700    case WA_DEACTIVATE:
    708       return "deactivate";
    709       break;
     701    return "deactivate";
     702    break;
    710703    case WA_SPECIAL1:
    711       return "special1";
    712       break;
     704    return "special1";
     705    break;
    713706    default:
    714       return "none";
    715       break;
     707    return "none";
     708    break;
    716709  }
    717710}
     
    757750  {
    758751    case WS_SHOOTING:
    759       return "shooting";
    760       break;
     752    return "shooting";
     753    break;
    761754    case WS_CHARGING:
    762       return "charging";
    763       break;
     755    return "charging";
     756    break;
    764757    case WS_RELOADING:
    765       return "reloading";
    766       break;
     758    return "reloading";
     759    break;
    767760    case WS_ACTIVATING:
    768       return "activating";
    769       break;
     761    return "activating";
     762    break;
    770763    case WS_DEACTIVATING:
    771       return "deactivating";
    772       break;
     764    return "deactivating";
     765    break;
    773766    case WS_IDLE:
    774       return "idle";
    775       break;
     767    return "idle";
     768    break;
    776769    case WS_INACTIVE:
    777       return "inactive";
    778       break;
     770    return "inactive";
     771    break;
    779772    default:
    780       return "none";
    781       break;
    782   }
    783 }
     773    return "none";
     774    break;
     775  }
     776}
Note: See TracChangeset for help on using the changeset viewer.