Rev | Line | |
---|
[7819] | 1 | /*! |
---|
| 2 | * @file cr_engine.h |
---|
| 3 | * @brief The collision reaction engine, defining generic collision reactions to collision events |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _CR_ENGINE_ |
---|
| 7 | #define _CR_ENGINE_ |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
[7865] | 10 | #include <stdarg.h> |
---|
| 11 | #include <vector> |
---|
[7819] | 12 | |
---|
| 13 | // FORWARD DECLARATION |
---|
[7839] | 14 | class CollisionHandle; |
---|
| 15 | class Collision; |
---|
[7865] | 16 | class WorldEntity; |
---|
[7819] | 17 | |
---|
| 18 | //! A default singleton class. |
---|
[7839] | 19 | class CREngine : public BaseObject |
---|
| 20 | { |
---|
[7865] | 21 | |
---|
[7839] | 22 | typedef enum CRType { |
---|
| 23 | CR_CONSERVATION_OF_MOMENTUM = 0, |
---|
| 24 | |
---|
| 25 | CR_OBJECT_DAMAGE, |
---|
| 26 | CR_OBJECT_PICKUP, |
---|
| 27 | |
---|
| 28 | CR_VERTEX_TRAFO, |
---|
| 29 | |
---|
| 30 | CR_CALLBACK, |
---|
| 31 | |
---|
| 32 | CR_NUMBER |
---|
| 33 | }; |
---|
| 34 | |
---|
[7865] | 35 | |
---|
[7839] | 36 | public: |
---|
[7819] | 37 | virtual ~CREngine(void); |
---|
| 38 | /** @returns a Pointer to the only object of this Class */ |
---|
| 39 | inline static CREngine* getInstance(void) { if (!singletonRef) singletonRef = new CREngine(); return singletonRef; }; |
---|
| 40 | |
---|
[7865] | 41 | |
---|
[7841] | 42 | CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type, int nrOfTargets, ...); |
---|
[7819] | 43 | |
---|
[7839] | 44 | bool unsubscribeReaction(WorldEntity* worldEntity); |
---|
| 45 | bool unsubscribeReaction(CollisionHandle* collisionHandle); |
---|
| 46 | |
---|
| 47 | |
---|
[7841] | 48 | void handleCollisions(); |
---|
| 49 | |
---|
[7839] | 50 | /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */ |
---|
[7843] | 51 | inline Collision* getCollisionObject() { /* return the first element of the cache list*/ } |
---|
[7839] | 52 | /** @param collision: returns the Collision object back to the cache list */ |
---|
| 53 | inline void putCollisionObject(Collision* collision) { this->cachedCollisions.push_back(collision); } |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | private: |
---|
[7865] | 57 | CREngine(void); |
---|
[7839] | 58 | |
---|
[7865] | 59 | private: |
---|
[7839] | 60 | std::vector<CollisionHandle*> collisionHandles; //!< list with the collision handles |
---|
| 61 | std::vector<Collision*> cachedCollisions; //!< a list of unused, cached collision events |
---|
[7865] | 62 | std::vector<int> targetList; |
---|
| 63 | |
---|
[7843] | 64 | static CREngine* singletonRef; //!< the reference to the CREngine object (singleton) |
---|
[7819] | 65 | }; |
---|
| 66 | |
---|
| 67 | #endif /* _CR_ENGINE_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.