File size: 1,442 Bytes
1e67697 | 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | // Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraBotCheats.h"
#include "Engine/World.h"
#include "GameFramework/CheatManagerDefines.h"
#include "GameModes/LyraBotCreationComponent.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(LyraBotCheats)
//////////////////////////////////////////////////////////////////////
// ULyraBotCheats
ULyraBotCheats::ULyraBotCheats()
{
#if WITH_SERVER_CODE && UE_WITH_CHEAT_MANAGER
if (HasAnyFlags(RF_ClassDefaultObject))
{
UCheatManager::RegisterForOnCheatManagerCreated(FOnCheatManagerCreated::FDelegate::CreateLambda(
[](UCheatManager* CheatManager)
{
CheatManager->AddCheatManagerExtension(NewObject<ThisClass>(CheatManager));
}));
}
#endif
}
void ULyraBotCheats::AddPlayerBot()
{
#if WITH_SERVER_CODE && UE_WITH_CHEAT_MANAGER
if (ULyraBotCreationComponent* BotComponent = GetBotComponent())
{
BotComponent->Cheat_AddBot();
}
#endif
}
void ULyraBotCheats::RemovePlayerBot()
{
#if WITH_SERVER_CODE && UE_WITH_CHEAT_MANAGER
if (ULyraBotCreationComponent* BotComponent = GetBotComponent())
{
BotComponent->Cheat_RemoveBot();
}
#endif
}
ULyraBotCreationComponent* ULyraBotCheats::GetBotComponent() const
{
if (UWorld* World = GetWorld())
{
if (AGameStateBase* GameState = World->GetGameState())
{
return GameState->FindComponentByClass<ULyraBotCreationComponent>();
}
}
return nullptr;
}
|