diff --git a/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp b/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp index 3993e1a..181dcea 100644 --- a/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp +++ b/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp @@ -8,12 +8,15 @@ #include "GameFeaturesSubsystem.h" #include "GameFeatureAction.h" #include "GameFeaturesSubsystemSettings.h" +#include "OLSLog.h" #include "TimerManager.h" #include "DataAssets/OLSExperienceActionSetDataAsset.h" #include "DataAssets/OLSExperienceDefinitionDataAsset.h" #include "Net/UnrealNetwork.h" #include "Systems/OLSAssetManager.h" +DEFINE_LOG_CATEGORY(LogOLSExperienceManagerComponent); + //@TODO: Async load the experience definition itself //@TODO: Handle failures explicitly (go into a 'completed but failed' state rather than check()-ing) //@TODO: Do the action phases at the appropriate times instead of all at once @@ -96,21 +99,20 @@ void UOLSExperienceManagerComponent::EndPlay(const EEndPlayReason::Type endPlayR }; DeactivateListOfActions(CurrentExperience->Actions); - // @Todo implement this. - // for (const TObjectPtr& ActionSet : CurrentExperience->ActionSets) - // { - // if (ActionSet != nullptr) - // { - // DeactivateListOfActions(ActionSet->Actions); - // } - // } + for (const TObjectPtr& actionSet : CurrentExperience->ActionSets) + { + if (actionSet != nullptr) + { + DeactivateListOfActions(actionSet->Actions); + } + } NumExpectedPausers = context.GetNumPausers(); if (NumExpectedPausers > 0) { - // @Todo replace this with our custom. - // UE_LOG(LogLyraExperience, Error, TEXT("Actions that have asynchronous deactivation aren't fully supported yet in Lyra experiences")); + OLS_LOG(LogOLSExperienceManagerComponent, Error, + TEXT("Actions that have asynchronous deactivation aren't fully supported yet in Lyra experiences")); } if (NumExpectedPausers == NumObservedPausers) @@ -212,10 +214,8 @@ void UOLSExperienceManagerComponent::StartExperienceLoad() check(CurrentExperience != nullptr); check(LoadState == EOLSExperienceLoadState::Unloaded); - // @Todo replace this by custom log. - // UE_LOG(LogLyraExperience, Log, TEXT("EXPERIENCE: StartExperienceLoad(CurrentExperience = %s, %s)"), - // *CurrentExperience->GetPrimaryAssetId().ToString(), - // *GetClientServerContextString(this)); + OLS_LOG(LogOLSExperienceManagerComponent, Log, TEXT("EXPERIENCE: StartExperienceLoad(CurrentExperience = %s, %s)"), + *CurrentExperience->GetPrimaryAssetId().ToString(), *GetClientServerContextString(this)); LoadState = EOLSExperienceLoadState::Loading; @@ -305,10 +305,9 @@ void UOLSExperienceManagerComponent::OnExperienceLoadComplete() check(LoadState == EOLSExperienceLoadState::Loading); check(CurrentExperience != nullptr); - // @Todo replace this by our custom. - // UE_LOG(LogLyraExperience, Log, TEXT("EXPERIENCE: OnExperienceLoadComplete(CurrentExperience = %s, %s)"), - // *CurrentExperience->GetPrimaryAssetId().ToString(), - // *GetClientServerContextString(this)); + OLS_LOG(LogOLSExperienceManagerComponent, Log, TEXT("EXPERIENCE: OnExperienceLoadComplete(CurrentExperience = %s, %s)"), + *CurrentExperience->GetPrimaryAssetId().ToString(), + *GetClientServerContextString(this)); // find the URLs for our GameFeaturePlugins - filtering out dupes and ones that don't have a valid mapping GameFeaturePluginURLs.Reset(); @@ -328,7 +327,7 @@ void UOLSExperienceManagerComponent::OnExperienceLoadComplete() } } - // // Add in our extra plugin + // Add in our extra plugin (Lyra commented this out). // if (!CurrentPlaylistData->GameFeaturePluginToActivateUntilDownloadedContentIsPresent.IsEmpty()) // { // FString PluginURL; @@ -340,14 +339,13 @@ void UOLSExperienceManagerComponent::OnExperienceLoadComplete() }; collectGameFeaturePluginURLs(CurrentExperience, CurrentExperience->GameFeaturesToEnable); - // @Todo implement this. - // for (const TObjectPtr& ActionSet : CurrentExperience->ActionSets) - // { - // if (ActionSet != nullptr) - // { - // CollectGameFeaturePluginURLs(ActionSet, ActionSet->GameFeaturesToEnable); - // } - // } + for (const TObjectPtr& actionSet : CurrentExperience->ActionSets) + { + if (actionSet) + { + collectGameFeaturePluginURLs(actionSet, actionSet->GameFeaturesToEnable); + } + } // Load and activate the features NumGameFeaturePluginsLoading = GameFeaturePluginURLs.Num(); @@ -427,14 +425,14 @@ void UOLSExperienceManagerComponent::OnExperienceFullLoadCompleted() }; activateListOfActions(CurrentExperience->Actions); - // @Todo implement this - // for (const TObjectPtr& ActionSet : CurrentExperience->ActionSets) - // { - // if (ActionSet != nullptr) - // { - // activateListOfActions(ActionSet->Actions); - // } - // } + + for (const TObjectPtr& actionSet : CurrentExperience->ActionSets) + { + if (actionSet) + { + activateListOfActions(actionSet->Actions); + } + } LoadState = EOLSExperienceLoadState::Loaded; @@ -449,7 +447,7 @@ void UOLSExperienceManagerComponent::OnExperienceFullLoadCompleted() // Apply any necessary scalability settings #if !UE_SERVER - // @Todo implement this + // @TODO implement UOLSSettingsLocal // UOLSSettingsLocal::Get()->OnExperienceLoaded(); #endif } diff --git a/Source/ols/Private/OLSLog.cpp b/Source/ols/Private/OLSLog.cpp index 34fdf94..1d2986b 100644 --- a/Source/ols/Private/OLSLog.cpp +++ b/Source/ols/Private/OLSLog.cpp @@ -2,3 +2,34 @@ #include "OLSLog.h" + +FString GetClientServerContextString(UObject* contextObject) +{ + ENetRole role = ROLE_None; + + if (AActor* actor = Cast(contextObject)) + { + role = actor->GetLocalRole(); + } + else if (UActorComponent* component = Cast(contextObject)) + { + role = component->GetOwnerRole(); + } + + if (role != ROLE_None) + { + return (role == ROLE_Authority) ? TEXT("Server") : TEXT("Client"); + } + else + { +#if WITH_EDITOR + if (GIsEditor) + { + extern ENGINE_API FString GPlayInEditorContextString; + return GPlayInEditorContextString; + } +#endif + } + + return TEXT("[]"); +} diff --git a/Source/ols/Private/Systems/OLSAssetManager.cpp b/Source/ols/Private/Systems/OLSAssetManager.cpp index ee6996e..8856a5f 100644 --- a/Source/ols/Private/Systems/OLSAssetManager.cpp +++ b/Source/ols/Private/Systems/OLSAssetManager.cpp @@ -292,6 +292,6 @@ void UOLSAssetManager::InitializeGameplayCueManager() void UOLSAssetManager::UpdateInitialGameContentLoadPercent(float gameContentPercent) { - // @TODO: Implement this function. - // Could route this to the early startup loading screen + // Lyra left this comment. + // Could route this to the early startup loading screen. } diff --git a/Source/ols/Public/GameModes/OLSExperienceManagerComponent.h b/Source/ols/Public/GameModes/OLSExperienceManagerComponent.h index 4982e83..eb96635 100644 --- a/Source/ols/Public/GameModes/OLSExperienceManagerComponent.h +++ b/Source/ols/Public/GameModes/OLSExperienceManagerComponent.h @@ -7,6 +7,8 @@ #include "LoadingProcessInterface.h" #include "OLSExperienceManagerComponent.generated.h" +DECLARE_LOG_CATEGORY_EXTERN(LogOLSExperienceManagerComponent, Verbose, All); + namespace UE::GameFeatures { struct FResult; } DECLARE_MULTICAST_DELEGATE_OneParam(FOLSExperienceLoadedNativeDelegate, const class UOLSExperienceDefinitionDataAsset* /*experience*/); diff --git a/Source/ols/Public/OLSLog.h b/Source/ols/Public/OLSLog.h index d190723..b807075 100644 --- a/Source/ols/Public/OLSLog.h +++ b/Source/ols/Public/OLSLog.h @@ -119,4 +119,6 @@ * OLS_LOG_FUNC * OLS_LOG_FUNCTION_WORLD_CTX */ -#define OLS_LOG_FUNC_NO_WORLD(categoryName, verbosity) UE_LOG(categoryName, verbosity, TEXT("[NO_WORLD][%s]"), ANSI_TO_TCHAR(__func__)); \ No newline at end of file +#define OLS_LOG_FUNC_NO_WORLD(categoryName, verbosity) UE_LOG(categoryName, verbosity, TEXT("[NO_WORLD][%s]"), ANSI_TO_TCHAR(__func__)); + +OLS_API FString GetClientServerContextString(UObject* contextObject = nullptr); \ No newline at end of file