mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-05 02:04:04 +00:00
change timers to not use ptrs (#1399)
add comments as to why logic may seem confusing.
This commit is contained in:
@@ -1,22 +1,10 @@
|
||||
#include "EntityCallbackTimer.h"
|
||||
|
||||
EntityCallbackTimer::EntityCallbackTimer(float time, std::function<void()> callback) {
|
||||
EntityCallbackTimer::EntityCallbackTimer(const float time, const std::function<void()> callback) {
|
||||
m_Time = time;
|
||||
m_Callback = callback;
|
||||
}
|
||||
|
||||
EntityCallbackTimer::~EntityCallbackTimer() {
|
||||
|
||||
}
|
||||
|
||||
std::function<void()> EntityCallbackTimer::GetCallback() {
|
||||
return m_Callback;
|
||||
}
|
||||
|
||||
float EntityCallbackTimer::GetTime() {
|
||||
return m_Time;
|
||||
}
|
||||
|
||||
void EntityCallbackTimer::Update(float deltaTime) {
|
||||
m_Time -= deltaTime;
|
||||
}
|
||||
|
@@ -5,11 +5,11 @@
|
||||
|
||||
class EntityCallbackTimer {
|
||||
public:
|
||||
EntityCallbackTimer(float time, std::function<void()> callback);
|
||||
~EntityCallbackTimer();
|
||||
EntityCallbackTimer(const float time, const std::function<void()> callback);
|
||||
|
||||
std::function<void()> GetCallback() const { return m_Callback; };
|
||||
|
||||
std::function<void()> GetCallback();
|
||||
float GetTime();
|
||||
float GetTime() const { return m_Time; };
|
||||
|
||||
void Update(float deltaTime);
|
||||
|
||||
|
@@ -1,14 +1,10 @@
|
||||
#include "EntityTimer.h"
|
||||
|
||||
EntityTimer::EntityTimer(std::string name, float time) {
|
||||
EntityTimer::EntityTimer(const std::string& name, const float time) {
|
||||
m_Name = name;
|
||||
m_Time = time;
|
||||
}
|
||||
|
||||
EntityTimer::~EntityTimer() {
|
||||
|
||||
}
|
||||
|
||||
std::string EntityTimer::GetName() {
|
||||
return m_Name;
|
||||
}
|
||||
|
@@ -4,8 +4,15 @@
|
||||
|
||||
class EntityTimer {
|
||||
public:
|
||||
EntityTimer(std::string name, float time);
|
||||
~EntityTimer();
|
||||
EntityTimer(const std::string& name, const float time);
|
||||
|
||||
bool operator==(const EntityTimer& other) const {
|
||||
return m_Name == other.m_Name;
|
||||
}
|
||||
|
||||
bool operator==(const std::string& other) const {
|
||||
return m_Name == other;
|
||||
}
|
||||
|
||||
std::string GetName();
|
||||
float GetTime();
|
||||
|
Reference in New Issue
Block a user