mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 08:33:36 +00:00
code style fix
This commit is contained in:
@@ -4,31 +4,48 @@
|
||||
|
||||
#include "Component/Collision/CollisionComponent.hpp"
|
||||
|
||||
|
||||
namespace BBM
|
||||
namespace BBM
|
||||
{
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity)
|
||||
: WAL::Component(entity)
|
||||
{ }
|
||||
: WAL::Component(entity)
|
||||
{}
|
||||
|
||||
WAL::Component *CollisionComponent::clone(WAL::Entity &entity) const
|
||||
{
|
||||
return new CollisionComponent(entity);
|
||||
}
|
||||
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, Vector3f bound)
|
||||
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound(bound)
|
||||
{ }
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &> &onCollide,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &> &onCollided,
|
||||
Vector3f bound)
|
||||
: WAL::Component(entity),
|
||||
onCollide(onCollide),
|
||||
onCollided(onCollided),
|
||||
bound(bound)
|
||||
{}
|
||||
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, float boundSize)
|
||||
: WAL::Component(entity), onCollide(onCollide), onCollided(onCollided), bound({boundSize, boundSize, boundSize})
|
||||
{ }
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &> &onCollide,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &> &onCollided,
|
||||
float boundSize)
|
||||
: WAL::Component(entity),
|
||||
onCollide(onCollide),
|
||||
onCollided(onCollided),
|
||||
bound({boundSize, boundSize, boundSize})
|
||||
{}
|
||||
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity, Vector3f bound)
|
||||
: WAL::Component(entity), onCollide(), onCollided(), bound(bound)
|
||||
{ }
|
||||
: WAL::Component(entity),
|
||||
onCollide(),
|
||||
onCollided(),
|
||||
bound(bound)
|
||||
{}
|
||||
|
||||
CollisionComponent::CollisionComponent(WAL::Entity &entity, float boundSize)
|
||||
: WAL::Component(entity), onCollide(), onCollided(), bound({boundSize, boundSize, boundSize})
|
||||
{ }
|
||||
: WAL::Component(entity),
|
||||
onCollide(),
|
||||
onCollided(),
|
||||
bound({boundSize, boundSize, boundSize})
|
||||
{}
|
||||
}
|
||||
@@ -9,43 +9,49 @@
|
||||
#include "Component/Component.hpp"
|
||||
#include "Entity/Entity.hpp"
|
||||
|
||||
namespace BBM
|
||||
namespace BBM
|
||||
{
|
||||
class CollisionComponent : public WAL::Component
|
||||
{
|
||||
private:
|
||||
public:
|
||||
//! @brief onCollide functions to be called
|
||||
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide;
|
||||
//! @brief onCollided functions to be called
|
||||
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided;
|
||||
//! @brief Bound size on all axis
|
||||
Vector3f bound;
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
public:
|
||||
//! @brief onCollide functions to be called
|
||||
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide;
|
||||
//! @brief onCollided functions to be called
|
||||
WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided;
|
||||
//! @brief Bound size on all axis
|
||||
Vector3f bound;
|
||||
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
explicit CollisionComponent(WAL::Entity &entity);
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
|
||||
//! @brief Constructor with a WAL::Callback
|
||||
CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided,Vector3f bound);
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
explicit CollisionComponent(WAL::Entity &entity);
|
||||
|
||||
//! @brief Constructor with a WAL::Callback, same boundSize for all axis
|
||||
CollisionComponent(WAL::Entity &entity, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollide, WAL::Callback<WAL::Entity &, const WAL::Entity &> onCollided, float boundSize = 0);
|
||||
//! @brief Constructor with a WAL::Callback
|
||||
CollisionComponent(WAL::Entity &entity,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &>& onCollide,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &>& onCollided,
|
||||
Vector3f bound);
|
||||
|
||||
//! @brief Constructor of collider with no callback
|
||||
CollisionComponent(WAL::Entity &entity, Vector3f bound);
|
||||
//! @brief Constructor with a WAL::Callback, same boundSize for all axis
|
||||
CollisionComponent(WAL::Entity &entity,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &>& onCollide,
|
||||
const WAL::Callback<WAL::Entity &, const WAL::Entity &>& onCollided,
|
||||
float boundSize = 0);
|
||||
|
||||
//! @brief Constructor no callback, same boundSize for all axis
|
||||
CollisionComponent(WAL::Entity &entity, float boundSize);
|
||||
//! @brief Constructor of collider with no callback
|
||||
CollisionComponent(WAL::Entity &entity, Vector3f bound);
|
||||
|
||||
//! @brief Default copy constructor
|
||||
CollisionComponent(const CollisionComponent &) = default;
|
||||
//! @brief Constructor no callback, same boundSize for all axis
|
||||
CollisionComponent(WAL::Entity &entity, float boundSize);
|
||||
|
||||
//! @brief default destructor
|
||||
~CollisionComponent() override = default;
|
||||
//! @brief Default copy constructor
|
||||
CollisionComponent(const CollisionComponent &) = default;
|
||||
|
||||
//! @brief A component can't be assigned
|
||||
CollisionComponent &operator=(const CollisionComponent &) = delete;
|
||||
//! @brief default destructor
|
||||
~CollisionComponent() override = default;
|
||||
|
||||
//! @brief A component can't be assigned
|
||||
CollisionComponent &operator=(const CollisionComponent &) = delete;
|
||||
};
|
||||
}
|
||||
@@ -26,10 +26,10 @@ TEST_CASE("Collision test", "[Component][System]")
|
||||
.addComponent<PositionComponent>()
|
||||
.addComponent<CollisionComponent>([](Entity &actual, const Entity &) {
|
||||
try {
|
||||
auto &pos = actual.getComponent<PositionComponent>();
|
||||
pos.position.x = 1;
|
||||
pos.position.y = 1;
|
||||
pos.position.z = 1;
|
||||
auto &pos = actual.getComponent<PositionComponent>();
|
||||
pos.position.x = 1;
|
||||
pos.position.y = 1;
|
||||
pos.position.z = 1;
|
||||
} catch (std::exception &e) {};
|
||||
}, [](Entity &, const Entity &){}, 5.0);
|
||||
Entity &entity = wal.scene->getEntities().front();
|
||||
|
||||
Reference in New Issue
Block a user