mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 22:05:10 +00:00
Adding components
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
|
||||
namespace WAL
|
||||
{
|
||||
@@ -18,35 +19,42 @@ namespace WAL
|
||||
//! @brief The name of this component
|
||||
std::string _name;
|
||||
//! @brief Is this component disabled?
|
||||
bool _disabled;
|
||||
bool _disabled = false;
|
||||
protected:
|
||||
//! @brief The entity that own this component
|
||||
Entity &_entity;
|
||||
//! @brief The list of dependencies of this component.
|
||||
// TODO check if there is a better type than strings
|
||||
std::vector<std::string> _dependencies;
|
||||
std::vector<std::type_index> _dependencies;
|
||||
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
explicit Component(std::string name, Entity &entity);
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
Component(const Component &) = default;
|
||||
public:
|
||||
//! @brief A component can't be assigned
|
||||
Component &operator=(const Component &) = delete;
|
||||
//! @brief A virtual destructor
|
||||
virtual ~Component() = default;
|
||||
|
||||
//! @brief Clone a component for another or the same entity.
|
||||
//! @param entity The entity that owns the ne component.
|
||||
virtual Component *clone(Entity &entity) const = 0;
|
||||
|
||||
//! @brief Get the name of this component
|
||||
std::string _getName() const;
|
||||
std::string getName() const;
|
||||
|
||||
//! @brief Used if the component is disabled
|
||||
bool isDisable() const;
|
||||
bool isDisabled() const;
|
||||
//! @brief Disable this component.
|
||||
void setDisable(bool disabled);
|
||||
|
||||
//! @brief Get the dependencies of this component.
|
||||
const std::vector<std::type_index> &getDependencies() const;
|
||||
|
||||
//! @brief The entity or this component has just been enabled.
|
||||
//! @param entity The entity that has this component
|
||||
virtual void onStart(Entity &entity);
|
||||
virtual void onStart();
|
||||
|
||||
//! @brief The entity or this component has just been disable.
|
||||
//! @param entity The entity that has this component
|
||||
virtual void onStop(Entity &entity);
|
||||
|
||||
//! @brief A virtual destructor (that also calls onStop)
|
||||
virtual ~Component();
|
||||
protected:
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
Component() = default;
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
Component(const Component &) = default;
|
||||
//! @brief A component can't be instantiated, it should be derived.
|
||||
Component &operator=(const Component &) = default;
|
||||
virtual void onStop();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user