-
Notifications
You must be signed in to change notification settings - Fork 226
/
Utils.cpp
40 lines (32 loc) · 1.21 KB
/
Utils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <World.h>
#include <Components.h>
#include <Actor.h>
namespace Utils
{
std::optional<uint32_t> GetServerId(entt::entity aEntity) noexcept
{
const auto* pLocalComponent = World::Get().try_get<LocalComponent>(aEntity);
const auto* pRemoteComponent = World::Get().try_get<RemoteComponent>(aEntity);
const auto* pObjectComponent = World::Get().try_get<ObjectComponent>(aEntity);
uint32_t serverId = -1;
if (pLocalComponent)
serverId = pLocalComponent->Id;
else if (pRemoteComponent)
serverId = pRemoteComponent->Id;
else if (pObjectComponent)
serverId = pObjectComponent->Id;
else
{
const auto* pFormIdComponent = World::Get().try_get<FormIdComponent>(aEntity);
spdlog::warn("This entity has neither a local or remote component: {:X}, form id: {:X}", to_integral(aEntity), pFormIdComponent ? pFormIdComponent->Id : 0);
return std::nullopt;
}
return {serverId};
}
void ShowHudMessage(const TiltedPhoques::String& acMessage)
{
using TShowHudMessage = void(const char*, const char*, bool);
POINTER_SKYRIMSE(TShowHudMessage, s_showHudMessage, 52933);
s_showHudMessage(acMessage.c_str(), nullptr, false);
}
} // namespace Utils