#include #include #include #include #include #include #include WeatherService::WeatherService(World& aWorld, entt::dispatcher& aDispatcher) noexcept : m_world(aWorld) { m_weatherChangeConnection = aDispatcher.sink>().connect<&WeatherService::OnWeatherChange>(this); m_currentWeatherConnection = aDispatcher.sink>().connect<&WeatherService::OnRequestCurrentWeather>(this); } void WeatherService::OnWeatherChange(const PacketEvent& acMessage) const noexcept { NotifyWeatherChange notify{}; notify.Id = acMessage.Packet.Id; auto* pParty = m_world.GetPartyService().GetPlayerParty(acMessage.pPlayer); if (!pParty) return; pParty->CachedWeather = notify.Id; if (!acMessage.pPlayer->GetCharacter()) return; const auto origin = *acMessage.pPlayer->GetCharacter(); GameServer::Get()->SendToPartyInRange(notify, acMessage.pPlayer->GetParty(), origin, acMessage.pPlayer); } void WeatherService::OnRequestCurrentWeather(const PacketEvent& acMessage) const noexcept { auto* pParty = m_world.GetPartyService().GetPlayerParty(acMessage.pPlayer); if (!pParty) return; NotifyWeatherChange notify{}; notify.Id = pParty->CachedWeather; acMessage.pPlayer->Send(notify); }