File size: 2,171 Bytes
7fd553e | 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 61 62 63 64 65 66 | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Components/GameStateComponent.h"
#include "LyraPlayerSpawningManagerComponent.generated.h"
#define UE_API LYRAGAME_API
class AController;
class APlayerController;
class APlayerState;
class APlayerStart;
class ALyraPlayerStart;
class AActor;
/**
* @class ULyraPlayerSpawningManagerComponent
*/
UCLASS(MinimalAPI)
class ULyraPlayerSpawningManagerComponent : public UGameStateComponent
{
GENERATED_BODY()
public:
UE_API ULyraPlayerSpawningManagerComponent(const FObjectInitializer& ObjectInitializer);
/** UActorComponent */
UE_API virtual void InitializeComponent() override;
UE_API virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
/** ~UActorComponent */
protected:
// Utility
UE_API APlayerStart* GetFirstRandomUnoccupiedPlayerStart(AController* Controller, const TArray<ALyraPlayerStart*>& FoundStartPoints) const;
virtual AActor* OnChoosePlayerStart(AController* Player, TArray<ALyraPlayerStart*>& PlayerStarts) { return nullptr; }
virtual void OnFinishRestartPlayer(AController* Player, const FRotator& StartRotation) { }
UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName=OnFinishRestartPlayer))
UE_API void K2_OnFinishRestartPlayer(AController* Player, const FRotator& StartRotation);
private:
/** We proxy these calls from ALyraGameMode, to this component so that each experience can more easily customize the respawn system they want. */
UE_API AActor* ChoosePlayerStart(AController* Player);
UE_API bool ControllerCanRestart(AController* Player);
UE_API void FinishRestartPlayer(AController* NewPlayer, const FRotator& StartRotation);
friend class ALyraGameMode;
/** ~ALyraGameMode */
UPROPERTY(Transient)
TArray<TWeakObjectPtr<ALyraPlayerStart>> CachedPlayerStarts;
private:
UE_API void OnLevelAdded(ULevel* InLevel, UWorld* InWorld);
UE_API void HandleOnActorSpawned(AActor* SpawnedActor);
#if WITH_EDITOR
UE_API APlayerStart* FindPlayFromHereStart(AController* Player);
#endif
};
#undef UE_API
|