F4MP/tiltedcode/Code/client/Services/CalendarService.h
Jous99 37b16f1547 code upload
codigo original de f4mp y tilted para referencias
2026-01-06 18:45:00 +01:00

44 lines
1.1 KiB
C++

#pragma once
#include <DateTime.h>
#include <Events/EventDispatcher.h>
#include <Games/Events.h>
struct ServerTimeSettings;
struct DisconnectedEvent;
struct World;
struct UpdateEvent;
struct TransportService;
/**
* @brief Handles time sync.
*/
class CalendarService final : public BSTEventSink<TESActivateEvent>
{
public:
CalendarService(World&, entt::dispatcher&, TransportService&);
static bool AllowGameTick() noexcept;
private:
void OnTimeUpdate(const ServerTimeSettings&) noexcept;
void HandleUpdate(const UpdateEvent&) noexcept;
void OnDisconnected(const DisconnectedEvent&) noexcept;
void ToggleGameClock(bool aEnable);
float TimeInterpolate(const TimeModel& aFrom, TimeModel& aTo) const;
entt::scoped_connection m_timeUpdateConnection;
entt::scoped_connection m_updateConnection;
entt::scoped_connection m_disconnectedConnection;
DateTime m_onlineTime;
DateTime m_offlineTime;
float m_fadeTimer = 0.f;
static bool s_gameClockLocked;
uint64_t m_lastTick = 0;
uint64_t m_lastLogTick = 0;
World& m_world;
TransportService& m_transport;
};