From 75189645d0e9ec4d7e7064b6ff7f761a84684aef Mon Sep 17 00:00:00 2001 From: Benedikt Galbavy Date: Sat, 3 Feb 2024 16:53:40 +0100 Subject: [PATCH] Documented entity see todos --- Doxyfile | 2 +- include/Entity.h | 67 ++++++++++++++++++++++++++++++++++-------------- 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/Doxyfile b/Doxyfile index d90e875..78f37c4 100644 --- a/Doxyfile +++ b/Doxyfile @@ -530,7 +530,7 @@ EXTRACT_ALL = NO # be included in the documentation. # The default value is: NO. -EXTRACT_PRIVATE = YES +EXTRACT_PRIVATE = NO # If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual # methods of a class will be included in the documentation. diff --git a/include/Entity.h b/include/Entity.h index d02f6e4..805047b 100644 --- a/include/Entity.h +++ b/include/Entity.h @@ -16,36 +16,61 @@ using ComponentBitSet = std::bitset; using GroupBitSet = std::bitset; using ComponentArray = std::array; +/*! + * + * \brief Main class for any object in game, stores associations, labeling and components + * \details The entity class is the primary class each object in the game needs to use. Add components to assign functionality. + * + * \todo More detailed description + * \todo Some functions in entity class are only supposed to be called in specific context, which might be valid uses for `friend` keyword. Example: Entity() should only be called from Manager::addEntity(). Verify each functions intended use/scope. + * + */ class Entity { public: - /*! TODO */ + /*! + * \brief Used for rendering order (last is highest) or retrieving entities of group + * \todo Label used in singular entity shouldn't use plural + * \todo HEARTS are rendered above POWERUPS, missleading order + * \todo PROJECTILE are rendered above POWERUPS, missleading order + * \todo Generalize HEARTS as UI or similar + */ enum class GroupLabel { - MAPTILES, - PLAYERS, - ENEMIES, - COLLIDERS, - PROJECTILE, - HEARTS, - POWERUPS + MAPTILES, //!< Entity using TileComponent + PLAYERS, //!< Primary entity in player controll + ENEMIES, //!< \deprecated All players now grouped as player + COLLIDERS, //!< Fixed collider entity, e.g. a wall + PROJECTILE, //!< \todo Document + HEARTS, //!< \todo Document + POWERUPS //!< \todo Document }; + /*! + * \brief Allows grouping entities by team association for hits, win conditions, etc. + */ enum class TeamLabel { - NONE, //!< No team + NONE, //!< No team, should be skipped in any checks BLUE, //!< Team blue RED //!< Team red }; + /*! + * \todo Document + */ explicit Entity(Manager& mManager) : manager(mManager) { }; - void update() const; + void update() const; //!< Call each frame to update all components + //! Call after update to render components. + //! \sa SpriteComponent::draw() void draw() const; - bool isActive() const { return this->active; } + bool isActive() const { return this->active; } //!< \sa destroy() + //! Mark for destruction for Manager::refresh() and disables collision + //! \sa ColliderComponent void destroy() { this->active = false; if (this->hasComponent()) { @@ -53,22 +78,26 @@ public: } } - bool hasGroup(Group mGroup); - void addGroup(Group mGroup); - void delGroup(Group mGroup); + bool hasGroup(Group mGroup); //!< \sa GroupLabel + void addGroup(Group mGroup); //!< \sa GroupLabel + void delGroup(Group mGroup); //!< \sa GroupLabel + //! \returns bitset with true on position GroupLabel if the entity belongs to group + //! \sa GroupLabel std::bitset getGroupBitSet(); - void setTeam(TeamLabel teamLabel); - /*! TODO */ - TeamLabel getTeam(); + void setTeam(TeamLabel teamLabel); //!< \sa TeamLabel + TeamLabel getTeam(); //!< \sa TeamLabel + //! \sa Manager Manager& getManager() { return manager; }; - template bool hasComponent() const + template bool hasComponent() const //! \sa Component { return componentBitSet[getComponentTypeID()]; } + //! \brief Adds specified type as component and calls Component::init() + //! \param mArgs Constructor arguments of component template T& addComponent(TArgs&&...mArgs) { T* c(new T(std::forward(mArgs)...)); @@ -83,7 +112,7 @@ public: return *c; }; - template T& getComponent() const + template T& getComponent() const //! \returns Component of type T { auto ptr(componentArray[getComponentTypeID()]); return *static_cast(ptr);