Changeset 4934 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jul 22, 2005, 6:41:46 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/object_manager.h
r4933 r4934 63 63 64 64 protected: 65 FastFactory (ClassID classID, const char* fastFactoryName = NULL); 66 65 67 /** sets the Next factory in the list @param nextFactory the next factory */ 66 68 inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; }; … … 68 70 FastFactory* getNext() const { return this->next; }; 69 71 70 virtual BaseObject* fabricate(ClassID classID) = NULL; 71 72 private: 73 FastFactory (ClassID classID, const char* fastFactoryName = NULL); 72 // virtual BaseObject* fabricate(ClassID classID) = NULL; 73 74 static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL); 75 76 private: 74 77 static void registerFastFactory(FastFactory* fastFactory); 75 static FastFactory* searchFastFactory(ClassID classID, const char* fastFactoryName = NULL);76 78 77 79 protected: … … 92 94 { 93 95 public: 94 static FastFactory* getFastFactory(ClassID classID, const char* fastFactoryName = NULL);96 static tFastFactory<T>* getFastFactory(ClassID classID, const char* fastFactoryName = NULL); 95 97 96 98 void prepare(unsigned int count); … … 126 128 127 129 template<class T> 128 FastFactory* tFastFactory<T>::getFastFactory(ClassID classID, const char* fastFactoryName)130 tFastFactory<T>* tFastFactory<T>::getFastFactory(ClassID classID, const char* fastFactoryName) 129 131 { 130 132 tFastFactory<T>* tmpFac = NULL; 131 133 if (FastFactory::getFirst() != NULL) 132 tmpFac = FastFactory::getFirst()->searchFastFactory(classID, fastFactoryName);134 tmpFac = static_cast<tFastFactory<T>*>(FastFactory::getFirst()->searchFastFactory(classID, fastFactoryName)); 133 135 134 136 if (tmpFac != NULL) 135 137 return tmpFac; 136 138 else 137 return new tFastFactory<T> ;139 return new tFastFactory<T>(classID, fastFactoryName); 138 140 } 139 141 … … 142 144 T* tFastFactory<T>::fabricate() 143 145 { 144 FastObjectMember<T>* tmpFirstDead = this->deadList;146 FastObjectMember<T>* tmpFirstDead = new FastObjectMember<T>; 145 147 tmpFirstDead->objectPointer = new T(); 146 148 tmpFirstDead->next = this->deadList; … … 148 150 149 151 this->deadList = tmpFirstDead; 150 return t his->deadList;152 return tmpFirstDead->objectPointer; 151 153 } 152 154 … … 154 156 void tFastFactory<T>::prepare(unsigned int count) 155 157 { 156 if (this->storedDeadObjects + this->storedLivingObjects >= count)158 /* if (this->storedDeadObjects + this->storedLivingObjects >= count) 157 159 { 158 160 PRINTF(3)("not creating new Objects for class %s, because the requested count already exists\n", this->getClassName()); 159 } 160 for (int i = this->storedDeadObjects + this->storedLivingObjects; i < count; i++)161 }*/ 162 for (int i = this->storedDeadObjects; i < count; i++) 161 163 { 162 164 this->fabricate(); … … 167 169 T* tFastFactory<T>::resurect() 168 170 { 171 PRINTF(4)("Resurecting Object of type %s\n", this->getName()); 169 172 if (unlikely(this->deadList == NULL)) 170 173 { … … 179 182 180 183 tmpC->next = this->unusedContainers; 181 this->unusedContainers ->tmpC;182 183 return tmpC ;184 this->unusedContainers = tmpC; 185 186 return tmpC->objectPointer; 184 187 } 185 188 } -
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4932 r4934 111 111 112 112 this->setActionSound(WA_SHOOT, "sound/shot1.wav"); 113 114 this->bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet"); 115 this->bulletFactory->prepare(100); 113 116 } 114 117 … … 155 158 void TestGun::fire() 156 159 { 157 Projectile* pj = new TestBullet();//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS));160 Projectile* pj = this->bulletFactory->resurect();//new TestBullet();//dynamic_cast<Projectile*>(ObjectManager::getInstance()->getFromDeadList(CL_TEST_BULLET & CL_MASK_LOWLEVEL_CLASS)); 158 161 // weaponSource->play(); 159 162 -
orxonox/trunk/src/world_entities/weapons/test_gun.h
r4927 r4934 30 30 class Quaternion; 31 31 class Animation3D; 32 class TestBullet; 32 33 33 34 34 35 class TestGun : public Weapon 35 {36 { 36 37 public: 37 38 TestGun (PNode* parent, const Vector& coordinate, const Quaternion& direction, int leftRight); … … 54 55 int leftRight; // this will become an enum 55 56 57 tFastFactory<TestBullet>* bulletFactory; //!< The factory for fast interaction with the TestBullet Class. 56 58 57 59 58 };59 60 61 }; 60 62 #endif /* _TEST_GUN_H */ -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4930 r4934 398 398 void Weapon::tickW(float dt) 399 399 { 400 printf("%s ", stateToChar(this->currentState));400 //printf("%s ", stateToChar(this->currentState)); 401 401 402 402 // setting up the timing properties -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4930 r4934 26 26 class Animation3D; 27 27 class TiXmlElement; 28 template<class T> class tFastFactory; 28 29 29 30 //! An enumerator defining Actions a Weapon can take
Note: See TracChangeset
for help on using the changeset viewer.