- Timestamp:
- Jul 23, 2005, 11:17:27 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/fast_factory.h
r4941 r4947 64 64 65 65 /** @returns the first FastFactory */ 66 static FastFactory* getFirst() 67 { 68 return FastFactory::first; 69 }; 66 inline static FastFactory* getFirst() { return FastFactory::first; }; 67 68 static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL); 70 69 71 70 protected: … … 73 72 74 73 /** sets the Next factory in the list @param nextFactory the next factory */ 75 inline void setNext( FastFactory* nextFastFactory) 76 { 77 this->next = nextFastFactory; 78 }; 74 inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; }; 79 75 /** @returns the next FastFactory */ 80 FastFactory* getNext() const 81 { 82 return this->next; 83 }; 76 FastFactory* getNext() const { return this->next; }; 84 77 85 78 /** generates a new Object of the Class T */ 86 79 virtual void fabricate() = NULL; 87 static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL);88 80 89 81 private: -
orxonox/trunk/src/world_entities/weapons/test_bullet.cc
r4942 r4947 22 22 #include "vector.h" 23 23 #include "garbage_collector.h" 24 #include "fast_factory.h" 24 25 25 26 using namespace std; 26 27 28 CREATE_FAST_FACTORY(TestBullet, CL_TEST_BULLET); 27 29 28 30 /** -
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4940 r4947 112 112 this->setActionSound(WA_SHOOT, "sound/shot1.wav"); 113 113 114 this-> bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet");115 this-> bulletFactory->prepare(100);114 this->setProjectile(CL_TEST_BULLET); 115 this->getProjectileFactory()->prepare(100); 116 116 } 117 117 … … 158 158 void TestGun::fire() 159 159 { 160 Projectile* pj = dynamic_cast<Projectile*>(this-> bulletFactory->resurrect());160 Projectile* pj = dynamic_cast<Projectile*>(this->getProjectileFactory()->resurrect()); 161 161 162 162 pj->setAbsCoor(this->getEmissionPoint()); -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4934 r4947 54 54 55 55 int leftRight; // this will become an enum 56 57 tFastFactory<TestBullet>* bulletFactory; //!< The factory for fast interaction with the TestBullet Class.58 59 60 61 56 }; 62 57 #endif /* _TEST_GUN_H */ -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4934 r4947 80 80 this->emissionPoint.setParent(this); 81 81 82 this->projectile = NULL; 82 this->projectile = CL_NULL; 83 this->projectileFactory = NULL; 83 84 84 85 this->hideInactive = true; … … 93 94 } 94 95 96 /** 97 * sets the Projectile to use for this weapon. 98 * @param projectile The ID of the Projectile to use 99 * 100 * be aware, that this function does not create Factories, as this is job of Bullet-classes. 101 */ 102 bool Weapon::setProjectile(ClassID projectile) 103 { 104 if (projectile == CL_NULL) 105 return false; 106 this->projectile = projectile; 107 this->projectileFactory = FastFactory::searchFastFactory(projectile); 108 if (this->projectileFactory == NULL) 109 return false; 110 }; 95 111 96 112 /** … … 446 462 bool retVal = true; 447 463 448 if (this->projectile == NULL)464 // if (this->projectile == NULL) 449 465 { 450 466 PRINTF(2)("There was no projectile assigned to the Weapon.\n"); -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4934 r4947 20 20 21 21 #include "world_entity.h" 22 #include "fast_factory.h" 22 23 23 24 // FORWARD DECLARATION … … 79 80 //////////////////// 80 81 82 // INTERACTIVITY // 81 83 void requestAction(WeaponAction action); 82 84 float increaseEnergy(float energyToAdd); 85 /////////////////// 86 83 87 84 88 /** @returns true if the Weapon is Active (this is used to check if the weapon must be drawn)*/ … … 88 92 89 93 // FUNCTIONS TO SET THE WEAPONS PROPERTIES. 90 /** @param projectile a projectile for this weapon */ 91 void setProjectile(Projectile* projectile) { this->projectile = projectile; }; 92 /** @returns The projectile if availiable */ 93 Projectile* getProjectile() { return this->projectile; }; 94 bool setProjectile(ClassID projectile); 95 /** @returns The projectile's classID */ 96 inline ClassID getProjectile() { return this->projectile; }; 97 /** @returns the FastFactory, that creates Projectiles of type getProjectile */ 98 inline FastFactory* getProjectileFactory() { return this->projectileFactory; }; 99 94 100 95 101 void setEmissionPoint(const Vector& point); … … 188 194 bool chargeable; //!< if the Weapon is charcheable (if true, the weapon will charge before it fires.) 189 195 190 Projectile* projectile; //!< the projectile used for this weapon 196 ClassID projectile; //!< the projectile used for this weapon (since they should be generated via macro and the FastFactory, only the ClassID must be known.) 197 FastFactory* projectileFactory; //!< A factory, that produces and handles the projectiles. 191 198 }; 192 199
Note: See TracChangeset
for help on using the changeset viewer.