Changeset 9705 in orxonox.OLD for branches/new_class_id/src/world_entities/weapons
- Timestamp:
- Aug 25, 2006, 9:44:53 PM (18 years ago)
- 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 23 23 24 24 25 25 NewObjectListDefinition(AmmoContainer); 26 26 /** 27 27 * standard constructor 28 28 * @todo this constructor is not jet implemented - do it 29 29 */ 30 AmmoContainer::AmmoContainer ( ClassIDprojectileType, float maxEnergy)30 AmmoContainer::AmmoContainer (const NewClassID& projectileType, float maxEnergy) 31 31 { 32 this->setClassID(CL_AMMO_CONTAINER, "AmmoContainer");32 this->registerObject(this, AmmoContainer::_objectList); 33 33 34 35 34 this->projectileType = projectileType; 35 this->maxEnergy = maxEnergy; 36 36 37 37 this->energy = 0.0; 38 38 } 39 39 -
branches/new_class_id/src/world_entities/weapons/ammo_container.h
r9685 r9705 17 17 //! A class for Storing energy of Projectiles. 18 18 class AmmoContainer : public BaseObject { 19 NewObjectListDeclaration(AmmoContainer); 19 20 20 21 public: 21 AmmoContainer( NewClassIDid, float maxEnergy = DEFAULT_MAX_ENERGY);22 AmmoContainer(const NewClassID& id, float maxEnergy = DEFAULT_MAX_ENERGY); 22 23 virtual ~AmmoContainer(); 23 24 -
branches/new_class_id/src/world_entities/weapons/crosshair.cc
r9406 r9705 26 26 27 27 28 28 NewObjectListDefinition(Crosshair); 29 29 /** 30 30 * standart constructor … … 54 54 void Crosshair::init() 55 55 { 56 this-> setClassID(CL_CROSSHAIR, "Crosshair");56 this->registerObject(this, Crosshair::_objectList); 57 57 this->setName("Crosshair"); 58 58 -
branches/new_class_id/src/world_entities/weapons/crosshair.h
r7221 r9705 22 22 //! A class that enables the 23 23 class Crosshair : public PNode, public Element2D, public EventListener { 24 24 NewObjectListDeclaration(Crosshair); 25 25 public: 26 26 Crosshair(const TiXmlElement* root = NULL); -
branches/new_class_id/src/world_entities/weapons/weapon.cc
r9406 r9705 25 25 26 26 #include "util/loading/resource_manager.h" 27 #include "class_list.h"28 27 #include "util/loading/factory.h" 29 28 #include "util/loading/load_param.h" … … 36 35 #include "elements/glgui_energywidget.h" 37 36 38 37 NewObjectListDefinition(Weapon); 39 38 40 39 //////////////////// … … 58 57 { 59 58 for (int i = 0; i < WS_STATE_COUNT; i++) 60 if (this->animation[i] && ClassList::exists(animation[i], CL_ANIMATION)) //!< @todo this should check animation3D59 if (this->animation[i] && Animation::objectList().exists(animation[i])) //!< @todo this should check animation3D 61 60 delete this->animation[i]; 62 61 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])) 64 63 ResourceManager::getInstance()->unload(this->soundBuffers[i]); 65 64 66 if ( ClassList::exists(this->soundSource, CL_SOUND_SOURCE))65 if (OrxSound::SoundSource::objectList().exists(this->soundSource)) 67 66 delete this->soundSource; 68 67 } … … 73 72 * @returns the newly created Weapon. 74 73 */ 75 Weapon* Weapon::createWeapon( ClassIDweaponID)74 Weapon* Weapon::createWeapon(const NewClassID& weaponID) 76 75 { 77 76 BaseObject* createdObject = Factory::fabricate(weaponID); 78 77 if (createdObject != NULL) 79 78 { 80 if (createdObject->isA( CL_WEAPON))79 if (createdObject->isA(Weapon::classID())) 81 80 return dynamic_cast<Weapon*>(createdObject); 82 81 else … … 89 88 } 90 89 90 Weapon* 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 91 107 /** 92 108 * initializes the Weapon with ALL default values … … 96 112 void Weapon::init() 97 113 { 98 this-> setClassID(CL_WEAPON, "Weapon");114 this->registerObject(this, Weapon::_objectList); 99 115 this->currentState = WS_INACTIVE; //< Normaly the Weapon is Inactive 100 116 this->requestedAction = WA_NONE; //< No action is requested by default … … 115 131 this->defaultTarget = NULL; //< Nothing is Targeted by default. 116 132 117 this->projectile = CL_NULL;//< No Projectile Class is Connected to this weapon133 this->projectile = NullClass::classID(); //< No Projectile Class is Connected to this weapon 118 134 this->projectileFactory = NULL; //< No Factory generating Projectiles is selected. 119 135 … … 163 179 * What it does, is telling the Weapon what Projectiles it can Emit. 164 180 */ 165 void Weapon::setProjectileType(ClassID projectile) 166 { 167 if (projectile == CL_NULL) 168 return; 181 void Weapon::setProjectileType(const NewClassID& projectile) 182 { 169 183 this->projectile = projectile; 170 184 this->projectileFactory = FastFactory::searchFastFactory(projectile); -
branches/new_class_id/src/world_entities/weapons/weapon.h
r9685 r9705 83 83 class Weapon : public WorldEntity 84 84 { 85 NewObjectListDeclaration(Weapon); 86 85 87 public: 86 88 // INITIALISATION // 87 89 Weapon (); 88 90 virtual ~Weapon (); 89 static Weapon* createWeapon(NewClassID weaponID); 91 static Weapon* createWeapon(const NewClassID& weaponID); 92 static Weapon* createWeapon(const std::string& weaponName); 90 93 91 94 void init(); … … 110 113 /** @returns the Capabilities of this Weapon */ 111 114 inline long getCapability() const { return this->capability; }; 112 void setProjectileType( NewClassIDprojectile);115 void setProjectileType(const NewClassID& projectile); 113 116 void setProjectileTypeC(const std::string& projectile); 114 117 /** @returns The projectile's classID */ -
branches/new_class_id/src/world_entities/weapons/weapon_manager.cc
r9406 r9705 22 22 #include "weapon.h" 23 23 #include "crosshair.h" 24 #include "class_list.h"25 24 26 25 #include "playable.h" … … 32 31 33 32 33 NewObjectListDefinition(WeaponManager); 34 34 /** 35 35 * @brief this initializes the weaponManager for a given nnumber of weapon slots … … 57 57 // crosshair being a PNode it must not be deleted (this is because PNodes delete themselves.) 58 58 // rennerc: crosshair seems not to delete itselve 59 if (C lassList::exists(this->crosshair, CL_CROSSHAIR))59 if (Crosshair::objectList().exists(this->crosshair)) 60 60 delete this->crosshair; 61 61 } … … 66 66 void WeaponManager::init() 67 67 { 68 this-> setClassID(CL_WEAPON_MANAGER, "WeaponManager");68 this->registerObject(this, WeaponManager::_objectList); 69 69 70 70 this->parentNode = NULL; … … 298 298 { 299 299 this->parentNode->addChild(weapon); 300 if (this->parentEntity->isA( CL_PLAYABLE))300 if (this->parentEntity->isA(Playable::classID())) 301 301 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 302 302 weapon->setDefaultTarget(this->crosshair); … … 311 311 * @param ammo the ammo to increase 312 312 */ 313 float WeaponManager::increaseAmmunition( ClassIDprojectileType, float ammo)313 float WeaponManager::increaseAmmunition(const NewClassID& projectileType, float ammo) 314 314 { 315 315 return this->getAmmoContainer(projectileType)->increaseEnergy(ammo); … … 324 324 { 325 325 assert (weapon != NULL); 326 return this->increaseAmmunition(weapon->get LeafClassID(), ammo);326 return this->increaseAmmunition(weapon->getClassID(), ammo); 327 327 328 328 } … … 468 468 else 469 469 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())) 471 471 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 472 472 } … … 523 523 } 524 524 525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer( ClassIDprojectileType)525 CountPointer<AmmoContainer>& WeaponManager::getAmmoContainer(const NewClassID& projectileType) 526 526 { 527 527 for (unsigned int i = 0; i < this->ammo.size(); i++) … … 537 537 { 538 538 assert (weapon != NULL); 539 return (this->getAmmoContainer(weapon->get LeafClassID()));539 return (this->getAmmoContainer(weapon->getClassID())); 540 540 } 541 541 -
branches/new_class_id/src/world_entities/weapons/weapon_manager.h
r9685 r9705 39 39 */ 40 40 class WeaponManager : public BaseObject { 41 NewObjectListDeclaration(WeaponManager); 41 42 42 43 //! an enumerator defining a Slot, where a Weapon can be stored inside. … … 89 90 void changeWeaponConfig(int weaponConfig); 90 91 91 float increaseAmmunition( NewClassIDprojectileType, float ammo);92 float increaseAmmunition(const NewClassID& projectileType, float ammo); 92 93 float inclreaseAmmunition(const Weapon* weapon, float ammo); 93 94 … … 106 107 // private: 107 108 int getNextFreeSlot(int configID, long capability = WTYPE_ALL); 108 CountPointer<AmmoContainer>& getAmmoContainer( NewClassIDprojectileType);109 CountPointer<AmmoContainer>& getAmmoContainer(const NewClassID& projectileType); 109 110 CountPointer<AmmoContainer>& getAmmoContainer(const Weapon* weapon); 110 111
Note: See TracChangeset
for help on using the changeset viewer.