Fix some bugs with merchant and options system
This commit is contained in:
@@ -17,6 +17,9 @@ void UEleriAudioSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
Super::Initialize(Collection);
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
#elif
|
||||
// The rotation starts on its own, so that a level does not have to remember to ask for music. Safe
|
||||
// here because a game instance is handed the world it will run in before its subsystems are
|
||||
// initialised, so GetWorld() already answers with the world the music is going to live in.
|
||||
@@ -24,6 +27,7 @@ void UEleriAudioSubsystem::Initialize(FSubsystemCollectionBase& Collection)
|
||||
{
|
||||
World->GetTimerManager().SetTimer(SoundtrackTimerHandle, this, &UEleriAudioSubsystem::StartDefaultMusic, 1.f, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UEleriAudioSubsystem::Deinitialize()
|
||||
|
||||
@@ -136,7 +136,7 @@ void UDialogueComponent::StartDialogueInternal(USpeechDataAsset* DialogueAssetPa
|
||||
DialogueWidget = Cast<UDialogueWidget>(EleriPlayerController->ToggleDialogueWindow(true));
|
||||
DialogueWidget->AssignDialogueComponent(this);
|
||||
|
||||
CurrentLineIndex = 0;
|
||||
CurrentLineIndex = GetStartingDialogueLineIndex(DialogueAssetPath);
|
||||
CurrentActiveDialogue = DialogueAssetPath;
|
||||
CurrentDialogueReplacementMap = ReplacementMap;
|
||||
DialogueWidget->DisplayDialogue(CurrentActiveDialogue, GetOwner(), CurrentDialogueReplacementMap);
|
||||
@@ -226,7 +226,7 @@ void UDialogueComponent::AdvanceDialogue()
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num())
|
||||
if (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num() && !CurrentActiveDialogue->bRandomLines)
|
||||
{
|
||||
const FSoftObjectPath EventToTrigger = CurrentActiveDialogue->DialogueLines[CurrentLineIndex].TriggerEventStart;
|
||||
if (!EventToTrigger.IsNull())
|
||||
@@ -235,7 +235,7 @@ void UDialogueComponent::AdvanceDialogue()
|
||||
}
|
||||
}
|
||||
|
||||
if (!CurrentActiveDialogue->StartQuests.IsEmpty())
|
||||
if (!CurrentActiveDialogue->StartQuests.IsEmpty() && !CurrentActiveDialogue->bRandomLines)
|
||||
{
|
||||
for (const FGameplayTag& QuestTag : CurrentActiveDialogue->StartQuests)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ void UDialogueComponent::AdvanceDialogue()
|
||||
}
|
||||
}
|
||||
|
||||
if (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num() - 1)
|
||||
if (CurrentLineIndex < CurrentActiveDialogue->DialogueLines.Num() - 1 && !CurrentActiveDialogue->bRandomLines)
|
||||
{
|
||||
CurrentLineIndex++;
|
||||
DialogueWidget->AdvanceDialogue(CurrentActiveDialogue->DialogueLines[CurrentLineIndex].DialogueLine, CurrentActiveDialogue->DialogueLines[CurrentLineIndex].SpeakerName);
|
||||
@@ -338,6 +338,28 @@ TArray<FText> UDialogueComponent::GetDialogueOptionsFromPlayerSpeakList(const TA
|
||||
return Options;
|
||||
}
|
||||
|
||||
int32 UDialogueComponent::GetStartingDialogueLineIndex(USpeechDataAsset* DialogueAssetPath)
|
||||
{
|
||||
if (!DialogueAssetPath) return INDEX_NONE;
|
||||
|
||||
TArray<int32> ValidIndexes;
|
||||
for (int32 Index = 0; Index < DialogueAssetPath->DialogueLines.Num(); ++Index)
|
||||
{
|
||||
if (DialogueAssetPath->DialogueLines[Index].EventRequired.IsValid() && UGameEventSubsystem::GetGameEventSubsystem()->GetEventStage(DialogueAssetPath->DialogueLines[Index].EventRequired) < EEventStage::STARTED)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ValidIndexes.Add(Index);
|
||||
}
|
||||
|
||||
if (ValidIndexes.IsEmpty()) return INDEX_NONE;
|
||||
|
||||
if (!DialogueAssetPath->bRandomLines) return ValidIndexes[0];
|
||||
|
||||
return ValidIndexes[FMath::RandRange(0, ValidIndexes.Num() - 1)];
|
||||
}
|
||||
|
||||
EDialogueSceneStart UDialogueComponent::StartDialogueScene(const USpeechDataAsset* DialogueAsset, EDialogueSceneTiming Timing)
|
||||
{
|
||||
if (DialogueAsset == nullptr || DialogueAsset->Scene.IsNull() || DialogueAsset->SceneTiming != Timing)
|
||||
|
||||
@@ -95,6 +95,8 @@ protected:
|
||||
|
||||
static TArray<FText> GetPlayerAsksFromDialogueList(const TArray<USpeechDataAsset*>& DialogueList);
|
||||
static TArray<FText> GetDialogueOptionsFromPlayerSpeakList(const TArray<FPlayerSpeakToDialogue>& SpeakList);
|
||||
|
||||
static int32 GetStartingDialogueLineIndex(USpeechDataAsset* DialogueAssetPath);
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "DialogueWidget")
|
||||
TSubclassOf<UDialogueWidget> DialogueWidgetClass;
|
||||
|
||||
@@ -22,6 +22,9 @@ struct FLineData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta=(MetaClass="/Script/ProjectEleri.GameEventDataAsset"))
|
||||
FSoftObjectPath EventRequired;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||
EDialogueEmotion DialogueEmotion;
|
||||
|
||||
|
||||
@@ -97,13 +97,13 @@ class PROJECTELERI_API USpeechDataAsset : public UDataAsset
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment")
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment", meta = (EditCondition = "!bRandomLines", EditConditionHides))
|
||||
TArray<FEventRequirement> EventRequirements;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Speech", meta = (AllowedClasses = "/Script/ProjectEleri.NpcBaseCharacter"))
|
||||
TSoftClassPtr<AActor> Npc;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech", meta = (Categories = "Quests"))
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech", meta = (Categories = "Quests", EditCondition = "!bRandomLines", EditConditionHides))
|
||||
FGameplayTagContainer StartQuests;
|
||||
|
||||
/**
|
||||
@@ -157,6 +157,11 @@ public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
|
||||
bool bIsStartingDialogue;
|
||||
|
||||
// Will pick one at random then display options if they're present.
|
||||
// If this is enabled, dialogue cannot trigger quests or events
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
|
||||
bool bRandomLines;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
|
||||
TArray<FLineData> DialogueLines;
|
||||
|
||||
Reference in New Issue
Block a user