Download LyraStarterGame/Source/LyraGame/Teams/LyraTeamStatics.cpp from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 2.83 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Teams/LyraTeamStatics.cpp
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/Teams/LyraTeamStatics.cpp
-
curl -L -o LyraTeamStatics.cpp https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Teams/LyraTeamStatics.cpp
2.83 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| class UTexture; | |
| ////////////////////////////////////////////////////////////////////// | |
| void ULyraTeamStatics::FindTeamFromObject(const UObject* Agent, bool& bIsPartOfTeam, int32& TeamId, ULyraTeamDisplayAsset*& DisplayAsset, bool bLogIfNotSet) | |
| { | |
| bIsPartOfTeam = false; | |
| TeamId = INDEX_NONE; | |
| DisplayAsset = nullptr; | |
| if (UWorld* World = GEngine->GetWorldFromContextObject(Agent, EGetWorldErrorMode::LogAndReturnNull)) | |
| { | |
| if (ULyraTeamSubsystem* TeamSubsystem = World->GetSubsystem<ULyraTeamSubsystem>()) | |
| { | |
| TeamId = TeamSubsystem->FindTeamFromObject(Agent); | |
| if (TeamId != INDEX_NONE) | |
| { | |
| bIsPartOfTeam = true; | |
| DisplayAsset = TeamSubsystem->GetTeamDisplayAsset(TeamId, INDEX_NONE); | |
| if ((DisplayAsset == nullptr) && bLogIfNotSet) | |
| { | |
| UE_LOG(LogLyraTeams, Log, TEXT("FindTeamFromObject(%s) called too early (found team %d but no display asset set yet"), *GetPathNameSafe(Agent), TeamId); | |
| } | |
| } | |
| } | |
| else | |
| { | |
| UE_LOG(LogLyraTeams, Error, TEXT("FindTeamFromObject(%s) failed: Team subsystem does not exist yet"), *GetPathNameSafe(Agent)); | |
| } | |
| } | |
| } | |
| ULyraTeamDisplayAsset* ULyraTeamStatics::GetTeamDisplayAsset(const UObject* WorldContextObject, int32 TeamId) | |
| { | |
| ULyraTeamDisplayAsset* Result = nullptr; | |
| if (UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)) | |
| { | |
| if (ULyraTeamSubsystem* TeamSubsystem = World->GetSubsystem<ULyraTeamSubsystem>()) | |
| { | |
| return TeamSubsystem->GetTeamDisplayAsset(TeamId, INDEX_NONE); | |
| } | |
| } | |
| return Result; | |
| } | |
| float ULyraTeamStatics::GetTeamScalarWithFallback(ULyraTeamDisplayAsset* DisplayAsset, FName ParameterName, float DefaultValue) | |
| { | |
| if (DisplayAsset) | |
| { | |
| if (float* pValue = DisplayAsset->ScalarParameters.Find(ParameterName)) | |
| { | |
| return *pValue; | |
| } | |
| } | |
| return DefaultValue; | |
| } | |
| FLinearColor ULyraTeamStatics::GetTeamColorWithFallback(ULyraTeamDisplayAsset* DisplayAsset, FName ParameterName, FLinearColor DefaultValue) | |
| { | |
| if (DisplayAsset) | |
| { | |
| if (FLinearColor* pColor = DisplayAsset->ColorParameters.Find(ParameterName)) | |
| { | |
| return *pColor; | |
| } | |
| } | |
| return DefaultValue; | |
| } | |
| UTexture* ULyraTeamStatics::GetTeamTextureWithFallback(ULyraTeamDisplayAsset* DisplayAsset, FName ParameterName, UTexture* DefaultValue) | |
| { | |
| if (DisplayAsset) | |
| { | |
| if (TObjectPtr<UTexture>* pTexture = DisplayAsset->TextureParameters.Find(ParameterName)) | |
| { | |
| return *pTexture; | |
| } | |
| } | |
| return DefaultValue; | |
| } | |