![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
A timer that can be used with the timer manager to handle time. More...
#include <C_timer.hpp>
Public Member Functions | |
Timer (fge::Timer const &timer) | |
Timer (fge::Timer &&timer) noexcept | |
Timer (std::chrono::milliseconds const &goal) | |
Create a new timer with the given time goal. | |
Timer (std::chrono::milliseconds const &goal, bool paused) | |
Create a new timer with the given time goal and pause state. | |
Timer (std::chrono::milliseconds const &goal, std::string name, bool paused) | |
Create a new timer with the given time goal, name and pause state. | |
void | setName (std::string const &name) |
Set the timer name. | |
std::string const & | getName () const |
Get the timer name. | |
void | setGoalDuration (std::chrono::milliseconds const &t) |
Set the goal duration of the timer. | |
void | addToGoal (std::chrono::milliseconds const &t) |
Add an amount of time to the goal duration of the timer. | |
void | subToGoal (std::chrono::milliseconds const &t) |
Subtract an amount of time to the goal duration of the timer. | |
void | setElapsedTime (std::chrono::milliseconds const &t) |
Set the elapsed time of the timer. | |
void | addToElapsedTime (std::chrono::milliseconds const &t) |
Add an amount of time to the elapsed time of the timer. | |
void | subToElapsedTime (std::chrono::milliseconds const &t) |
Subtract an amount of time to the elapsed time of the timer. | |
std::chrono::steady_clock::time_point const & | getLifeTimePoint () const |
Get the life time of the timer. | |
std::chrono::milliseconds | getLifeDuration () const |
Get the life time of the timer as milliseconds. | |
std::chrono::milliseconds const & | getElapsedTime () const |
Get the elapsed time of the timer. | |
std::chrono::milliseconds const & | getGoalDuration () const |
Get the goal time of the timer. | |
std::chrono::milliseconds | getTimeLeft () const |
Get the remaining time of the timer. | |
bool | goalReached () const |
Check if the goal has been reached. | |
void | restart () |
Restart the timer. | |
void | pause () |
Pause the timer. | |
void | resume () |
Unpause the timer. | |
bool | isPaused () const |
Check if the timer is paused. | |
Public Attributes | |
fge::CallbackHandler< fge::Timer & > | _onTimeReached |
The callback called when the timer reaches the goal. | |
A timer that can be used with the timer manager to handle time.
|
explicit |
Create a new timer with the given time goal.
goal | The time goal of the timer |
fge::Timer::Timer | ( | std::chrono::milliseconds const & | goal, |
bool | paused ) |
Create a new timer with the given time goal and pause state.
goal | The time goal of the timer |
paused | The pause state of the timer |
fge::Timer::Timer | ( | std::chrono::milliseconds const & | goal, |
std::string | name, | ||
bool | paused ) |
Create a new timer with the given time goal, name and pause state.
goal | The time goal of the timer |
name | The name of the timer |
paused | The pause state of the timer |
void fge::Timer::addToElapsedTime | ( | std::chrono::milliseconds const & | t | ) |
Add an amount of time to the elapsed time of the timer.
t | The amount of time to add to the elapsed time |
void fge::Timer::addToGoal | ( | std::chrono::milliseconds const & | t | ) |
Add an amount of time to the goal duration of the timer.
t | The amount of time to add to the goal duration |
std::chrono::milliseconds const & fge::Timer::getElapsedTime | ( | ) | const |
Get the elapsed time of the timer.
std::chrono::milliseconds const & fge::Timer::getGoalDuration | ( | ) | const |
Get the goal time of the timer.
std::chrono::milliseconds fge::Timer::getLifeDuration | ( | ) | const |
Get the life time of the timer as milliseconds.
std::chrono::steady_clock::time_point const & fge::Timer::getLifeTimePoint | ( | ) | const |
Get the life time of the timer.
This is the time elapsed since the timer was created.
std::string const & fge::Timer::getName | ( | ) | const |
Get the timer name.
std::chrono::milliseconds fge::Timer::getTimeLeft | ( | ) | const |
Get the remaining time of the timer.
bool fge::Timer::goalReached | ( | ) | const |
Check if the goal has been reached.
bool fge::Timer::isPaused | ( | ) | const |
Check if the timer is paused.
void fge::Timer::pause | ( | ) |
Pause the timer.
void fge::Timer::restart | ( | ) |
Restart the timer.
This will reset the elapsed time to 0.
void fge::Timer::resume | ( | ) |
Unpause the timer.
void fge::Timer::setElapsedTime | ( | std::chrono::milliseconds const & | t | ) |
Set the elapsed time of the timer.
t | The elapsed time of the timer |
void fge::Timer::setGoalDuration | ( | std::chrono::milliseconds const & | t | ) |
Set the goal duration of the timer.
This is the time goal of the timer, once reached the timer will be stopped and an callback will be called, you will be able to restart the timer in this callback.
t | The goal duration of the timer |
void fge::Timer::setName | ( | std::string const & | name | ) |
Set the timer name.
name | The name of the timer |
void fge::Timer::subToElapsedTime | ( | std::chrono::milliseconds const & | t | ) |
Subtract an amount of time to the elapsed time of the timer.
t | The amount of time to subtract to the elapsed time |
void fge::Timer::subToGoal | ( | std::chrono::milliseconds const & | t | ) |
Subtract an amount of time to the goal duration of the timer.
t | The amount of time to subtract to the goal duration |
fge::CallbackHandler<fge::Timer&> fge::Timer::_onTimeReached |
The callback called when the timer reaches the goal.