From 80e9d674e9e638ef8f9130bc7fc2eecb54d8aa4d Mon Sep 17 00:00:00 2001 From: TrueBabyChaise Date: Fri, 21 May 2021 15:11:03 +0200 Subject: [PATCH] Fix documentation and remove friend keyword Remove friend keyword and put variables in public instead Fix documentation where the name of the component is not specified Co-Authored-By: Benjamin HENRY <44569175+EternalRat@users.noreply.github.com> --- .../Controllable/ControllableComponent.hpp | 47 ++++++++++--------- sources/Component/Health/HealthComponent.cpp | 4 +- sources/Component/Health/HealthComponent.hpp | 12 ++--- .../Component/Keyboard/KeyboardComponent.hpp | 8 ++-- sources/System/Health/HealthSystem.cpp | 4 +- sources/System/Keyboard/KeyboardSystem.cpp | 18 +++---- 6 files changed, 45 insertions(+), 48 deletions(-) diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp index fdab2cd8..6a410802 100644 --- a/sources/Component/Controllable/ControllableComponent.hpp +++ b/sources/Component/Controllable/ControllableComponent.hpp @@ -11,34 +11,35 @@ namespace BBM { class ControllableComponent : public WAL::Component - { - private: - float _moveX = 0; - float _moveZ = 0; - bool _jump = false; - bool _bomb = false; - bool _pause = false; - public: + { + public: + //! @brief input value for X axe + float moveX = 0; + //! @brief input value for Z axe + float moveZ = 0; + //! @brief input value for jump + bool jump = false; + //! @brief input value for bomb + bool bomb = false; + //! @brief input value for pause + bool pause = false; - //! @inherit - WAL::Component *clone(WAL::Entity &entity) const override; + //! @inherit + WAL::Component *clone(WAL::Entity &entity) const override; - //! @brief A component can't be instantiated, it should be derived. - explicit ControllableComponent(WAL::Entity &entity); + //! @brief A Controllable component can't be instantiated, it should be derived. + explicit ControllableComponent(WAL::Entity &entity); - //! @brief Constructor - ControllableComponent(WAL::Entity &entity, unsigned int maxBombCount); + //! @brief Constructor + ControllableComponent(WAL::Entity &entity, unsigned int maxBombCount); - //! @brief A component can't be instantiated, it should be derived. - ControllableComponent(const ControllableComponent &) = default; + //! @brief A Controllable component can't be instantiated, it should be derived. + ControllableComponent(const ControllableComponent &) = default; - //! @brief default destructor - ~ControllableComponent() override = default; + //! @brief default destructor + ~ControllableComponent() override = default; - //! @brief A component can't be assigned - ControllableComponent &operator=(const ControllableComponent &) = delete; - - friend class KeyboardSystem; - friend class ControllableSystem; + //! @brief A Controllable omponent can't be assigned + ControllableComponent &operator=(const ControllableComponent &) = delete; }; } \ No newline at end of file diff --git a/sources/Component/Health/HealthComponent.cpp b/sources/Component/Health/HealthComponent.cpp index bd3fff53..fe81fabb 100644 --- a/sources/Component/Health/HealthComponent.cpp +++ b/sources/Component/Health/HealthComponent.cpp @@ -36,8 +36,8 @@ namespace BBM this->_healthPoint -= damage; } - void HealthComponent::die(void) + unsigned int HealthComponent::getHealthPoint(void) const { - this->_entity.setDisable(true); + return (this->_healthPoint); } } \ No newline at end of file diff --git a/sources/Component/Health/HealthComponent.hpp b/sources/Component/Health/HealthComponent.hpp index 41a8d920..f484d028 100644 --- a/sources/Component/Health/HealthComponent.hpp +++ b/sources/Component/Health/HealthComponent.hpp @@ -25,27 +25,25 @@ namespace BBM //! @brief reduce health void takeDmg(unsigned int damage); - //! @brief disable the entity - void die(void); + //! @brief return health point of the entity + unsigned int getHealthPoint(void) const; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; - //! @brief A component can't be instantiated, it should be derived. + //! @brief A Health component can't be instantiated, it should be derived. explicit HealthComponent(WAL::Entity &entity); //! @brief Constructor HealthComponent(WAL::Entity &entity, unsigned int healthPoint); - //! @brief A component can't be instantiated, it should be derived. + //! @brief A Health component can't be instantiated, it should be derived. HealthComponent(const HealthComponent &) = default; //! @brief default destructor ~HealthComponent() override = default; - //! @brief A component can't be assigned + //! @brief A Health component can't be assigned HealthComponent &operator=(const HealthComponent &) = delete; - - friend class HealthSystem; }; } \ No newline at end of file diff --git a/sources/Component/Keyboard/KeyboardComponent.hpp b/sources/Component/Keyboard/KeyboardComponent.hpp index dc5c74c0..b522296e 100644 --- a/sources/Component/Keyboard/KeyboardComponent.hpp +++ b/sources/Component/Keyboard/KeyboardComponent.hpp @@ -32,21 +32,19 @@ namespace BBM //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; - //! @brief A component can't be instantiated, it should be derived. + //! @brief A Keyboard component can't be instantiated, it should be derived. explicit KeyboardComponent(WAL::Entity &entity); //! @brief Constructor KeyboardComponent(WAL::Entity &entity, unsigned int maxBombCount); - //! @brief A component can't be instantiated, it should be derived. + //! @brief A Keyboard component can't be instantiated, it should be derived. KeyboardComponent(const KeyboardComponent &) = default; //! @brief default destructor ~KeyboardComponent() override = default; - //! @brief A component can't be assigned + //! @brief A Keyboard component can't be assigned KeyboardComponent &operator=(const KeyboardComponent &) = delete; - - friend class KeyboardSystem; }; } \ No newline at end of file diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index 3b03337a..c0d435f8 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -19,7 +19,7 @@ namespace BBM { auto &health = entity.getComponent(); - if (health._healthPoint == 0); - health.die(); + if (health.getHealthPoint() == 0); + entity.setDisable(true); } } \ No newline at end of file diff --git a/sources/System/Keyboard/KeyboardSystem.cpp b/sources/System/Keyboard/KeyboardSystem.cpp index 0c8216ba..a994db01 100644 --- a/sources/System/Keyboard/KeyboardSystem.cpp +++ b/sources/System/Keyboard/KeyboardSystem.cpp @@ -20,22 +20,22 @@ namespace BBM auto &keyboard = entity.getComponent(); auto &controllable= entity.getComponent(); static const std::map keyPressedMap = { - {keyboard.keyJump, controllable._jump}, - {keyboard.keyBomb, controllable._bomb}, - {keyboard.keyPause, controllable._pause} + {keyboard.keyJump, controllable.jump}, + {keyboard.keyBomb, controllable.bomb}, + {keyboard.keyPause, controllable.pause} }; for (auto key : keyPressedMap) key.second = RAY::IsKeyPressed(key.first); - controllable._moveX = 0; - controllable._moveZ = 0; + controllable.moveX = 0; + controllable.moveZ = 0; if (RAY::IsKeyPressed(keyboard.keyRight)) - controllable._moveX += 1; + controllable.moveX += 1; if (RAY::IsKeyPressed(keyboard.keyLeft)) - controllable._moveX -= 1; + controllable.moveX -= 1; if (RAY::IsKeyPressed(keyboard.keyUp)) - controllable._moveX += 1; + controllable.moveX += 1; if (RAY::IsKeyPressed(keyboard.keyDown)) - controllable._moveX -= 1; + controllable.moveX -= 1; } } \ No newline at end of file