Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/power_ups/power_up.cc

    r9406 r9869  
    2121#include "primitive_model.h"
    2222
    23 #include "util/loading/resource_manager.h"
     23#include "sound/resource_sound_buffer.h"
    2424#include "util/loading/load_param.h"
    2525
     26#include "debug.h"
    2627
     28ObjectListDefinition(PowerUp);
    2729
    2830PowerUp::PowerUp(float r, float g, float b)
    2931{
    30   this->setClassID(CL_POWER_UP, "PowerUp");
     32  this->registerObject(this, PowerUp::_objectList);
    3133
    3234  this->respawnType = RESPAWN_TIME;
     
    4547
    4648  this->soundSource.setSourceNode(this);
    47   this->pickupBuffer = NULL;
    48   this->respawnBuffer = NULL;
    4949
    5050  this->collider = NULL;
     
    5454{
    5555  delete this->sphereMaterial;
    56   if (this->pickupBuffer != NULL)
    57     ResourceManager::getInstance()->unload(this->pickupBuffer);
    58   if (this->respawnBuffer != NULL)
    59     ResourceManager::getInstance()->unload(this->respawnBuffer);
    6056}
    6157
     
    7773void PowerUp::loadPickupSound(const std::string& pickupSound)
    7874{
    79   if (this->pickupBuffer != NULL)
    80     ResourceManager::getInstance()->unload(this->pickupBuffer);
    81 
    82   else if (!pickupSound.empty())
    83   {
    84     this->pickupBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(pickupSound, WAV);
    85     if (this->pickupBuffer != NULL)
    86     {
    87       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", pickupSound.c_str(), this->getCName());
    88     }
    89     else
    90     {
    91       PRINTF(2)("Failed to load sound %s to pickup %s.\n.", pickupSound.c_str(), this->getCName());
    92     }
    93   }
     75  if (!pickupSound.empty())
     76    this->pickupBuffer = OrxSound::ResourceSoundBuffer(pickupSound);
    9477  else
    95     this->pickupBuffer = NULL;
     78    this->pickupBuffer = OrxSound::SoundBuffer();
    9679}
    9780
    9881void PowerUp::loadRespawnSound(const std::string& respawnSound)
    9982{
    100   if (this->respawnBuffer != NULL)
    101     ResourceManager::getInstance()->unload(this->respawnBuffer);
    102 
    103   else if (!respawnSound.empty())
    104   {
    105     this->respawnBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(respawnSound, WAV);
    106     if (this->respawnBuffer != NULL)
    107     {
    108       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", respawnSound.c_str(), this->getCName());
    109     }
    110     else
    111     {
    112       PRINTF(2)("Failed to load sound %s to respawn %s.\n.", respawnSound.c_str(), this->getCName());
    113     }
    114   }
     83  if (!respawnSound.empty())
     84    this->respawnBuffer = OrxSound::ResourceSoundBuffer(respawnSound);
    11585  else
    116     this->respawnBuffer = NULL;
     86    this->respawnBuffer = OrxSound::SoundBuffer();
    11787}
    11888
     
    12090void PowerUp::collidesWith (WorldEntity* entity, const Vector& location)
    12191{
    122   if(this->collider != entity && entity->isA(CL_EXTENDABLE))
     92  if(this->collider != entity && entity->isA(Extendable::staticClassID()))
    12393  {
    12494    this->collider = entity;
    12595    if(dynamic_cast<Extendable*>(entity)->pickup(this))
    12696    {
    127       if(pickupBuffer != NULL)
     97      if(pickupBuffer.loaded())
    12898        this->soundSource.play(this->pickupBuffer);
    12999
     
    154124      this->toList(OM_COMMON);
    155125      this->collider = NULL;
    156       if (likely(this->respawnBuffer != NULL))
     126      if (likely(this->respawnBuffer.loaded()))
    157127        this->soundSource.play(this->respawnBuffer);
    158128
Note: See TracChangeset for help on using the changeset viewer.