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/projectiles/projectile.cc

    r9656 r9869  
    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"
    2727
     28ObjectListDefinition(Projectile);
    2829
    2930/**
     
    3233Projectile::Projectile () : WorldEntity()
    3334{
    34   this->setClassID(CL_PROJECTILE, "Projectile");
     35  this->registerObject(this, Projectile::_objectList);
    3536
    3637  this->lifeCycle = 0.0;
     
    4344  this->setDamage(1.0f); // default damage of a projectile set to 100.0 damage points
    4445
    45   this->explosionBuffer = NULL;
    46   this->engineBuffer = NULL;
    47 
    4846  //this->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    4947}
     
    5553Projectile::~Projectile ()
    5654{
    57   if (this->explosionBuffer != NULL)
    58     ResourceManager::getInstance()->unload(this->explosionBuffer);
    59   if (this->engineBuffer != NULL)
    60     ResourceManager::getInstance()->unload(this->engineBuffer);
    6155  /*
    6256     do not delete the test projectModel, since it is pnode
     
    6963void Projectile::loadExplosionSound(const std::string& explosionSound)
    7064{
    71   if (this->explosionBuffer != NULL)
    72     ResourceManager::getInstance()->unload(this->explosionBuffer);
    73 
    74   else if (!explosionSound.empty())
    75   {
    76     this->explosionBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(explosionSound, WAV);
    77     if (this->explosionBuffer != NULL)
    78     {
    79       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", explosionSound.c_str(), this->getCName());
    80     }
    81     else
    82     {
    83       PRINTF(2)("Failed to load sound %s to explosion %s.\n.", explosionSound.c_str(), this->getCName());
    84     }
    85   }
     65  if (!explosionSound.empty())
     66    this->explosionBuffer = OrxSound::ResourceSoundBuffer(explosionSound);
    8667  else
    87     this->explosionBuffer = NULL;
     68    this->explosionBuffer = OrxSound::SoundBuffer();
    8869}
    8970
     
    9172void Projectile::loadEngineSound(const std::string& engineSound)
    9273{
    93   if (this->engineBuffer != NULL)
    94     ResourceManager::getInstance()->unload(this->engineBuffer);
    95 
    96   else if (!engineSound.empty())
    97   {
    98     this->engineBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load(engineSound, WAV);
    99     if (this->engineBuffer != NULL)
    100     {
    101       PRINTF(4)("Loaded sound %s to Pickup: %s.\n", engineSound.c_str(), this->getCName());
    102     }
    103     else
    104     {
    105       PRINTF(2)("Failed to load sound %s to engine %s.\n.", engineSound.c_str(), this->getCName());
    106     }
    107   }
     74  if (!engineSound.empty())
     75    this->engineBuffer = OrxSound::ResourceSoundBuffer(engineSound);
    10876  else
    109     this->engineBuffer = NULL;
     77    this->engineBuffer = OrxSound::SoundBuffer();
    11078}
    11179
     
    139107  //Vector offsetVel =
    140108  this->velocity = velocity;
    141  // offsetVel.normalize();
     109  // offsetVel.normalize();
    142110  //this->velocity += (offsetVel * 50.0);
    143111}
     
    148116{
    149117  if (this->target == NULL)
    150     this->target = new PNode(target, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_ON_PARENTS_REMOVE);
     118    this->target = new PNode(target, PNODE_REPARENT_ON_PARENTS_REMOVE | PNODE_REPARENT_TO_NULL | PNODE_PROHIBIT_DELETE_WITH_PARENT);
    151119  else
    152120    this->target->setParent(target);
     
    173141void Projectile::destroy (WorldEntity* killer)
    174142{
    175   if (this->explosionBuffer != NULL)
     143  if (this->explosionBuffer.loaded())
    176144    this->soundSource.play(this->explosionBuffer);
    177145}
Note: See TracChangeset for help on using the changeset viewer.