Last change
on this file since 8044 was
7927,
checked in by patrick, 18 years ago
|
trunk: added more cr framework, i will branche soon with this stuff so the trunk dosn't get involved to much in the development phase
|
File size:
1.8 KB
|
Line | |
---|
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" |
---|
10 | #include <stdarg.h> |
---|
11 | #include <vector> |
---|
12 | |
---|
13 | // FORWARD DECLARATION |
---|
14 | class CollisionHandle; |
---|
15 | class Collision; |
---|
16 | class WorldEntity; |
---|
17 | |
---|
18 | //! A default singleton class. |
---|
19 | class CREngine : public BaseObject |
---|
20 | { |
---|
21 | |
---|
22 | public: |
---|
23 | typedef enum CRType { |
---|
24 | CR_PHYSICS_MOMENTUM = 0, |
---|
25 | CR_PHYSICS_GROUND, |
---|
26 | CR_PHYSICS_GROUND_WALK, |
---|
27 | |
---|
28 | CR_OBJECT_DAMAGE, |
---|
29 | CR_OBJECT_PICKUP, |
---|
30 | |
---|
31 | CR_VERTEX_TRAFO, |
---|
32 | |
---|
33 | CR_SPECIAL_CALLBACK, |
---|
34 | |
---|
35 | CR_NUMBER |
---|
36 | }; |
---|
37 | |
---|
38 | virtual ~CREngine(void); |
---|
39 | |
---|
40 | /** @returns a Pointer to the only object of this Class */ |
---|
41 | inline static CREngine* getInstance(void) { if (!singletonRef) singletonRef = new CREngine(); return singletonRef; }; |
---|
42 | |
---|
43 | |
---|
44 | CollisionHandle* subscribeReaction(WorldEntity* worldEntity, CRType type, int nrOfTargets, ...); |
---|
45 | |
---|
46 | bool unsubscribeReaction(WorldEntity* worldEntity); |
---|
47 | bool unsubscribeReaction(CollisionHandle* collisionHandle); |
---|
48 | |
---|
49 | |
---|
50 | void handleCollisions(); |
---|
51 | |
---|
52 | /** @returns an instance to a collision object. instead of creating new object this ones can be resycled */ |
---|
53 | inline Collision* getCollisionObject() { /* return the first element of the cache list*/ } |
---|
54 | /** @param collision: returns the Collision object back to the cache list */ |
---|
55 | inline void putCollisionObject(Collision* collision) { this->cachedCollisions.push_back(collision); } |
---|
56 | |
---|
57 | |
---|
58 | private: |
---|
59 | CREngine(void); |
---|
60 | |
---|
61 | |
---|
62 | private: |
---|
63 | std::vector<CollisionHandle*> collisionHandles; //!< list with the collision handles |
---|
64 | std::vector<Collision*> cachedCollisions; //!< a list of unused, cached collision events |
---|
65 | |
---|
66 | static CREngine* singletonRef; //!< the reference to the CREngine object (singleton) |
---|
67 | }; |
---|
68 | |
---|
69 | #endif /* _CR_ENGINE_ */ |
---|
Note: See
TracBrowser
for help on using the repository browser.