Agrarsense
ActorAssetGroupDataAsset.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Engine/DataAsset.h"
10#include "Engine/Texture2D.h"
11#include "Misc/Guid.h"
13#include "ActorAssetGroupDataAsset.generated.h"
14
15/*
16 * Data asset for grouping of data assets together e.g. Birch group to hold all different sizes
17 */
18UCLASS(BlueprintType)
19class UActorAssetGroupDataAsset : public UDataAsset
20{
21 GENERATED_BODY()
22
23public:
27 UPROPERTY(EditAnywhere, BlueprintReadOnly)
28 FString UniqueIdentifier;
32 UPROPERTY(EditAnywhere, BlueprintReadOnly)
33 FText VariationText = NSLOCTEXT("Agrarsense", "Variation_Size", "Size");
34
38 UPROPERTY(EditAnywhere, BlueprintReadOnly)
39 FText DisplayName;
40
44 UPROPERTY(EditAnywhere, BlueprintReadOnly)
45 TObjectPtr<UTexture2D> GroupTexture;
46
50 UPROPERTY(EditAnywhere, BlueprintReadOnly)
51 FString DefaultVariation;
52
56 UPROPERTY(EditAnywhere, BlueprintReadOnly)
57 TArray<FActorAssetVariation> Variations;
58
63 UFUNCTION(BlueprintCallable, BlueprintPure)
64 bool HasMultipleVariations()
65 {
66 return Variations.Num() >= 2;
67 }
68
73 UFUNCTION(BlueprintCallable, BlueprintPure)
74 bool HasDefaultVariation()
75 {
76 return !DefaultVariation.IsEmpty();
77 }
78
84 UFUNCTION(BlueprintCallable, BlueprintPure)
85 FActorAssetVariation GetDefaultVariation(bool& FoundVariation)
86 {
87 return FindVariationByUniqueIdentifier(DefaultVariation, FoundVariation);
88 }
89
96 UFUNCTION(BlueprintCallable, BlueprintPure)
97 FActorAssetVariation FindVariationByUniqueIdentifier(const FString& UniqueIdentifierToFind, bool& FoundVariation)
98 {
99 for (const auto& Variation : Variations)
100 {
101 if (Variation.UniqueIdentifier == UniqueIdentifierToFind)
102 {
103 FoundVariation = true;
104 return Variation;
105 }
106 }
107
108 FoundVariation = false;
109 return FActorAssetVariation();
110 }
111
113 {
114 UniqueIdentifier = FGuid::NewGuid().ToString();
115 }
116};