mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 07:53:43 +00:00
doc: add docu
- datacomponent - stateffectcomponent - powerupcomponent
This commit is contained in:
parent
044d957106
commit
eba3cdb6c8
@ -24,7 +24,6 @@ public:
|
|||||||
AssetManager(Manager* manager);
|
AssetManager(Manager* manager);
|
||||||
~AssetManager();
|
~AssetManager();
|
||||||
|
|
||||||
void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, Entity* owner);
|
|
||||||
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, std::string texturePath);
|
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, std::string texturePath);
|
||||||
|
|
||||||
Vector2D calculateSpawnPosition();
|
Vector2D calculateSpawnPosition();
|
||||||
|
|||||||
@ -11,9 +11,21 @@ class DataComponent : public Component
|
|||||||
public:
|
public:
|
||||||
DataComponent() {};
|
DataComponent() {};
|
||||||
~DataComponent() {};
|
~DataComponent() {};
|
||||||
|
/**
|
||||||
|
* @brief Set a key-value pair of any type in the data map
|
||||||
|
* @details e.g. setEntry("speed", 180); in this case the key is "speed" and the value is set to an integer of 180
|
||||||
|
* @param key The name to store the value under
|
||||||
|
* @param value The value to store of type T
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void setEntry(const std::string& key, const T& value) { dataMap.insert_or_assign(key, value); }
|
void setEntry(const std::string& key, const T& value) { dataMap.insert_or_assign(key, value); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a value of type T from the data map
|
||||||
|
* @details e.g. getEntry<int>("speed"); in this case the key is "speed" and the value is returned as an integer
|
||||||
|
* @param key The name to retrieve the value from
|
||||||
|
* @return An optional of type T containing the value if it exists and matches in typeid, otherwise std::nullopt
|
||||||
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::optional<T> getEntry(std::string key) const {
|
std::optional<T> getEntry(std::string key) const {
|
||||||
if (!this->dataMap.contains(key)) return std::nullopt;
|
if (!this->dataMap.contains(key)) return std::nullopt;
|
||||||
|
|||||||
@ -6,6 +6,10 @@
|
|||||||
class PowerupComponent : public Component
|
class PowerupComponent : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Powerup Component object
|
||||||
|
* @param func The function to be called when the powerup is picked up
|
||||||
|
*/
|
||||||
PowerupComponent(std::function<void (Entity*)> func);
|
PowerupComponent(std::function<void (Entity*)> func);
|
||||||
~PowerupComponent() {};
|
~PowerupComponent() {};
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,12 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
// This acts as a manager for the lifetime of a stateffect
|
/**
|
||||||
|
* @brief Struct to hold the duration, reset function and start time of a stat effect
|
||||||
|
*/
|
||||||
struct StatEffect {
|
struct StatEffect {
|
||||||
uint32_t duration;
|
uint32_t duration; //!< Duration of the effect in milliseconds
|
||||||
std::function<void()> resetFunction;
|
std::function<void()> resetFunction; //!< Function to reset the effect, will be called on expiry of duration
|
||||||
uint32_t startTime;
|
uint32_t startTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -19,6 +21,11 @@ public:
|
|||||||
|
|
||||||
void init() override;
|
void init() override;
|
||||||
void update() override;
|
void update() override;
|
||||||
|
/**
|
||||||
|
* @brief Add a stat effect to the entity
|
||||||
|
* @param duration The duration of the effect in milliseconds
|
||||||
|
* @param resetFunction The function to reset the effect, will be called on expiry of duration
|
||||||
|
*/
|
||||||
void addEffect(uint32_t duration, std::function<void()> resetFunction);
|
void addEffect(uint32_t duration, std::function<void()> resetFunction);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user