Iteration on bazaar, new npc name interface, initial setup for dialogue triggering
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <ProjectEleri/GameEventSystem/GameEventSubsystem.h>
|
||||
#include <Kismet/GameplayStatics.h>
|
||||
|
||||
#include "Speech.h"
|
||||
|
||||
bool USpeechDataAsset::TestRequirements(UWorld* World)
|
||||
{
|
||||
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(World);
|
||||
@@ -27,3 +29,19 @@ bool USpeechDataAsset::TestRequirements(UWorld* World)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
FText USpeechDataAsset::GetFormattedDialogueLine(const int32 Index, TMap<FString, FText> ReplacementMap)
|
||||
{
|
||||
if (DialogueLines.Num() - 1 < Index || Index < 0)
|
||||
return FText();
|
||||
|
||||
const FText& LineRef = DialogueLines[Index].DialogueLine;
|
||||
|
||||
FFormatNamedArguments Args;
|
||||
for (const TTuple<FString, FText>& ReplacementPair : ReplacementMap)
|
||||
{
|
||||
Args.Add(ReplacementPair.Key, ReplacementPair.Value);
|
||||
}
|
||||
|
||||
return FText::Format(LineRef, Args);
|
||||
}
|
||||
|
||||
@@ -69,4 +69,7 @@ public:
|
||||
|
||||
UFUNCTION()
|
||||
bool TestRequirements(UWorld* World);
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
FText GetFormattedDialogueLine(const int32 Index, TMap<FString, FText> ReplacementMap);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "ProjectEleri/Public/Interface/ZoneInteractableInterface.h"
|
||||
#include "GameFramework/FloatingPawnMovement.h"
|
||||
#include "ProjectEleri/Public/Interface/NpcSpeakerDataInterface.h"
|
||||
#include "ProjectEleri/Data/FaceExpressionDataAsset.h"
|
||||
#include "StateTreeModule/Public/StateTree.h"
|
||||
#include "BaseCharacter.generated.h"
|
||||
@@ -18,7 +18,7 @@ class UCapsuleComponent;
|
||||
class USkeletalMeshComponent;
|
||||
|
||||
UCLASS(BlueprintType)
|
||||
class PROJECTELERI_API ABaseCharacter : public APawn, public IZoneInteractableInterface
|
||||
class PROJECTELERI_API ABaseCharacter : public APawn, public IZoneInteractableInterface, public INpcSpeakerDataInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -84,4 +84,7 @@ protected:
|
||||
|
||||
float SecondsTillNextFaceFrame = 0.f;
|
||||
int32 CurrentFaceFrameIndex = 0;
|
||||
|
||||
public:
|
||||
virtual FText GetNpcName_Implementation() override { return CharacterName;}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Interface/NpcSpeakerDataInterface.h"
|
||||
|
||||
|
||||
// Add default functionality here for any INpcSpeakerDataInterface functions that are not pure virtual.
|
||||
@@ -27,11 +27,13 @@
|
||||
#if WITH_EDITOR
|
||||
void AMyCharacter::DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) {
|
||||
Super::DisplayDebug(Canvas, DebugDisplay, YL, YPos);
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LOCTEXT_NAMESPACE "MyCharacter"
|
||||
const FText AMyCharacter::PlayerName = LOCTEXT("PlayerName", "Eleri");
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
// Sets default values
|
||||
AMyCharacter::AMyCharacter()
|
||||
{
|
||||
@@ -362,5 +364,10 @@ void AMyCharacter::ToggleBroomActor(bool bActive)
|
||||
}
|
||||
}
|
||||
|
||||
FText AMyCharacter::GetNpcName_Implementation()
|
||||
{
|
||||
return PlayerName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "NpcSpeakerDataInterface.generated.h"
|
||||
|
||||
// This class does not need to be modified.
|
||||
UINTERFACE()
|
||||
class UNpcSpeakerDataInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class PROJECTELERI_API INpcSpeakerDataInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
|
||||
public:
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Eleri|NpcSpeaker")
|
||||
FText GetNpcName();
|
||||
virtual FText GetNpcName_Implementation() { return FText(); }
|
||||
};
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "GlobalEnums.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Delegates/Delegate.h"
|
||||
#include "Interface/NpcSpeakerDataInterface.h"
|
||||
#include "ProjectEleri/Public/Interface/SaveableObjectInterface.h"
|
||||
|
||||
#include "MyCharacter.generated.h"
|
||||
@@ -31,7 +32,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnInteractExit);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnBookRenderTexUpdate);
|
||||
|
||||
UCLASS()
|
||||
class PROJECTELERI_API AMyCharacter : public ACharacter, public ISaveableObjectInterface
|
||||
class PROJECTELERI_API AMyCharacter : public ACharacter, public ISaveableObjectInterface, public INpcSpeakerDataInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -85,6 +86,7 @@ protected:
|
||||
float ZoomTime = 0.f;
|
||||
float NextZoomOffsetTarget = 0.f;
|
||||
|
||||
static const FText PlayerName;
|
||||
|
||||
//----- ISaveableObjectInterface -----
|
||||
// This is so actors can have custom data and we don't need to create new classes for it
|
||||
@@ -232,4 +234,6 @@ public:
|
||||
void ThrowWaterBall() const;
|
||||
|
||||
void ToggleBroomActor(bool bActive);
|
||||
|
||||
virtual FText GetNpcName_Implementation() override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user