diff --git a/Source/ols/Private/DataAssets/OLSExperienceActionSet.cpp b/Source/ols/Private/DataAssets/OLSExperienceActionSet.cpp new file mode 100644 index 0000000..d30a801 --- /dev/null +++ b/Source/ols/Private/DataAssets/OLSExperienceActionSet.cpp @@ -0,0 +1,57 @@ +// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action. + + +#include "DataAssets/OLSExperienceActionSet.h" + +#if WITH_EDITOR +#include "Misc/DataValidation.h" +#endif + +#include "GameFeatureAction.h" + +#include UE_INLINE_GENERATED_CPP_BY_NAME(OLSExperienceActionSet) + +#define LOCTEXT_NAMESPACE "OLSSystem" + +#if WITH_EDITOR +EDataValidationResult UOLSExperienceActionSet::IsDataValid(FDataValidationContext& context) const +{ + EDataValidationResult result = CombineDataValidationResults(Super::IsDataValid(context), EDataValidationResult::Valid); + + int32 entryIndex = 0; + for (const UGameFeatureAction* action : Actions) + { + if (action) + { + EDataValidationResult ChildResult = action->IsDataValid(context); + result = CombineDataValidationResults(result, ChildResult); + } + else + { + result = EDataValidationResult::Invalid; + context.AddError(FText::Format(LOCTEXT("ActionEntryIsNull", "Null entry at index {0} in Actions"), FText::AsNumber(entryIndex))); + } + + ++entryIndex; + } + + return result; +} +#endif + +#if WITH_EDITORONLY_DATA +void UOLSExperienceActionSet::UpdateAssetBundleData() +{ + Super::UpdateAssetBundleData(); + + for (UGameFeatureAction* action : Actions) + { + if (action) + { + action->AddAdditionalAssetBundleData(AssetBundleData); + } + } +} +#endif // WITH_EDITORONLY_DATA + +#undef LOCTEXT_NAMESPACE \ No newline at end of file diff --git a/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp b/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp index 3bf0103..99cbaa6 100644 --- a/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp +++ b/Source/ols/Private/GameModes/OLSExperienceManagerComponent.cpp @@ -9,6 +9,7 @@ #include "GameFeatureAction.h" #include "GameFeaturesSubsystemSettings.h" #include "TimerManager.h" +#include "DataAssets/OLSExperienceActionSet.h" #include "DataAssets/OLSExperienceDefinitionPrimaryDataAsset.h" #include "Net/UnrealNetwork.h" #include "Systems/OLSAssetManager.h" @@ -224,14 +225,14 @@ void UOLSExperienceManagerComponent::StartExperienceLoad() TSet rawAssetList; bundleAssetList.Add(CurrentExperience->GetPrimaryAssetId()); - // @Todo implement this - // for (const TObjectPtr& ActionSet : CurrentExperience->ActionSets) - // { - // if (ActionSet != nullptr) - // { - // BundleAssetList.Add(ActionSet->GetPrimaryAssetId()); - // } - // } + + for (const TObjectPtr& actionSet : CurrentExperience->ActionSets) + { + if (actionSet != nullptr) + { + bundleAssetList.Add(actionSet->GetPrimaryAssetId()); + } + } // Load assets associated with the experience diff --git a/Source/ols/Public/DataAssets/OLSExperienceActionSet.h b/Source/ols/Public/DataAssets/OLSExperienceActionSet.h new file mode 100644 index 0000000..9088dc1 --- /dev/null +++ b/Source/ols/Public/DataAssets/OLSExperienceActionSet.h @@ -0,0 +1,42 @@ +// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action. + +#pragma once + +#include "CoreMinimal.h" +#include "OLSPawnPrimaryDataAsset.h" +#include "OLSExperienceActionSet.generated.h" + +/** + * Definition of a set of actions to perform as part of entering an experience + */ +UCLASS(BlueprintType, NotBlueprintable) +class OLS_API UOLSExperienceActionSet : public UOLSPawnPrimaryDataAsset +{ + GENERATED_BODY() + +public: + + //~ Begin UObject interface +#if WITH_EDITOR + virtual EDataValidationResult IsDataValid(class FDataValidationContext& context) const override; +#endif + //~ End UObject interface + + //~ Begin UPrimaryDataAsset interface +#if WITH_EDITORONLY_DATA + virtual void UpdateAssetBundleData() override; +#endif + //~ End UPrimaryDataAsset interface + +public: + + // List of actions to perform as this experience is loaded/activated/deactivated/unloaded + UPROPERTY(EditAnywhere, Instanced, Category="Actions to Perform") + TArray> Actions; + + // List of Game Feature Plugins this experience wants to have active + UPROPERTY(EditAnywhere, Category="Feature Dependencies") + TArray GameFeaturesToEnable; +}; + + diff --git a/Source/ols/Public/DataAssets/OLSExperienceDefinitionPrimaryDataAsset.h b/Source/ols/Public/DataAssets/OLSExperienceDefinitionPrimaryDataAsset.h index 55ed3a3..f5b5ca3 100644 --- a/Source/ols/Public/DataAssets/OLSExperienceDefinitionPrimaryDataAsset.h +++ b/Source/ols/Public/DataAssets/OLSExperienceDefinitionPrimaryDataAsset.h @@ -42,14 +42,14 @@ public: TArray GameFeaturesToEnable; /** The default pawn class to spawn for players */ - // UPROPERTY(EditDefaultsOnly, Category = "OLSExperienceDefinition") - // TObjectPtr DefaultPawnData; + UPROPERTY(EditDefaultsOnly, Category = "OLSExperienceDefinition") + TObjectPtr DefaultPawnData = nullptr; // List of actions to perform as this experience is loaded/activated/deactivated/unloaded UPROPERTY(EditDefaultsOnly, Instanced, Category = "OLSExperienceDefinition") TArray> Actions; // List of additional action sets to compose into this experience - // UPROPERTY(EditDefaultsOnly, Category = "OLSExperienceDefinition") - // TArray> ActionSets; + UPROPERTY(EditDefaultsOnly, Category = "OLSExperienceDefinition") + TArray> ActionSets; };