Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

adapted many more classes

Location:
branches/new_class_id/src/world_entities/weapons
Files:
8 edited

Legend:

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

    r9406 r9705  
    2323
    2424
    25 
     25NewObjectListDefinition(AmmoContainer);
    2626/**
    2727 * standard constructor
    2828 * @todo this constructor is not jet implemented - do it
    2929*/
    30 AmmoContainer::AmmoContainer (ClassID projectileType, float maxEnergy)
     30AmmoContainer::AmmoContainer (const NewClassID& projectileType, float maxEnergy)
    3131{
    32    this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");
     32  this->registerObject(this, AmmoContainer::_objectList);
    3333
    34    this->projectileType = projectileType;
    35    this->maxEnergy = maxEnergy;
     34  this->projectileType = projectileType;
     35  this->maxEnergy = maxEnergy;
    3636
    37    this->energy = 0.0;
     37  this->energy = 0.0;
    3838}
    3939
  • branches/new_class_id/src/world_entities/weapons/ammo_container.h

    r9685 r9705  
    1717//! A class for Storing energy of Projectiles.
    1818class AmmoContainer : public BaseObject {
     19  NewObjectListDeclaration(AmmoContainer);
    1920
    2021 public:
    21   AmmoContainer(NewClassID id, float maxEnergy = DEFAULT_MAX_ENERGY);
     22  AmmoContainer(const NewClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY);
    2223  virtual ~AmmoContainer();
    2324
  • branches/new_class_id/src/world_entities/weapons/crosshair.cc

    r9406 r9705  
    2626
    2727
    28 
     28NewObjectListDefinition(Crosshair);
    2929/**
    3030 * standart constructor
     
    5454void Crosshair::init()
    5555{
    56   this->setClassID(CL_CROSSHAIR, "Crosshair");
     56  this->registerObject(this, Crosshair::_objectList);
    5757  this->setName("Crosshair");
    5858
  • branches/new_class_id/src/world_entities/weapons/crosshair.h

    r7221 r9705  
    2222//! A class that enables the
    2323class Crosshair : public PNode, public Element2D, public EventListener {
    24 
     24  NewObjectListDeclaration(Crosshair);
    2525 public:
    2626  Crosshair(const TiXmlElement* root = NULL);
  • 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);
  • branches/new_class_id/src/world_entities/weapons/weapon.h

    r9685 r9705  
    8383class Weapon : public WorldEntity
    8484{
     85  NewObjectListDeclaration(Weapon);
     86
    8587  public:
    8688    // INITIALISATION //
    8789    Weapon ();
    8890    virtual ~Weapon ();
    89     static Weapon* createWeapon(NewClassID weaponID);
     91    static Weapon* createWeapon(const NewClassID& weaponID);
     92    static Weapon* createWeapon(const std::string& weaponName);
    9093
    9194    void init();
     
    110113    /** @returns the Capabilities of this Weapon */
    111114    inline long getCapability() const { return this->capability; };
    112     void setProjectileType(NewClassID projectile);
     115    void setProjectileType(const NewClassID& projectile);
    113116    void setProjectileTypeC(const std::string& projectile);
    114117    /** @returns The projectile's classID */
  • branches/new_class_id/src/world_entities/weapons/weapon_manager.cc

    r9406 r9705  
    2222#include "weapon.h"
    2323#include "crosshair.h"
    24 #include "class_list.h"
    2524
    2625#include "playable.h"
     
    3231
    3332
     33NewObjectListDefinition(WeaponManager);
    3434/**
    3535 * @brief this initializes the weaponManager for a given nnumber of weapon slots
     
    5757  // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.)
    5858  // rennerc: crosshair seems not to delete itselve
    59   if (ClassList::exists(this->crosshair, CL_CROSSHAIR))
     59  if (Crosshair::objectList().exists(this->crosshair))
    6060    delete this->crosshair;
    6161}
     
    6666void WeaponManager::init()
    6767{
    68   this->setClassID(CL_WEAPON_MANAGER, "WeaponManager");
     68  this->registerObject(this, WeaponManager::_objectList);
    6969
    7070  this->parentNode = NULL;
     
    298298  {
    299299    this->parentNode->addChild(weapon);
    300     if (this->parentEntity->isA(CL_PLAYABLE))
     300    if (this->parentEntity->isA(Playable::classID()))
    301301      dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    302302    weapon->setDefaultTarget(this->crosshair);
     
    311311 * @param ammo the ammo to increase
    312312 */
    313 float WeaponManager::increaseAmmunition(ClassID projectileType, float ammo)
     313float WeaponManager::increaseAmmunition(const NewClassID& projectileType, float ammo)
    314314{
    315315  return this->getAmmoContainer(projectileType)->increaseEnergy(ammo);
     
    324324{
    325325  assert (weapon != NULL);
    326   return this->increaseAmmunition(weapon->getLeafClassID(), ammo);
     326  return this->increaseAmmunition(weapon->getClassID(), ammo);
    327327
    328328}
     
    468468      else
    469469        this->currentSlotConfig[i].position.deactivateNode();
    470       if (this->parentEntity != NULL && this->parentEntity->isA(CL_PLAYABLE))
     470      if (this->parentEntity != NULL && this->parentEntity->isA(Playable::classID()))
    471471        dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged();
    472472    }
     
    523523}
    524524
    525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(ClassID projectileType)
     525CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const NewClassID& projectileType)
    526526{
    527527  for (unsigned int i = 0; i < this->ammo.size(); i++)
     
    537537{
    538538  assert (weapon != NULL);
    539   return (this->getAmmoContainer(weapon->getLeafClassID()));
     539  return (this->getAmmoContainer(weapon->getClassID()));
    540540}
    541541
  • branches/new_class_id/src/world_entities/weapons/weapon_manager.h

    r9685 r9705  
    3939 */
    4040class WeaponManager : public BaseObject {
     41  NewObjectListDeclaration(WeaponManager);
    4142
    4243  //! an enumerator defining a Slot, where a Weapon can be stored inside.
     
    8990    void changeWeaponConfig(int weaponConfig);
    9091
    91     float increaseAmmunition(NewClassID projectileType, float ammo);
     92    float increaseAmmunition(const NewClassID& projectileType, float ammo);
    9293    float inclreaseAmmunition(const Weapon* weapon, float ammo);
    9394
     
    106107 // private:
    107108    int getNextFreeSlot(int configID, long capability = WTYPE_ALL);
    108     CountPointer<AmmoContainer>& getAmmoContainer(NewClassID projectileType);
     109    CountPointer<AmmoContainer>& getAmmoContainer(const NewClassID& projectileType);
    109110    CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon);
    110111
Note: See TracChangeset for help on using the changeset viewer.