|
|
|
|
| #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()
|
| {
|
| #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;
|
| }
|
|
|
|
|