Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2006, 9:44:53 PM (18 years ago)
Author:
bensch
Message:

adapted many more classes

File:
1 edited

Legend:

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

    r9406 r9705  
    2525
    2626#include "util/loading/resource_manager.h"
    27 #include "class_list.h"
    2827#include "util/loading/factory.h"
    2928#include "util/loading/load_param.h"
     
    3635#include "elements/glgui_energywidget.h"
    3736
    38 
     37NewObjectListDefinition(Weapon);
    3938
    4039////////////////////
     
    5857{
    5958  for (int i = 0; i < WS_STATE_COUNT; i++)
    60     if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION))  //!< @todo this should check animation3D
     59    if (this->animation[i] && Animation::objectList().exists(animation[i]))  //!< @todo this should check animation3D
    6160      delete this->animation[i];
    6261  for (int i = 0; i < WA_ACTION_COUNT; i++)
    63     if (this->soundBuffers[i] != NULL && ClassList::exists(this->soundBuffers[i], CL_SOUND_BUFFER))
     62    if (this->soundBuffers[i] != NULL && OrxSound::SoundBuffer::objectList().exists(this->soundBuffers[i]))
    6463      ResourceManager::getInstance()->unload(this->soundBuffers[i]);
    6564
    66   if (ClassList::exists(this->soundSource, CL_SOUND_SOURCE))
     65  if (OrxSound::SoundSource::objectList().exists(this->soundSource))
    6766    delete this->soundSource;
    6867}
     
    7372 * @returns the newly created Weapon.
    7473 */
    75 Weapon* Weapon::createWeapon(ClassID weaponID)
     74Weapon* Weapon::createWeapon(const NewClassID& weaponID)
    7675{
    7776  BaseObject* createdObject = Factory::fabricate(weaponID);
    7877  if (createdObject != NULL)
    7978  {
    80     if (createdObject->isA(CL_WEAPON))
     79    if (createdObject->isA(Weapon::classID()))
    8180      return dynamic_cast<Weapon*>(createdObject);
    8281    else
     
    8988}
    9089
     90Weapon* Weapon::createWeapon(const std::string& weaponName)
     91{
     92  BaseObject* createdObject = Factory::fabricate(weaponName);
     93  if (createdObject != NULL)
     94  {
     95    if (createdObject->isA(Weapon::classID()))
     96      return dynamic_cast<Weapon*>(createdObject);
     97    else
     98    {
     99      delete createdObject;
     100      return NULL;
     101    }
     102  }
     103  return NULL;
     104}
     105
     106
    91107/**
    92108 * initializes the Weapon with ALL default values
     
    96112void Weapon::init()
    97113{
    98   this->setClassID(CL_WEAPON, "Weapon");
     114  this->registerObject(this, Weapon::_objectList);
    99115  this->currentState     = WS_INACTIVE;            //< Normaly the Weapon is Inactive
    100116  this->requestedAction  = WA_NONE;                //< No action is requested by default
     
    115131  this->defaultTarget = NULL;                      //< Nothing is Targeted by default.
    116132
    117   this->projectile = CL_NULL;                      //< No Projectile Class is Connected to this weapon
     133  this->projectile = NullClass::classID();         //< No Projectile Class is Connected to this weapon
    118134  this->projectileFactory = NULL;                  //< No Factory generating Projectiles is selected.
    119135
     
    163179 * What it does, is telling the Weapon what Projectiles it can Emit.
    164180 */
    165 void Weapon::setProjectileType(ClassID projectile)
    166 {
    167   if (projectile == CL_NULL)
    168     return;
     181void Weapon::setProjectileType(const NewClassID& projectile)
     182{
    169183  this->projectile = projectile;
    170184  this->projectileFactory = FastFactory::searchFastFactory(projectile);
Note: See TracChangeset for help on using the changeset viewer.