[7841] | 1 | /*! |
---|
| 2 | * @file collision_handle.h |
---|
| 3 | * @brief Definition of a collision handle: used for accesing per world entity collision events and reactions |
---|
| 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> |
---|
[7989] | 13 | #include <list> |
---|
[7927] | 14 | |
---|
| 15 | |
---|
[7841] | 16 | class Collision; |
---|
[7927] | 17 | class WorldEntity; |
---|
[7841] | 18 | |
---|
[7927] | 19 | |
---|
| 20 | |
---|
[7841] | 21 | //! A class for defining collision reactions and storing events |
---|
[7945] | 22 | class CollisionHandle : public BaseObject |
---|
| 23 | { |
---|
[7841] | 24 | |
---|
[7945] | 25 | public: |
---|
| 26 | CollisionHandle(WorldEntity* owner, CREngine::CRType type); |
---|
| 27 | virtual ~CollisionHandle(); |
---|
[7841] | 28 | |
---|
[7946] | 29 | void reset(); |
---|
[7927] | 30 | |
---|
[7989] | 31 | void addTarget(long target); |
---|
[7967] | 32 | Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB); |
---|
[8106] | 33 | void registerSharedCollision(Collision* collision); |
---|
[7964] | 34 | void registerCollisionEvent(CollisionEvent* collisionEvent); |
---|
[8029] | 35 | |
---|
[7947] | 36 | /** @returns true if regiestered some new collision events in this tick frame */ |
---|
| 37 | inline bool isCollided() const { return this->bCollided; } |
---|
[8029] | 38 | /** @returns true if this collision handle has already been dispatched */ |
---|
| 39 | inline bool isDispatched() const { return this->bDispatched; } |
---|
[8043] | 40 | /** @returns true if this handle should be pulled also if there are no collisions */ |
---|
| 41 | inline bool isContinuousPoll() const { return this->bContinuousPoll; } |
---|
[7841] | 42 | |
---|
[7945] | 43 | void handleCollisions(); |
---|
[7841] | 44 | |
---|
| 45 | |
---|
[7945] | 46 | private: |
---|
| 47 | void flushCollisions(); |
---|
[8109] | 48 | bool filterCollisionEvent(CollisionEvent* collisionEvent); |
---|
[7841] | 49 | |
---|
| 50 | |
---|
[7945] | 51 | private: |
---|
| 52 | WorldEntity* owner; //!< the worldenity this reaction will be applied on |
---|
| 53 | CREngine::CRType type; //!< the reaction type |
---|
[7841] | 54 | |
---|
[8043] | 55 | bool bContinuousPoll; //!< if this is true |
---|
[7945] | 56 | bool bDispatched; //!< true if this handle has already been dispatched |
---|
| 57 | bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match |
---|
[7947] | 58 | bool bCollided; //!< true if the CollsionHandle has registered some new collisions |
---|
[7945] | 59 | |
---|
| 60 | std::vector<Collision*> collisionList; //!< a list full of collisions |
---|
| 61 | std::vector<long> targetList; //!< a list of target classes for filtering |
---|
| 62 | |
---|
[7841] | 63 | }; |
---|
| 64 | |
---|
| 65 | #endif /* _COLLISION_HANDLE_H */ |
---|