lyra_game_ue/Source/LyraGame/GameModes/LyraBotCreationComponent.h
Goran Lazarevski 3bcab085f8 Initial commit
2025-03-20 11:06:26 +01:00

64 lines
1.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/GameStateComponent.h"
#include "LyraBotCreationComponent.generated.h"
class ULyraExperienceDefinition;
class ULyraPawnData;
class AAIController;
UCLASS(Blueprintable, Abstract)
class ULyraBotCreationComponent : public UGameStateComponent
{
GENERATED_BODY()
public:
ULyraBotCreationComponent(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
//~UActorComponent interface
virtual void BeginPlay() override;
//~End of UActorComponent interface
private:
void OnExperienceLoaded(const ULyraExperienceDefinition* Experience);
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Gameplay)
int32 NumBotsToCreate = 5;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Gameplay)
TSubclassOf<AAIController> BotControllerClass;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category=Gameplay)
TArray<FString> RandomBotNames;
TArray<FString> RemainingBotNames;
protected:
UPROPERTY(Transient)
TArray<TObjectPtr<AAIController>> SpawnedBotList;
/** Always creates a single bot */
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Gameplay)
virtual void SpawnOneBot();
/** Deletes the last created bot if possible */
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category=Gameplay)
virtual void RemoveOneBot();
/** Spawns bots up to NumBotsToCreate */
UFUNCTION(BlueprintNativeEvent, BlueprintAuthorityOnly, Category=Gameplay)
void ServerCreateBots();
#if WITH_SERVER_CODE
public:
void Cheat_AddBot() { SpawnOneBot(); }
void Cheat_RemoveBot() { RemoveOneBot(); }
FString CreateBotName(int32 PlayerIndex);
#endif
};