TmpMenu/src/services/hotkey/hotkey.cpp
maybegreat48 97a8c5d60b Add more spoofing options and added clang-format (#1020)
* feat(Spoofing): add spoofing
* feat(Spoofing): prepare code for player attach
* remove(PlayerAttach): isn't going to work due to netsync architecture
* fix(GUI): fix scaling
* feat(Project): add clang-format file
* feat(Classes): update classes
* fix(BlackHole): remove unnecessary cleanup
* fix(Formatting): fix formatting for initializer lists
* feat(clang-format): Set tab width and 1 space before comment

Co-authored-by: Yimura <24669514+Yimura@users.noreply.github.com>
2023-03-01 21:27:15 +00:00

36 lines
789 B
C++

#include "hotkey.hpp"
namespace big
{
hotkey::hotkey(rage::joaat_t name_hash, key_t key, rage::joaat_t command_hash, std::optional<std::chrono::high_resolution_clock::duration> cooldown) :
m_name_hash(name_hash),
m_key(key),
m_command_hash(command_hash),
m_cooldown(cooldown),
m_wakeup()
{
}
bool hotkey::can_exec() const
{
return !m_cooldown.has_value() || std::chrono::high_resolution_clock::now() >= m_wakeup;
}
void hotkey::exec()
{
if (m_cooldown.has_value())
m_wakeup = std::chrono::high_resolution_clock::now() + m_cooldown.value();
command::get(m_command_hash)->call(std::vector<std::uint64_t>());
}
rage::joaat_t hotkey::name_hash() const
{
return m_name_hash;
}
void hotkey::set_key(key_t new_key)
{
m_key = new_key;
}
}