/*! * @file collision_handle.h * @brief Definition of a collision handle: used for accesing per world entity collision events and reactions */ #ifndef _COLLISION_HANDLE_H #define _COLLISION_HANDLE_H #include "base_object.h" #include "cr_engine.h" #include #include class Collision; class WorldEntity; class CollisionReaction; //! A class for defining collision reactions and storing events class CollisionHandle : public BaseObject { public: CollisionHandle(WorldEntity* owner, CREngine::CRType type); virtual ~CollisionHandle(); void reset(); void addTarget(long target); Collision* registerCollision(WorldEntity* entityA, WorldEntity* entityB); void registerSharedCollision(Collision* collision); void registerCollisionEvent(CollisionEvent* collisionEvent); /** @returns true if regiestered some new collision events in this tick frame */ inline bool isCollided() const { return this->bCollided; } /** @returns true if this collision handle has already been dispatched */ inline bool isDispatched() const { return this->bDispatched; } /** @returns true if this handle should be pulled also if there are no collisions */ inline bool isContinuousPoll() const { return this->bContinuousPoll; } /** @returns the type */ inline CREngine::CRType getType() const { return this->type; } void handleCollisions(); private: void flushCollisions(); bool filterCollisionEvent(CollisionEvent* collisionEvent); bool filterCollision(Collision* collision); private: WorldEntity* owner; //!< the worldenity this reaction will be applied on CREngine::CRType type; //!< the reaction type bool bContinuousPoll; //!< if this is true bool bDispatched; //!< true if this handle has already been dispatched bool bStopOnFirstCollision; //!< true if the cd of this object should be terminated after one match bool bCollided; //!< true if the CollsionHandle has registered some new collisions std::vector collisionList; //!< a list full of collisions std::vector targetList; //!< a list of target classes for filtering CollisionReaction* collisionReaction; //!< reference to the collision reaction object }; #endif /* _COLLISION_HANDLE_H */