86 lines
2.4 KiB
C++
86 lines
2.4 KiB
C++
// © 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/OLSExperienceDefinitionDataAsset.h"
|
|
|
|
#include "GameFeatureAction.h"
|
|
#if WITH_EDITOR
|
|
#include "Misc/DataValidation.h"
|
|
#endif
|
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(OLSExperienceDefinitionDataAsset)
|
|
|
|
#define LOCTEXT_NAMESPACE "OLSSystem"
|
|
|
|
UOLSExperienceDefinitionDataAsset::UOLSExperienceDefinitionDataAsset()
|
|
{
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
EDataValidationResult UOLSExperienceDefinitionDataAsset::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;
|
|
}
|
|
|
|
// Make sure users didn't subclass from a BP of this (it's fine and expected to subclass once in BP, just not twice)
|
|
if (!GetClass()->IsNative())
|
|
{
|
|
const UClass* parentClass = GetClass()->GetSuperClass();
|
|
|
|
// Find the native parent
|
|
const UClass* firstNativeParent = parentClass;
|
|
while ((firstNativeParent != nullptr) && !firstNativeParent->IsNative())
|
|
{
|
|
firstNativeParent = firstNativeParent->GetSuperClass();
|
|
}
|
|
|
|
if (firstNativeParent != parentClass)
|
|
{
|
|
context.AddError(FText::Format(LOCTEXT("ExperienceInheritenceIsUnsupported", "Blueprint subclasses of Blueprint experiences is not currently supported (use composition via ActionSets instead). Parent class was {0} but should be {1}."),
|
|
FText::AsCultureInvariant(GetPathNameSafe(parentClass)),
|
|
FText::AsCultureInvariant(GetPathNameSafe(firstNativeParent))
|
|
));
|
|
result = EDataValidationResult::Invalid;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
#endif
|
|
|
|
FString UOLSExperienceDefinitionDataAsset::GetIdentifierString() const
|
|
{
|
|
return GetPrimaryAssetId().ToString();
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
void UOLSExperienceDefinitionDataAsset::UpdateAssetBundleData()
|
|
{
|
|
Super::UpdateAssetBundleData();
|
|
|
|
for (UGameFeatureAction* action : Actions)
|
|
{
|
|
if (action)
|
|
{
|
|
action->AddAdditionalAssetBundleData(AssetBundleData);
|
|
}
|
|
}
|
|
}
|
|
#endif
|