Skip to content

Instantly share code, notes, and snippets.

@Deewens
Created April 18, 2025 18:15
Show Gist options
  • Select an option

  • Save Deewens/89be238452730ab1baa8b674587e5a37 to your computer and use it in GitHub Desktop.

Select an option

Save Deewens/89be238452730ab1baa8b674587e5a37 to your computer and use it in GitHub Desktop.
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "DialogueLine.h"
#include "Components/ActorComponent.h"
#include "DialogueComponent.generated.h"
USTRUCT(BlueprintType)
struct MASTER_TFE_API FDialogueWithConditions
{
GENERATED_BODY()
FDialogueWithConditions() = default;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FDialogueCondition> Conditions;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue", meta=(RequiredAssetDataTags = "RowStructure=/script/Master_TFE.DialogueLine"))
UDataTable* Dialogue;
};
/**
* Store the dialogue data for an actor (usually an NPC)
*/
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class MASTER_TFE_API UDialogueComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UDialogueComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
/**
* This will trigger the dialogue system to start the dialogue configured in the component. Does nothing if there is no dialogue to start
*/
UFUNCTION(BlueprintCallable)
void StartDialogue() const;
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue")
TArray<FDialogueWithConditions> Dialogues; // If I comment this, there is no error
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Dialogue", meta=(RequiredAssetDataTags = "RowStructure=/script/Master_TFE.DialogueLine"))
TObjectPtr<UDataTable> DefaultDialogue;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment