[7841] | 1 | /*! |
---|
| 2 | * @file collision_handle.h |
---|
[9888] | 3 | * @brief Definition of a collision handle: used for accessing per world entity collision events and reactions |
---|
[7841] | 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _COLLISION_HANDLE_H |
---|
| 7 | #define _COLLISION_HANDLE_H |
---|
| 8 | |
---|
| 9 | #include "base_object.h" |
---|
[7927] | 10 | #include "cr_engine.h" |
---|
[7841] | 11 | |
---|
[7927] | 12 | #include <vector> |
---|
[8190] | 13 | #include <list> |
---|
[7927] | 14 | |
---|
| 15 | |
---|
[7841] | 16 | class Collision; |
---|
[7927] | 17 | class WorldEntity; |
---|
[7841] | 18 | |
---|
[9889] | 19 | namespace CoRe |
---|
| 20 | { |
---|
[7927] | 21 | |
---|
[9889] | 22 | class CollisionReaction; |
---|
[7927] | 23 | |
---|
[9889] | 24 | |
---|
| 25 | |
---|
| 26 | //! A class for defining collision reactions and storing events |
---|
| 27 | class CollisionHandle : public BaseObject |
---|
| 28 | { |
---|
| 29 | ObjectListDeclaration(CollisionHandle); |
---|
[9890] | 30 | |
---|
[8190] | 31 | public: |
---|
| 32 | CollisionHandle(WorldEntity* owner, CREngine::CRType type); |
---|
| 33 | virtual ~CollisionHandle(); |
---|
[7841] | 34 | |
---|
[8190] | 35 | void reset(); |
---|
[7927] | 36 | |
---|
[9869] | 37 | void addTarget(const ClassID& target); |
---|
[8190] | 38 | Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB); |
---|
| 39 | void registerSharedCollision(Collision* collision); |
---|
| 40 | void registerCollisionEvent(CollisionEvent* collisionEvent); |
---|
[7927] | 41 | |
---|
[8190] | 42 | /** @returns true if regiestered some new collision events in this tick frame */ |
---|
| 43 | inline bool isCollided() const { return this->bCollided; } |
---|
| 44 | /** @returns true if this collision handle has already been dispatched */ |
---|
| 45 | inline bool isDispatched() const { return this->bDispatched; } |
---|
| 46 | /** @returns true if this handle should be pulled also if there are no collisions */ |
---|
| 47 | inline bool isContinuousPoll() const { return this->bContinuousPoll; } |
---|
[8490] | 48 | /** @returns the type */ |
---|
| 49 | inline CREngine::CRType getType() const { return this->type; } |
---|
[7841] | 50 | |
---|
[8190] | 51 | void handleCollisions(); |
---|
[7841] | 52 | |
---|
| 53 | |
---|
[8190] | 54 | private: |
---|
| 55 | void flushCollisions(); |
---|
| 56 | bool filterCollisionEvent(CollisionEvent* collisionEvent); |
---|
| 57 | bool filterCollision(Collision* collision); |
---|
[7841] | 58 | |
---|
| 59 | |
---|
| 60 | |
---|
[8190] | 61 | private: |
---|
| 62 | WorldEntity* owner; //!< the worldenity this reaction will be applied on |
---|
| 63 | CREngine::CRType type; //!< the reaction type |
---|
| 64 | |
---|
| 65 | bool bContinuousPoll; //!< if this is true |
---|
| 66 | bool bDispatched; //!< true if this handle has already been dispatched |
---|
| 67 | bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match |
---|
| 68 | bool bCollided; //!< true if the CollsionHandle has registered some new collisions |
---|
| 69 | |
---|
| 70 | std::vector<Collision*> collisionList; //!< a list full of collisions |
---|
[9869] | 71 | std::vector<ClassID> targetList; //!< a list of target classes for filtering @TODO TAKE SET INSTEAD OF VECTOR HERE |
---|
[8190] | 72 | |
---|
| 73 | CollisionReaction* collisionReaction; //!< reference to the collision reaction object |
---|
| 74 | |
---|
[9889] | 75 | }; |
---|
[7841] | 76 | |
---|
[9889] | 77 | } |
---|
[7841] | 78 | #endif /* _COLLISION_HANDLE_H */ |
---|