Fixes for starting dialogue
This commit is contained in:
@@ -30,6 +30,9 @@ NetIndexFirstBitSegment=16
|
||||
+GameplayTagList=(Tag="GameEvents",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.BazarOpen",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.Birthday.Yuki",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.Character",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.Character.Trish",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.Character.Trish.Meet",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.World.Time",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.World.Time.NewDay",DevComment="")
|
||||
+GameplayTagList=(Tag="GameEvents.World.Weather",DevComment="")
|
||||
|
||||
BIN
Content/GameData/Dialogue/Characters/Test/S_Trish_MeetDialogue.uasset
LFS
Normal file
BIN
Content/GameData/Dialogue/Characters/Test/S_Trish_MeetDialogue.uasset
LFS
Normal file
Binary file not shown.
BIN
Content/GameData/Events/Characters/Trish/GEDA_TrishMeet.uasset
LFS
Normal file
BIN
Content/GameData/Events/Characters/Trish/GEDA_TrishMeet.uasset
LFS
Normal file
Binary file not shown.
Binary file not shown.
@@ -44,16 +44,6 @@ void UDialogueComponent::OnDialogueLoaded()
|
||||
}
|
||||
}
|
||||
|
||||
void UDialogueComponent::FilterSpeechData()
|
||||
{
|
||||
ActiveSpeechData.Empty();
|
||||
for (int i = 0; i < SpeechData.Num(); ++i)
|
||||
{
|
||||
//Check if speech event condition is met
|
||||
ActiveSpeechData.Add(SpeechData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void UDialogueComponent::StartDialogueWithNpc()
|
||||
{
|
||||
UDialogueSubsystem* DialogueSubsystem = UDialogueSubsystem::Get(this);
|
||||
@@ -67,8 +57,12 @@ void UDialogueComponent::StartDialogueWithNpc()
|
||||
// answer, and it is the single funnel every dialogue goes through.
|
||||
if (!DialogueSubsystem->StartDialogue(GetOwner())) return;
|
||||
|
||||
USpeechDataAsset* StartingDialogue = NpcBaseCharacter->GetStartingSpeech().Get();
|
||||
TArray<USpeechDataAsset*> StartingDialogues = GetStartingDialogues();
|
||||
if (!StartingDialogues.IsEmpty()) StartingDialogue = StartingDialogues[0];
|
||||
|
||||
MappedDialogueOptions.Empty();
|
||||
TriggerDialogue(NpcBaseCharacter->GetStartingSpeech().Get(), CurrentDialogueReplacementMap);
|
||||
TriggerDialogue(StartingDialogue, CurrentDialogueReplacementMap);
|
||||
}
|
||||
|
||||
void UDialogueComponent::TriggerDialogue_Async(TSoftObjectPtr<USpeechDataAsset> DialogueAssetPath, const TMap<FString, FText>& ReplacementMap)
|
||||
@@ -117,27 +111,19 @@ void UDialogueComponent::TriggerDialogue(USpeechDataAsset* DialogueAssetPath, co
|
||||
DialogueSubsystem->StartDialogue(GetOwner());
|
||||
}
|
||||
|
||||
TArray<USpeechDataAsset*> UDialogueComponent::GetActiveSpeechData() { return ActiveSpeechData; }
|
||||
|
||||
TArray<USpeechDataAsset*> UDialogueComponent::GetStartingDialogues()
|
||||
{
|
||||
TArray<USpeechDataAsset*> TempSpeechData;
|
||||
for (int i = 0; i < ActiveSpeechData.Num(); ++i)
|
||||
for (int i = 0; i < SpeechData.Num(); ++i)
|
||||
{
|
||||
if(ActiveSpeechData[i]->TestRequirements(GetWorld()) && ActiveSpeechData[i]->PlayerAsk.IsEmpty())
|
||||
TempSpeechData.AddUnique(ActiveSpeechData[i]);
|
||||
}
|
||||
if( !SpeechData[i]->bIsStartingDialogue ||
|
||||
!SpeechData[i]->PlayerAsk.IsEmpty() ||
|
||||
!SpeechData[i]->TestRequirements(GetWorld()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return TempSpeechData;
|
||||
}
|
||||
|
||||
TArray<USpeechDataAsset*> UDialogueComponent::GetActiveDialogues()
|
||||
{
|
||||
TArray<USpeechDataAsset*> TempSpeechData;
|
||||
for (int i = 0; i < ActiveSpeechData.Num(); ++i)
|
||||
{
|
||||
if(ActiveSpeechData[i]->TestRequirements(GetWorld()) && !ActiveSpeechData[i]->PlayerAsk.IsEmpty())
|
||||
TempSpeechData.AddUnique(ActiveSpeechData[i]);
|
||||
TempSpeechData.AddUnique(SpeechData[i]);
|
||||
}
|
||||
|
||||
return TempSpeechData;
|
||||
@@ -195,7 +181,7 @@ void UDialogueComponent::AdvanceDialogue()
|
||||
}
|
||||
}
|
||||
|
||||
if (!CurrentActiveDialogue->RandomizeLines && (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num() - 1))
|
||||
if (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num() - 1)
|
||||
{
|
||||
CurrentLineIndex++;
|
||||
DialogueWidget->AdvanceDialogue(CurrentActiveDialogue->DialogueLines[CurrentLineIndex].DialogueLine, CurrentActiveDialogue->DialogueLines[CurrentLineIndex].SpeakerName);
|
||||
|
||||
@@ -19,8 +19,6 @@ class PROJECTELERI_API UDialogueComponent : public UActorComponent
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
void FilterSpeechData();
|
||||
|
||||
// use when you want to chit chat with an npc instead of play a specific dialogue option
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
@@ -30,16 +28,10 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue", meta = (AutoCreateRefTerm = "ReplacementMap"))
|
||||
void TriggerDialogue(USpeechDataAsset* DialogueAssetPath, const TMap<FString, FText>& ReplacementMap);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
TArray<USpeechDataAsset*> GetActiveSpeechData();
|
||||
|
||||
//Goes through active speech data and returns the all speech data asset without a condition and player ask
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
TArray<USpeechDataAsset*> GetStartingDialogues();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
TArray<USpeechDataAsset*> GetActiveDialogues();
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Eleri|Dialogue")
|
||||
void SetTextReplacementMap(const TMap<FString, FText>& ReplacementMap);
|
||||
|
||||
@@ -68,16 +60,12 @@ protected:
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
AEleriPlayerController* EleriPlayerController;
|
||||
|
||||
TObjectPtr<UWidgetComponent> DialogueWidgetComponent;
|
||||
UPROPERTY()
|
||||
TObjectPtr<UDialogueWidget> DialogueWidget;
|
||||
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<USpeechDataAsset>> SpeechData;
|
||||
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<USpeechDataAsset>> ActiveSpeechData;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
bool bDialogueSelectOpen = false;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "InventoryComponent.h"
|
||||
#include "Speech.h"
|
||||
#include "Misc/DataValidation.h"
|
||||
#include "QuestSystem/QuestSubsystem.h"
|
||||
|
||||
bool FEventRequirement::TestRequirement(const UObject* WorldContext) const
|
||||
@@ -23,13 +24,9 @@ bool FEventRequirement::TestRequirement(const UObject* WorldContext) const
|
||||
|
||||
const EEventStage EventStage = GameEventSubsystem->GetEventStage(EventAsset);
|
||||
|
||||
if (!bMustAchieveEvent && EventStage != EEventStage::NONE)
|
||||
return false;
|
||||
|
||||
if (bMustAchieveEvent && (GameEventSubsystem->GetEventStage(EventAsset) < Stage))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return bMustAchieveEvent?
|
||||
EventStage >= Stage :
|
||||
EventStage < Stage;
|
||||
}
|
||||
case EEventRequirementType::Quest:
|
||||
{
|
||||
@@ -96,3 +93,15 @@ FText USpeechDataAsset::ReplaceTextInLine(const FText& Text, TMap<FString, FText
|
||||
|
||||
return FText::Format(Text, Args);
|
||||
}
|
||||
|
||||
EDataValidationResult USpeechDataAsset::IsDataValid(class FDataValidationContext& Context) const
|
||||
{
|
||||
EDataValidationResult Result = Super::IsDataValid(Context);
|
||||
if (bIsStartingDialogue && EventRequirements.IsEmpty())
|
||||
{
|
||||
Context.AddError(FText::FromString(TEXT("Cannot be a starting dialogue without an event requirement")));
|
||||
Result = EDataValidationResult::Invalid;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
FText PlayerAsk;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
|
||||
bool RandomizeLines;
|
||||
bool bIsStartingDialogue;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
|
||||
TArray<FLineData> DialogueLines;
|
||||
@@ -107,4 +107,8 @@ public:
|
||||
FText GetFormattedDialogueLine(const int32 Index, const TMap<FString, FText> ReplacementMap);
|
||||
UFUNCTION(BlueprintPure, Category = "Eleri|Options")
|
||||
static FText ReplaceTextInLine(const FText& Text, TMap<FString, FText> ReplacementMap);
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override;
|
||||
#endif
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user