diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 5bcd28fe..9f352ac4 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -1,4 +1,4 @@ -name: Linux Build epi env +name: Linux Build (Epitech Container) on: [push, pull_request] jobs: diff --git a/.github/workflows/build.yml b/.github/workflows/build_windows.yml similarity index 98% rename from .github/workflows/build.yml rename to .github/workflows/build_windows.yml index beea1b7f..a3a21944 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_windows.yml @@ -1,4 +1,4 @@ -name: Build +name: Windows Build on: [push, pull_request] jobs: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f24a0564..e87b9b9d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests +name: Unit Tests on: [push, pull_request] jobs: diff --git a/CMakeLists.txt b/CMakeLists.txt index 86be286d..6beac4e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,12 +20,12 @@ set(SOURCES sources/Component/Movable/MovableComponent.hpp sources/Component/Controllable/ControllableComponent.hpp sources/Component/Controllable/ControllableComponent.cpp + sources/Component/BombHolder/BombHolderComponent.cpp + sources/Component/BombHolder/BombHolderComponent.hpp sources/Component/Gamepad/GamepadComponent.cpp sources/Component/Gamepad/GamepadComponent.hpp sources/Component/Keyboard/KeyboardComponent.cpp sources/Component/Keyboard/KeyboardComponent.hpp - sources/Component/BombHolder/BombHolderComponent.cpp - sources/Component/BombHolder/BombHolderComponent.hpp sources/Component/Health/HealthComponent.cpp sources/Component/Health/HealthComponent.hpp sources/System/Movable/MovableSystem.hpp @@ -62,7 +62,9 @@ set(SOURCES sources/Component/Timer/TimerComponent.hpp sources/System/Timer/TimerSystem.cpp sources/System/Timer/TimerSystem.hpp - sources/System/Event/EventSystem.cpp sources/System/Event/EventSystem.hpp) + sources/System/Event/EventSystem.cpp + sources/System/Event/EventSystem.hpp +) add_executable(bomberman sources/main.cpp diff --git a/README.md b/README.md index 7f81836d..18e93e7a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ A recreation of the classic Bomberman arcade game +[![Linux Build (Epitech Container)](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/build_linux.yml/badge.svg)](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/build_linux.yml) +[![Windows Build](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/build_windows.yml/badge.svg)](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/build_windows.yml) +[![Web Building](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/webassembly.yml/badge.svg)](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/webassembly.yml) +[![Unit Tests](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/test.yml/badge.svg)](https://github.com/AnonymusRaccoon/Bomberman/actions/workflows/test.yml) + Repository link: https://github.com/AnonymusRaccoon/Bomberman/ ## Demo @@ -31,7 +36,10 @@ cd Bomberman Create `build` dir and compile using CMake ```bash -mkdir build && cd build && cmake .. && make +mkdir build +cd build +cmake .. +cmake --build . ``` Enjoy ! @@ -65,4 +73,4 @@ Please adhere to this project's `code of conduct`. - [Arthur Jamet](https://github.com/Arthi-chaud "Arthi-Chaud") - [Louis Auzuret](https://github.com/GitBluub "Bluub") - [Benjamin Henry](https://github.com/EternalRat "EternalRat") -- [Tom Augier](https://github.com/TrueBabyChaise "TrueBabyChaise") \ No newline at end of file +- [Tom Augier](https://github.com/TrueBabyChaise "TrueBabyChaise") diff --git a/lib/Ray/sources/Drawables/2D/Circle.cpp b/lib/Ray/sources/Drawables/2D/Circle.cpp index c1b5b3cc..cdb63a38 100644 --- a/lib/Ray/sources/Drawables/2D/Circle.cpp +++ b/lib/Ray/sources/Drawables/2D/Circle.cpp @@ -6,6 +6,7 @@ */ #include "Drawables/2D/Circle.hpp" +#include "Drawables/Image.hpp" namespace RAY::Drawables::Drawables2D { diff --git a/lib/Ray/sources/Drawables/2D/Line.cpp b/lib/Ray/sources/Drawables/2D/Line.cpp index 2425ac47..f412236b 100644 --- a/lib/Ray/sources/Drawables/2D/Line.cpp +++ b/lib/Ray/sources/Drawables/2D/Line.cpp @@ -7,6 +7,7 @@ #include "Drawables/2D/Line.hpp" #include +#include "Drawables/Image.hpp" namespace RAY::Drawables::Drawables2D { diff --git a/lib/Ray/sources/Drawables/2D/Point.cpp b/lib/Ray/sources/Drawables/2D/Point.cpp index 34f9f5f7..6118840d 100644 --- a/lib/Ray/sources/Drawables/2D/Point.cpp +++ b/lib/Ray/sources/Drawables/2D/Point.cpp @@ -6,6 +6,7 @@ */ #include "Drawables/2D/Point.hpp" +#include "Drawables/Image.hpp" namespace RAY::Drawables::Drawables2D { diff --git a/lib/Ray/sources/Drawables/2D/Rectangle.cpp b/lib/Ray/sources/Drawables/2D/Rectangle.cpp index 86a1242d..9f623bee 100644 --- a/lib/Ray/sources/Drawables/2D/Rectangle.cpp +++ b/lib/Ray/sources/Drawables/2D/Rectangle.cpp @@ -7,6 +7,7 @@ #include "Drawables/2D/Rectangle.hpp" #include +#include "Drawables/Image.hpp" namespace RAY::Drawables::Drawables2D { @@ -48,4 +49,15 @@ namespace RAY::Drawables::Drawables2D { ImageDrawRectangleV(image, this->_position, this->_dimensions, this->_color); } + + Rectangle::operator ::Rectangle() const + { + ::Rectangle rect; + + rect.x = this->_position.x; + rect.y = this->_position.y; + rect.width = this->_dimensions.x; + rect.height = this->_dimensions.y; + return rect; + } } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/2D/Rectangle.hpp b/lib/Ray/sources/Drawables/2D/Rectangle.hpp index 18f25d4f..e0d32dff 100644 --- a/lib/Ray/sources/Drawables/2D/Rectangle.hpp +++ b/lib/Ray/sources/Drawables/2D/Rectangle.hpp @@ -20,7 +20,7 @@ namespace RAY::Drawables::Drawables2D { //! @param position position of top-left point //! @param dimensions dimensions of the rectangle //! @param Color Color of the rectangle - Rectangle(const Vector2 &position, const Vector2 &dimensions, const Color &color); + Rectangle(const Vector2 &position, const Vector2 &dimensions, const Color &color = WHITE); //! @brief Rectangle constructor //! @param x x-position of top-left point @@ -28,7 +28,7 @@ namespace RAY::Drawables::Drawables2D { //! @param width width of the rectangle //! @param length length of the rectangle //! @param Color Color of the rectangle - Rectangle(int x, int y, int width, int height, const Color &color); + Rectangle(int x, int y, int width, int height, const Color &color = WHITE); //! @brief A default copy constructor Rectangle(const Rectangle &) = default; @@ -37,7 +37,7 @@ namespace RAY::Drawables::Drawables2D { Rectangle &operator=(const Rectangle &) = default; //! @brief A default destructor - ~Rectangle() override = default; + virtual ~Rectangle() override = default; //! @return the dimensions of the rectangle const Vector2 &getDimensions(void); @@ -49,13 +49,16 @@ namespace RAY::Drawables::Drawables2D { Rectangle &setDimensions(int x, int y); //! @brief Draw point on window - void drawOn(RAY::Window &) override; + virtual void drawOn(RAY::Window &) override; //! @brief Draw point on image - void drawOn(RAY::Image &image) override; + virtual void drawOn(RAY::Image &image) override; - private: + protected: //! @brief Diemnsions of the rectangle Vector2 _dimensions; + + INTERNAL: + operator ::Rectangle() const; }; }; diff --git a/lib/Ray/sources/Drawables/2D/Text.cpp b/lib/Ray/sources/Drawables/2D/Text.cpp index 9c679034..327d8fd1 100644 --- a/lib/Ray/sources/Drawables/2D/Text.cpp +++ b/lib/Ray/sources/Drawables/2D/Text.cpp @@ -6,7 +6,7 @@ */ #include "Drawables/2D/Text.hpp" - +#include "Drawables/Image.hpp" #include namespace RAY::Drawables::Drawables2D diff --git a/lib/Ray/sources/Drawables/2D/Triangle.cpp b/lib/Ray/sources/Drawables/2D/Triangle.cpp index 4e90d58c..2a4e6a56 100644 --- a/lib/Ray/sources/Drawables/2D/Triangle.cpp +++ b/lib/Ray/sources/Drawables/2D/Triangle.cpp @@ -7,6 +7,7 @@ #include "Drawables/2D/Triangle.hpp" #include "Exceptions/RayError.hpp" +#include "Drawables/Image.hpp" namespace RAY::Drawables::Drawables2D { diff --git a/lib/Ray/sources/Drawables/ADrawable2D.cpp b/lib/Ray/sources/Drawables/ADrawable2D.cpp index af031e36..0dd9804a 100644 --- a/lib/Ray/sources/Drawables/ADrawable2D.cpp +++ b/lib/Ray/sources/Drawables/ADrawable2D.cpp @@ -6,6 +6,7 @@ */ #include "Drawables/ADrawable2D.hpp" +#include "Image.hpp" namespace RAY::Drawables { diff --git a/lib/Ray/sources/Drawables/ADrawable2D.hpp b/lib/Ray/sources/Drawables/ADrawable2D.hpp index 46a9407b..f2364539 100644 --- a/lib/Ray/sources/Drawables/ADrawable2D.hpp +++ b/lib/Ray/sources/Drawables/ADrawable2D.hpp @@ -10,10 +10,12 @@ #include #include "Vector/Vector2.hpp" -#include "Image.hpp" #include "Drawables/IDrawable.hpp" #include "Color.hpp" +namespace RAY { + class Image; +} namespace RAY::Drawables { //! @brief Abstraction of any two-dimensionnal drawable class ADrawable2D: public IDrawable diff --git a/lib/Ray/sources/Drawables/Image.cpp b/lib/Ray/sources/Drawables/Image.cpp index 0145e642..d7c357df 100644 --- a/lib/Ray/sources/Drawables/Image.cpp +++ b/lib/Ray/sources/Drawables/Image.cpp @@ -6,36 +6,68 @@ */ #include "Drawables/Image.hpp" -#include "Drawables/IDrawable.hpp" +#include "Drawables/ADrawable2D.hpp" +#include "Drawables/2D/Rectangle.hpp" -RAY::Image::Image(const std::string &filename): - _image(LoadImage(filename.c_str())) -{ -} +namespace RAY { + std::unordered_map> Image::_ImageCache; -RAY::Image::Image(RAY::Texture &texture): - _image(GetTextureData(texture)) -{ + Image::Image(const std::string &filename): + Rectangle(Vector2(0, 0), Vector2(0, 0), WHITE), + _image(fetchImageInCache(filename)) + { + this->_dimensions = Vector2(this->_image->width, this->_image->height); + } -} + bool Image::exportTo(const std::string &outputPath) + { + ExportImage(*this->_image, outputPath.c_str()); + return true; + } -RAY::Image::~Image() -{ - UnloadImage(_image); -} + Image::operator ::Image() const + { + return *this->_image; + } -bool RAY::Image::exportTo(const std::string &outputPath) -{ - ExportImage(_image, outputPath.c_str()); - return true; -} + Image::operator ::Image *() + { + return this->_image.get(); + } -RAY::Image::operator ::Image() const -{ - return _image; -} + std::shared_ptr<::Image> Image::fetchImageInCache(const std::string &path) + { + if (Image::_ImageCache.find(path) == Image::_ImageCache.end()) + Image::_ImageCache.emplace(path, std::shared_ptr<::Image>( + new ::Image(LoadImage(path.c_str())), [](::Image *p) { + UnloadImage(*p); + delete p; + })); + return _ImageCache[path]; + } -RAY::Image::operator ::Image *() -{ - return &this->_image; + void Image::draw(Drawables::ADrawable2D &drawable) + { + drawable.drawOn(*this); + } + + void Image::drawOn(RAY::Window &) + { + //Since the image is a shared object, when it is resized, it mush be resized after to its previous dimensions + Vector2 oldDims = Vector2(this->_image->width, this->_image->height); + + ImageResize(*this, this->_dimensions.x, this->_dimensions.y); + Texture texture(*this); + + DrawTexture(texture, this->_position.x, this->_position.y, this->_color); + ImageResize(*this, oldDims.x, oldDims.y); + } + + void Image::drawOn(RAY::Image &image) + { + Drawables::Drawables2D::Rectangle dest(this->_position, this->getDimensions()); + Drawables::Drawables2D::Rectangle src(Vector2(0, 0), this->getDimensions()); + + ImageDraw(image, *this, dest, src, this->_color); + } } \ No newline at end of file diff --git a/lib/Ray/sources/Drawables/Image.hpp b/lib/Ray/sources/Drawables/Image.hpp index ac802580..6f6355bf 100644 --- a/lib/Ray/sources/Drawables/Image.hpp +++ b/lib/Ray/sources/Drawables/Image.hpp @@ -11,43 +11,50 @@ #include #include #include "Texture.hpp" +#include +#include +#include "Drawables/2D/Rectangle.hpp" namespace RAY { - namespace Drawables { - class ADrawable2D; - } //! @brief Object representation of a framebuffer - class Image { + class Image: public Drawables::Drawables2D::Rectangle { public: //! @brief Create an image, loading a file //! @param filename: path to file to load Image(const std::string &filename); - //! @brief Create an image, using data from a texure - //! @param texture: texture to extract data from - Image(Texture &texture); - //! @brief A default copy constructor - Image(const Image &image) = delete; + Image(const Image &image) = default; //! @brief An image is assignable - Image &operator=(const Image &image) = delete; + Image &operator=(const Image &image) = default; //! @brief Image destructor, will unload ressources - ~Image(); + ~Image() override = default; //! @brief export to file //! @param outputPath: path of output bool exportTo(const std::string &outputPath); - - //! @brief draw drawable + //! @brief draw drawable on image void draw(Drawables::ADrawable2D &); + //! @brief Draw image on window + void drawOn(RAY::Window &) override; + + //! @brief Draw image on another image + void drawOn(RAY::Image &image) override; + + private: //! @brief Image, really, that's just it... - ::Image _image; + std::shared_ptr<::Image> _image; + //! @brief, look through cache to see if a model using same file + std::shared_ptr<::Image>fetchImageInCache(const std::string &path); + + static std::unordered_map> _ImageCache; + INTERNAL: //! @brief get image diff --git a/lib/Ray/sources/Drawables/Texture.cpp b/lib/Ray/sources/Drawables/Texture.cpp index a92e1349..b2691a23 100644 --- a/lib/Ray/sources/Drawables/Texture.cpp +++ b/lib/Ray/sources/Drawables/Texture.cpp @@ -21,6 +21,12 @@ namespace RAY { { } + Texture::Texture(const Image &image): + _texture(LoadTextureFromImage(image)), + _resourcePath() + { + } + Texture &Texture::operator=(const Texture &other) { diff --git a/lib/Ray/sources/Drawables/Texture.hpp b/lib/Ray/sources/Drawables/Texture.hpp index a2054b1a..e087275d 100644 --- a/lib/Ray/sources/Drawables/Texture.hpp +++ b/lib/Ray/sources/Drawables/Texture.hpp @@ -20,10 +20,13 @@ namespace RAY //! @param filename: path to file to load Texture(const std::string &filename); - //! @brief A texture is not copy constructable + //! @brief A texture is copy constructable Texture(const Texture &); - //! @brief An image is assignable + //! @brief A textrue can be loaded from an image + Texture(const Image &); + + //! @brief An texture is assignable Texture &operator=(const Texture &); //! @brief Texture destructor, will unload ressources diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index cb4cd024..8554a40c 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -7,9 +7,12 @@ #include "Model/Model.hpp" #include "Exceptions/RayError.hpp" +#include + namespace RAY::Drawables::Drawables3D { + std::unordered_map> Model::_modelsCache; Model::Model(const std::string &filename, std::optional> texture, const RAY::Vector3 &position, @@ -17,7 +20,7 @@ namespace RAY::Drawables::Drawables3D { float rotationAngle, const RAY::Vector3 &scale) : ADrawable3D(position, WHITE), - _model(LoadModel(filename.c_str())), + _model(fetchModelInCache(filename)), _rotationAxis(rotationAxis), _rotationAngle(rotationAngle), _scale(scale) @@ -27,33 +30,29 @@ namespace RAY::Drawables::Drawables3D { } Model::Model(const Mesh &mesh) - : ADrawable3D({0, 0, 0}, WHITE), _model(LoadModelFromMesh(mesh)) + : ADrawable3D({0, 0, 0}, WHITE), + _model(std::make_shared<::Model>(LoadModelFromMesh(mesh))) { } - Model::~Model() - { - UnloadModel(this->_model); - } - bool Model::unloadKeepMeshes() { - UnloadModelKeepMeshes(_model); + UnloadModelKeepMeshes(*this->_model); return true; } bool Model::setAnimation(const RAY::ModelAnimation &animation) { - if (!IsModelAnimationValid(this->_model, animation)) + if (!IsModelAnimationValid(*this->_model, animation)) throw RAY::Exception::NotCompatibleError("The animation is not compatible with the model"); - UpdateModelAnimation(this->_model, animation, animation.getFrameCounter()); + UpdateModelAnimation(*this->_model, animation, animation.getFrameCounter()); return true; } bool Model::setTextureToMaterial(Model::MaterialType materialType, const std::string &texturePath) { this->_textureList.emplace(materialType, texturePath); - SetMaterialTexture(&this->_model.materials[materialType], + SetMaterialTexture(&this->_model->materials[materialType], materialType, this->_textureList.at(materialType)); return true; @@ -61,12 +60,12 @@ namespace RAY::Drawables::Drawables3D { Model::operator ::Model() const { - return this->_model; + return *this->_model; } int Model::getBoneCount() const { - return this->_model.boneCount; + return this->_model->boneCount; } Model &Model::setRotationAngle(float rotationAngle) @@ -104,6 +103,17 @@ namespace RAY::Drawables::Drawables3D { void Model::drawOn(RAY::Window &) { - DrawModelEx(this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color); + DrawModelEx(*this->_model, this->_position, this->_rotationAxis, this->_rotationAngle, this->_scale, this->_color); + } + + std::shared_ptr<::Model> Model::fetchModelInCache(const std::string &path) + { + if (Model::_modelsCache.find(path) == Model::_modelsCache.end()) + Model::_modelsCache.emplace(path, std::shared_ptr<::Model>( + new ::Model(LoadModel(path.c_str())), [](::Model *p) { + UnloadModel(*p); + delete p; + })); + return _modelsCache[path]; } } \ No newline at end of file diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index 039304ae..47689edb 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -14,7 +14,8 @@ #include #include #include -#include +#include +#include namespace RAY::Drawables::Drawables3D { //! @brief Basic 3D Model type @@ -42,8 +43,8 @@ namespace RAY::Drawables::Drawables3D { //! @brief A model is assignable Model& operator=(const Model &model) = default; - //! @brief Model destructor, unloads all related data - ~Model(); + //! @brief Model destructor, model's data will be deleted if it's the last entity alive + ~Model() override = default; //! @brief Unload model (excluding meshes) from memory (RAM and/or VRAM) bool unloadKeepMeshes(); @@ -81,15 +82,19 @@ namespace RAY::Drawables::Drawables3D { private: //! @brief Raw data from raylib - ::Model _model; + std::shared_ptr<::Model> _model; //! @brief The list of textures that can be applied to this model. - std::map _textureList; + std::unordered_map _textureList; //! @brief Rotation property RAY::Vector3 _rotationAxis; //! @brief Rotation property float _rotationAngle; //! @brief Scale of the shape RAY::Vector3 _scale; + //! @brief, look through cache to see if a model using same file + std::shared_ptr<::Model>fetchModelInCache(const std::string &path); + + static std::unordered_map> _modelsCache; INTERNAL: //! @brief A RAY Model is cast-able in libray's model diff --git a/lib/Ray/sources/Window.cpp b/lib/Ray/sources/Window.cpp index 11b14486..11acdab7 100644 --- a/lib/Ray/sources/Window.cpp +++ b/lib/Ray/sources/Window.cpp @@ -11,6 +11,7 @@ #include "Controllers/Mouse.hpp" #include "Drawables/ADrawable2D.hpp" #include "Drawables/ADrawable3D.hpp" +#include "Drawables/Image.hpp" std::optional RAY::Window::_instance = std::nullopt; diff --git a/lib/Ray/sources/Window.hpp b/lib/Ray/sources/Window.hpp index b04f60d8..94c2ad80 100644 --- a/lib/Ray/sources/Window.hpp +++ b/lib/Ray/sources/Window.hpp @@ -11,7 +11,6 @@ #include #include #include -#include "Drawables/Image.hpp" #include "Vector/Vector2.hpp" #include "Vector/Vector3.hpp" #include "Controllers/Keyboard.hpp" @@ -22,6 +21,7 @@ namespace RAY { //! @brief Window manager + class Image; namespace Drawables { class IDrawable; class ADrawable3D; diff --git a/sources/Component/Health/HealthComponent.hpp b/sources/Component/Health/HealthComponent.hpp index a7c72c7f..2eadafc5 100644 --- a/sources/Component/Health/HealthComponent.hpp +++ b/sources/Component/Health/HealthComponent.hpp @@ -6,6 +6,7 @@ #pragma once +#include #include "Component/Component.hpp" #include "Entity/Entity.hpp" @@ -19,6 +20,9 @@ namespace BBM unsigned int _healthPoint; public: + //! @brief The callback invoked on this entity's death. + WAL::Callback onDeath; + //! @brief add health to the entity void addHealthPoint(unsigned int healthPoint); diff --git a/sources/Component/Timer/TimerComponent.cpp b/sources/Component/Timer/TimerComponent.cpp index 7845df9d..020601d9 100644 --- a/sources/Component/Timer/TimerComponent.cpp +++ b/sources/Component/Timer/TimerComponent.cpp @@ -13,13 +13,13 @@ namespace BBM ringIn(delay) {} - TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, const WAL::Callback &callback) + TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, const WAL::Callback &callback) : WAL::Component(entity), ringIn(delay), callback(callback) {} - TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, std::function callback) + TimerComponent::TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, std::function callback) : WAL::Component(entity), ringIn(delay), callback(std::move(callback)) diff --git a/sources/Component/Timer/TimerComponent.hpp b/sources/Component/Timer/TimerComponent.hpp index 513ccb71..222a69b9 100644 --- a/sources/Component/Timer/TimerComponent.hpp +++ b/sources/Component/Timer/TimerComponent.hpp @@ -25,9 +25,9 @@ namespace BBM //! @brief A default constructor TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay); //! @brief Create a timer with a callback. - TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, const WAL::Callback &callback); + TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, const WAL::Callback &callback); //! @brief Create a timer with a function to call on ring. - TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, std::function callback); + TimerComponent(WAL::Entity &entity, std::chrono::nanoseconds delay, std::function callback); //! @brief A timer component is copy constructable TimerComponent(const TimerComponent &) = default; //! @brief A default destructor diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index eb531502..b31250d8 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -48,7 +48,7 @@ namespace BBM { wal.addSystem(wal) .addSystem() - .addSystem() + .addSystem() .addSystem() .addSystem(wal) .addSystem() diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index a3ecee88..90bbfbb9 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -20,7 +20,7 @@ namespace BBM { auto &health = entity.getComponent(); - if (health.getHealthPoint() == 0); - entity.setDisable(true); + if (health.getHealthPoint() == 0) + health.onDeath(entity); } } \ No newline at end of file