Bazaar improvements, moved some stuff into cpp and start creating the settings asset

This commit is contained in:
2026-08-22 18:10:43 +02:00
parent af29e5f859
commit 4c1f6eab70
11 changed files with 115 additions and 14 deletions

Binary file not shown.

View File

@@ -3,3 +3,12 @@
#include "BazarSellingStand.h"
void ABazarSellingStand::BeginPlay()
{
Super::BeginPlay();
BazarSettingsDataAsset.LoadAsync(FLoadSoftObjectPathAsyncDelegate::CreateWeakLambda(this, [this](const FSoftObjectPath& Path, UObject* Object)
{
}));
}

View File

@@ -6,6 +6,8 @@
#include "ProjectEleri/GameObjects/EleriBaseActor.h"
#include "BazarSellingStand.generated.h"
class UBazarSettingsDataAsset;
/**
*
*/
@@ -14,4 +16,11 @@ class PROJECTELERI_API ABazarSellingStand : public AEleriBaseActor
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Eleri|Bazaar")
TSoftObjectPtr<UBazarSettingsDataAsset> BazarSettingsDataAsset;
protected:
virtual void BeginPlay() override;
};

View File

@@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "BazarSettingsDataAsset.h"
void UBazarSettingsDataAsset::GetModifiersFromEmotionData(const FBazarDialogueEmotionData& InData, int32& OutAnger,
int32& OutFear, int32& OutSadness)
{
for (const FBazarEmotionModifier& Mod : InData.EmotionModifiers)
{
switch (Mod.Emotion)
{
case EBazarNpcEmotion::Anger:
OutAnger = FMath::RandRange(Mod.ValueMin, Mod.ValueMax);
break;
case EBazarNpcEmotion::Fear:
OutFear = FMath::RandRange(Mod.ValueMin, Mod.ValueMax);
break;
case EBazarNpcEmotion::Sadness:
OutSadness = FMath::RandRange(Mod.ValueMin, Mod.ValueMax);
break;
default: ;
}
}
}

View File

@@ -0,0 +1,61 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "BazarSettingsDataAsset.generated.h"
UENUM(BlueprintType)
enum class EBazarNpcEmotion: uint8
{
None,
Anger,
Fear,
Sadness,
MAX UMETA(Hidden)
};
USTRUCT(BlueprintType)
struct FBazarEmotionModifier
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, EditAnywhere)
EBazarNpcEmotion Emotion;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float ValueMin = 0.f;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
float ValueMax = 0.f;
float GetValueInRange() const { return FMath::RandRange(ValueMin, ValueMax); }
};
USTRUCT(BlueprintType)
struct FBazarDialogueEmotionData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<FBazarEmotionModifier> EmotionModifiers;
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FText DialogueText;
};
/**
*
*/
UCLASS()
class PROJECTELERI_API UBazarSettingsDataAsset : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere)
TArray<FBazarDialogueEmotionData> AvailableDialogueEmotionData;
UFUNCTION(BlueprintPure, Category = "Eleri|Bazaar")
static void GetModifiersFromEmotionData(const FBazarDialogueEmotionData& InData, int32& OutAnger, int32& OutFear, int32& OutSadness);
};