-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Timer component for ECS entities and update includes
- Loading branch information
1 parent
448368b
commit 6f0bf1b
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Flakkari/Engine/EntityComponentSystem/Components/Common/Timer.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2024-11-17 | ||
** File description: | ||
** Timer | ||
*/ | ||
|
||
#ifndef Timer_HPP_ | ||
#define Timer_HPP_ | ||
|
||
#include <cstring> | ||
#include <string> | ||
#include <chrono> | ||
|
||
#include "config.h.in" | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
LPL_PACKED_START | ||
|
||
/** | ||
* @brief Timer component for ECS entities that have a timer attached to them | ||
* | ||
* @details This component is used to store the current time and the maximum time | ||
*/ | ||
struct Timer { | ||
std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now(); | ||
float maxTime; | ||
|
||
Timer() : maxTime(0) {} | ||
Timer(bool spawed) : maxTime(spawed) {} | ||
Timer(const Timer &other) : maxTime(other.maxTime) {} | ||
|
||
Timer &operator=(const Timer &other) | ||
{ | ||
if (this != &other) | ||
{ | ||
lastTime = other.lastTime; | ||
maxTime = other.maxTime; | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
std::size_t size() const { return sizeof(*this); } | ||
}; | ||
|
||
LPL_PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::Common | ||
|
||
#endif /* !Timer_HPP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters