Changeset 4930 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jul 22, 2005, 2:11:21 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/object_manager.cc
r4836 r4930 19 19 #include "list.h" 20 20 21 #include "debug.h" 21 22 22 23 using namespace std; … … 106 107 PRINT(0)("=======================================================\n"); 107 108 } 109 110 /** 111 * constructor 112 113 set everything to zero and define factoryName 114 */ 115 FastObject::FastObject (const char* fastObjectName, ClassID classID) 116 { 117 this->setClassID(CL_FACTORY, "FastObject"); 118 this->setName(fastObjectName); 119 120 this->storedClassID = classID; 121 this->next = NULL; 122 123 FastObject::registerFastObject(this); 124 } 125 126 /** a reference to the First FastObject */ 127 FastObject* FastObject::first = NULL; 128 129 /** 130 * destructor 131 132 clear the Q 133 */ 134 FastObject::~FastObject () 135 { 136 // printf("%s\n", this->factoryName); 137 // FastObject* tmpDel = this->next; 138 // this->next = NULL; 139 if (this->next) 140 delete this->next; 141 } 142 143 /** 144 * add a FastObject to the FastObject Queue 145 * @param factory a FastObject to be registered 146 */ 147 void FastObject::registerFastObject( FastObject* factory) 148 { 149 PRINTF(4)("Registered FastObject for '%s'\n", factory->getName()); 150 151 if( FastObject::first == NULL) 152 FastObject::first = factory; 153 else 154 { 155 FastObject* tmpFac = FastObject::first; 156 while( tmpFac->next != NULL) 157 { 158 tmpFac = tmpFac->next; 159 } 160 tmpFac->setNext(factory); 161 } 162 } -
orxonox/trunk/src/util/object_manager.h
r4836 r4930 10 10 11 11 TO ADD SUPPORT FOR A CLASS do the following steps: 12 1. include the hader file : #include "class_ header.h"12 1. include the hader file : #include "class_id.h" 13 13 2. add the class to the type enum classID {}; in class_id.h 14 14 3. define a function void mCache( ClassName ) in class ObjectManager … … 21 21 22 22 #include "base_object.h" 23 #include "projectile.h"24 #include "list.h"25 23 24 template<class T> class tList; 26 25 class GarbageCollector; 27 28 29 //! This defines the "template" macro function for cache(...)30 #define mCache( Class ) \31 cache(ClassID index, int number, Class * copyObject) \32 { \33 this->managedObjectList[index] = new tList<BaseObject>(); \34 for(int i = 0; i < number; ++i)\35 {\36 this->managedObjectList[index]->add(new Class (*copyObject));\37 }\38 }39 40 41 26 42 27 //! the object manager itself … … 51 36 52 37 /** a class handled by the objectManage */ 53 void mCache(Projectile);54 38 void addToDeadList(int index, BaseObject* object); 55 39 BaseObject* getFromDeadList(int index, int number = 1); 40 41 BaseObject* resurect(); 42 void kill(BaseObject* object); 43 56 44 57 45 void debug() const; … … 68 56 69 57 58 /** 59 * Creates a factory to a Loadable Class. 60 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 61 */ 62 #define CREATE_FAST_FACTORY(CLASS_NAME, CLASS_ID) \ 63 tObject<CLASS_NAME>* global_##CLASS_NAME##_Object = new tObject<CLASS_NAME>(#CLASS_NAME, CLASS_ID) 64 65 //! The Factory is a loadable object handler 66 class FastObject : public BaseObject { 67 68 public: 69 FastObject (const char* fastObjectName = NULL, ClassID classID = CL_NULL); 70 virtual ~FastObject (); 71 72 virtual BaseObject* fabricate(ClassID classID) = NULL; 73 74 static void registerFastObject(FastObject* fastObject); 75 /** sets the Next factory in the list @param nextFactory the next factory */ 76 inline void setNext( FastObject* nextFastObject) { this->next = nextFastObject; }; 77 /** @returns the first factory */ 78 static FastObject* getFirst() { return FastObject::first; }; 79 /** @returns the next factory */ 80 FastObject* getNext() const { return this->next; }; 81 82 private: 83 FastObject* next; //!< pointer to the next factory. 84 static FastObject* first; //!< A pointer to the first factory. 85 ClassID storedClassID; //!< The classID of the specified class. 86 }; 87 88 /** 89 * a factory that is able to load any kind of Object 90 (this is a Functor) 91 */ 92 template<class T> class tFastObject : public FastObject 93 { 94 public: 95 tFastObject(const char* fastObjectName, ClassID fastObject); 96 97 private: 98 virtual BaseObject* fabricate(ClassID fastObject); 99 }; 100 101 /** 102 * construnts a factory with 103 * @param factoryName the name of the factory 104 */ 105 template<class T> 106 tFastObject<T>::tFastObject(const char* fastObjectName, ClassID fastObject) : FastObject(fastObjectName, fastObject) 107 { 108 PRINTF(5)("Class: %s loadable as a FastObject\n", this->getName()); 109 } 110 111 template<class T> 112 BaseObject* tFastObject<T>::fabricate(ClassID fastObject) 113 { 114 if(this->classID == fastObject) 115 return new T ( root); 116 else if( getNext() != NULL) 117 return getNext()->fabricate( root); 118 else 119 return NULL; 120 } 121 70 122 #endif /* _OBJECT_MANAGER_H */ -
orxonox/trunk/src/world_entities/weapons/test_gun.cc
r4927 r4930 105 105 this->setStateDuration(WS_DEACTIVATING, .4); 106 106 107 this->setMaximumEnergy(1000, 10); 107 108 this->increaseEnergy(100); 108 109 //this->minCharge = 2; -
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4927 r4930 88 88 89 89 this->energyLoaded = .0; 90 this->energyLoadedMax = 10.0;90 this->energyLoadedMax = 5.0; 91 91 this->energy = .0; 92 this->energyMax = 10 0.0;92 this->energyMax = 10.0; 93 93 } 94 94 … … 112 112 if (action >= WA_ACTION_COUNT) 113 113 return; 114 if (this->soundBuffers[action] != NULL) 115 ResourceManager::getInstance()->unload(this->soundBuffers[action]); 116 114 117 else if (soundFile != NULL) 115 118 { … … 330 333 { 331 334 this->requestAction(WA_RELOAD); 335 this->execute(); 332 336 } 333 337 } … … 344 348 { 345 349 this->requestAction(WA_DEACTIVATE); 350 this->execute(); 346 351 return false; 347 352 } -
orxonox/trunk/src/world_entities/weapons/weapon.h
r4927 r4930 110 110 111 111 /** @param energyMax the maximum energy the Weapon can have @param energyLoadedMax the maximum energy in the weapon buffers */ 112 inline void setMaximumEnergy(float energyMax, float energyLoadedMax = 0.0) { this->energyMax = energyMax; this->energyLoadedMax = energyLoadedMax; };112 inline void setMaximumEnergy(float energyMax, float energyLoadedMax) { this->energyMax = energyMax; this->energyLoadedMax = energyLoadedMax; }; 113 113 114 114 void setActionSound(WeaponAction action, const char* soundFile); … … 185 185 186 186 bool hideInactive; //!< Hides the Weapon if it is inactive 187 bool chargeable; //!< if the Weapon is charcheable 187 bool chargeable; //!< if the Weapon is charcheable (if true, the weapon will charge before it fires.) 188 188 189 189 Projectile* projectile; //!< the projectile used for this weapon -
orxonox/trunk/src/world_entities/weapons/weapon_manager.h
r4926 r4930 104 104 int currConfID; //<! the currently selected config 105 105 weaponConfig configs[4]; //<! a list of four configurations 106 107 106 };
Note: See TracChangeset
for help on using the changeset viewer.