Download LyraStarterGame/Source/LyraGame/Player/LyraPlayerStart.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 2.18 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Player/LyraPlayerStart.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/Player/LyraPlayerStart.cpp
-
curl -L -o LyraPlayerStart.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Player/LyraPlayerStart.cpp
2.18 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| ALyraPlayerStart::ALyraPlayerStart(const FObjectInitializer& ObjectInitializer) | |
| : Super(ObjectInitializer) | |
| { | |
| } | |
| ELyraPlayerStartLocationOccupancy ALyraPlayerStart::GetLocationOccupancy(AController* const ControllerPawnToFit) const | |
| { | |
| UWorld* const World = GetWorld(); | |
| if (HasAuthority() && World) | |
| { | |
| if (AGameModeBase* AuthGameMode = World->GetAuthGameMode()) | |
| { | |
| TSubclassOf<APawn> PawnClass = AuthGameMode->GetDefaultPawnClassForController(ControllerPawnToFit); | |
| const APawn* const PawnToFit = PawnClass ? GetDefault<APawn>(PawnClass) : nullptr; | |
| FVector ActorLocation = GetActorLocation(); | |
| const FRotator ActorRotation = GetActorRotation(); | |
| if (!World->EncroachingBlockingGeometry(PawnToFit, ActorLocation, ActorRotation, nullptr)) | |
| { | |
| return ELyraPlayerStartLocationOccupancy::Empty; | |
| } | |
| else if (World->FindTeleportSpot(PawnToFit, ActorLocation, ActorRotation)) | |
| { | |
| return ELyraPlayerStartLocationOccupancy::Partial; | |
| } | |
| } | |
| } | |
| return ELyraPlayerStartLocationOccupancy::Full; | |
| } | |
| bool ALyraPlayerStart::IsClaimed() const | |
| { | |
| return ClaimingController != nullptr; | |
| } | |
| bool ALyraPlayerStart::TryClaim(AController* OccupyingController) | |
| { | |
| if (OccupyingController != nullptr && !IsClaimed()) | |
| { | |
| ClaimingController = OccupyingController; | |
| if (UWorld* World = GetWorld()) | |
| { | |
| World->GetTimerManager().SetTimer(ExpirationTimerHandle, FTimerDelegate::CreateUObject(this, &ALyraPlayerStart::CheckUnclaimed), ExpirationCheckInterval, true); | |
| } | |
| return true; | |
| } | |
| return false; | |
| } | |
| void ALyraPlayerStart::CheckUnclaimed() | |
| { | |
| if (ClaimingController != nullptr && ClaimingController->GetPawn() != nullptr && GetLocationOccupancy(ClaimingController) == ELyraPlayerStartLocationOccupancy::Empty) | |
| { | |
| ClaimingController = nullptr; | |
| if (UWorld* World = GetWorld()) | |
| { | |
| World->GetTimerManager().ClearTimer(ExpirationTimerHandle); | |
| } | |
| } | |
| } | |