4#include <engine2/igameeventsystem.h>
5#include <networksystem/inetworkmessages.h>
6#include <networksystem/inetworkserializer.h>
7#include <usermessages.pb.h>
12using PostEvent = void (IGameEventSystem::*)(CSplitScreenSlot, bool, int,
const uint64*, NetMessageInfo_t*,
13 const CNetMessage*,
unsigned long, NetChannelBufType_t);
21 if (kind->GetMessageId() != UM_TextMsg)
25 const auto* text =
const_cast<CNetMessage*
>(data)->ToPB<CUserMessageTextMsg>();
26 if (!text || text->param_size() == 0)
31 before.
Raise(message);
36 : _hook(
"TextMessages", [this] {
return Install(); }), Before(_hook.MakeLifecycle()), _interfaces(interfaces)
41 if (
auto available =
Available(); !available)
43 return std::unexpected(available.error());
45 const auto onPost = [
this](IGameEventSystem&, CSplitScreenSlot, bool, int,
const uint64*, NetMessageInfo_t* kind,
46 const CNetMessage* data,
unsigned long,
49 return HookInterface(
static_cast<PostEvent>(&IGameEventSystem::PostEventAbstract), _interfaces.GameEventSystem,
55 if (!_interfaces.GameEventSystem)
57 return std::unexpected(
Error::NotReady(
"IGameEventSystem not available"));
A multicast signal with a fixed handler signature: the one way to subscribe in VoltMod.
A hook before-handler's verdict.
static HookResult Block(Ret value)
Event< TextMessage & > Before
TextMessages(Interfaces &interfaces)
std::expected< void, Error > Status
std::expected< T, Error > Result
static HookResult< void > FilterTextMessage(Event< TextMessage & > &before, NetMessageInfo_t *kind, const CNetMessage *data)
Subscription HookInterface(Ret(Iface::*method)(Args...), Iface *instance, Before &&before, After &&after=nullptr)
Hook one virtual method of an engine interface for a subscription's lifetime.
void(IGameEventSystem::*)(CSplitScreenSlot, bool, int, const uint64 *, NetMessageInfo_t *, const CNetMessage *, unsigned long, NetChannelBufType_t) PostEvent
static Error NotReady(std::string detail)
Centralized holder for all SDK interface pointers.