0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 15:53:42 +00:00
SDL_Minigame/include/StatEffectsComponent.h
Nimac0 70080681e0
Some checks failed
/ deploy (push) Failing after 33s
Docs: Formatting and more content
2025-05-02 13:45:07 +02:00

34 lines
1013 B
C++

#pragma once
#include "Component.h"
#include "Constants.h"
#include <cstdint>
#include <array>
#include <functional>
/**
* @brief Struct to hold the duration, reset function and start time of a stat effect
*/
struct StatEffect {
uint32_t duration; //!< Duration of the effect in milliseconds
std::function<void()> resetFunction; //!< Function to reset the effect, will be called on expiry of duration
uint32_t startTime;
};
//! \brief Manages the lifecycle of temporary effects
class StatEffectsComponent : public Component{
public:
StatEffectsComponent() {};
~StatEffectsComponent() {};
void init() override;
void update(uint_fast16_t diffTime) 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);
private:
std::vector<StatEffect> effects = {};
};