/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Engine/Core/GameState/Implementation/ForwardEventsToGameStateComponent.cpp
66 строк
2 KB
C-Core
Re-enabled security relevant warnings (#1339)
25 июн 2024, 12:03
Не верифицирован
25 июн 2024, 12:03
7083663
Код
Авторство
О чём код?
#include <Core/GameApplication/GameApplicationBase.h> #include <Core/GameState/ForwardEventsToGameStateComponent.h> #include <Core/GameState/GameStateBase.h> // clang-format off EZ_BEGIN_COMPONENT_TYPE(ezForwardEventsToGameStateComponent, 1 /* version */, ezComponentMode::Static) { EZ_BEGIN_ATTRIBUTES { new ezCategoryAttribute("Logic"), } EZ_END_ATTRIBUTES; } EZ_END_COMPONENT_TYPE // clang-format on ezForwardEventsToGameStateComponent::ezForwardEventsToGameStateComponent() = default; ezForwardEventsToGameStateComponent::~ezForwardEventsToGameStateComponent() = default; bool ezForwardEventsToGameStateComponent::HandlesMessage(const ezMessage& msg) const { // check whether there is any active game state // if so, test whether it would handle this type of message if (ezGameStateBase* pGameState = ezGameApplicationBase::GetGameApplicationBaseInstance()->GetActiveGameState()) { return pGameState->GetDynamicRTTI()->CanHandleMessage(msg.GetId()); } return false; } bool ezForwardEventsToGameStateComponent::OnUnhandledMessage(ezMessage& msg, bool bWasPostedMsg) { EZ_IGNORE_UNUSED(bWasPostedMsg); // if we have an active game state, forward the message to it if (ezGameStateBase* pGameState = ezGameApplicationBase::GetGameApplicationBaseInstance()->GetActiveGameState()) { return pGameState->GetDynamicRTTI()->DispatchMessage(pGameState, msg); } return false; } bool ezForwardEventsToGameStateComponent::OnUnhandledMessage(ezMessage& msg, bool bWasPostedMsg) const { EZ_IGNORE_UNUSED(bWasPostedMsg); // if we have an active game state, forward the message to it if (const ezGameStateBase* pGameState = ezGameApplicationBase::GetGameApplicationBaseInstance()->GetActiveGameState()) { return pGameState->GetDynamicRTTI()->DispatchMessage(pGameState, msg); } return false; } void ezForwardEventsToGameStateComponent::Initialize() { SUPER::Initialize(); EnableUnhandledMessageHandler(true); } EZ_STATICLINK_FILE(Core, Core_GameState_Implementation_ForwardEventsToGameStateComponent);