30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <object/components/component.hpp>
|
|
#include <state/gamestate.hpp>
|
|
|
|
namespace Game::Object::Components {
|
|
struct BoxColliderBounds {
|
|
float left, right, top, bottom;
|
|
};
|
|
|
|
class BoxCollider : public Component {
|
|
public:
|
|
BoxCollider() = default;
|
|
BoxCollider(const BoxCollider&);
|
|
BoxCollider& operator=(const BoxCollider&);
|
|
BoxCollider(BoxCollider&&) noexcept;
|
|
BoxCollider& operator=(BoxCollider&&) noexcept;
|
|
~BoxCollider() override;
|
|
|
|
void start(Object::Entity* thisEntity) override;
|
|
void update(float deltaTime, Object::Entity* thisEntity) override;
|
|
|
|
BoxColliderBounds getBounds() const { return mBounds; }
|
|
bool isColliding() const { return mIsColliding; }
|
|
|
|
private:
|
|
BoxColliderBounds mBounds;
|
|
bool mIsColliding = false; // Whether this collider is currently colliding with another collider; used to determine whether to call onCollisionEnter vs onCollisionStay, and to call onCollisionExit when collisions end
|
|
};
|
|
} |