mirror of
https://github.com/Jous99/F4MP.git
synced 2026-01-12 17:10:54 +01:00
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#include <Services/MapService.h>
|
|
#include <GameServer.h>
|
|
|
|
#include <Messages/NotifyRemoveWaypoint.h>
|
|
#include <Messages/NotifySetWaypoint.h>
|
|
#include <Messages/RequestRemoveWaypoint.h>
|
|
#include <Messages/RequestSetWaypoint.h>
|
|
|
|
MapService::MapService(World& aWorld, entt::dispatcher& aDispatcher) noexcept
|
|
: m_world(aWorld)
|
|
{
|
|
m_playerSetWaypointConnection =
|
|
aDispatcher.sink<PacketEvent<RequestSetWaypoint>>().connect<&MapService::OnSetWaypointRequest>(this);
|
|
m_playerRemoveWaypointConnection =
|
|
aDispatcher.sink<PacketEvent<RequestRemoveWaypoint>>().connect<&MapService::OnRemoveWaypointRequest>(this);
|
|
}
|
|
|
|
void MapService::OnSetWaypointRequest(const PacketEvent<RequestSetWaypoint>& acMessage) const noexcept
|
|
{
|
|
auto& message = acMessage.Packet;
|
|
|
|
NotifySetWaypoint notify{};
|
|
notify.Position = message.Position;
|
|
notify.WorldSpaceFormID = message.WorldSpaceFormID;
|
|
|
|
const auto& partyComponent = acMessage.pPlayer->GetParty();
|
|
if (!partyComponent.JoinedPartyId.has_value())
|
|
return;
|
|
|
|
GameServer::Get()->SendToParty(notify, partyComponent, acMessage.GetSender());
|
|
}
|
|
|
|
void MapService::OnRemoveWaypointRequest(const PacketEvent<RequestRemoveWaypoint>& acMessage) const noexcept
|
|
{
|
|
NotifyRemoveWaypoint notify{};
|
|
|
|
const auto& partyComponent = acMessage.pPlayer->GetParty();
|
|
if (!partyComponent.JoinedPartyId.has_value())
|
|
return;
|
|
|
|
GameServer::Get()->SendToParty(notify, partyComponent, acMessage.GetSender());
|
|
}
|
|
|