#ifndef TIMER_HPP #define TIMER_HPP #include #include #include #include #include #include #include using namespace std; //check if the timer is still valid, check if enough time has passed and if so, actuate action class Timer { public: string name; size_t triggeramount; bool isexpired = false; bool isinfinite = false; size_t triggercount = 0; function timeraction; Timer(string name, int triggercount, function myaction, std::chrono::milliseconds triggerinterval); void add_time(std::chrono::milliseconds deltatime); private: std::chrono::milliseconds accumulator = std::chrono::milliseconds(0); std::chrono::milliseconds triggerinterval = std::chrono::milliseconds(1000); //default to 1 sec }; //CRUD timers and give them dt on update class TimerManager { public: vector> timers; TimerManager() { previoustime = std::chrono::steady_clock::now(); } void add_timer(unique_ptr newtimer); void delete_timer(); void update_timers(); private: std::chrono::steady_clock::time_point previoustime; }; #endif