4#include "Net/UnrealNetwork.h"
31 UE_LOG(LogStoryManager,
Warning, TEXT(
"AStoryManager::InitNewStory StoryDataArray is empty"));
38 UE_LOG(LogStoryManager,
Warning, TEXT(
"AStoryManager::InitNewStory Index out of range"));
66 EventLogService::NewEvent<UNewStoryLoadedEvent>(
nullptr,
CurrentStep,
true);
83 EventLogService::NewEvent<UEndOfStoryReached>();
85 UE_LOG(LogStoryManager,
Warning, TEXT(
"AStoryManager::GoToNextStep Index out of range"));
104 EventLogService::NewEvent<UNewStepLoadedEvent>(
nullptr,
CurrentStep,
true);
105 UE_LOG(LogStoryManager, Log, TEXT(
"AStoryManager::GoToNextStep Next Step %s"), *
CurrentStep.
StepName.ToString());
129 EventLogService::NewEvent<UNewSubStepLoadedEvent>(
nullptr,
CurrentSubStep,
true);
130 UE_LOG(LogStoryManager, Log, TEXT(
"AStoryManager::GoToNextSubStep Next SubStep %s"),
161 UE_LOG(LogStoryManager,
Warning, TEXT(
"AStoryManager::JumpToStepByIndex Couldn't find a step by index %d"),
171 for (
int i =
StepIndex - 1; i >= index; i--)
201 EventLogService::NewEvent<UNewStepLoadedEvent>(
nullptr,
CurrentStep,
true);
202 UE_LOG(LogStoryManager, Log, TEXT(
"AStoryManager::JumpToStepByIndex Jump To Step %s"),
213 for (
int i = 0; i <
StepData.Num(); i++)
215 if (stepId.EqualTo(
StepData[i].Step.StepName))
225 UE_LOG(LogStoryManager,
Warning, TEXT(
"AStoryManager::JumpToStepByName Couldn't find a step %s"),
235 for (
int i =
StepIndex - 1; i >= index; i--)
265 EventLogService::NewEvent<UNewStepLoadedEvent>(
nullptr,
CurrentStep,
true);
266 UE_LOG(LogStoryManager, Log, TEXT(
"AStoryManager::JumpToStepByName Jump To Step %s"),
286 EventLogService::NewEvent<UStepCompletedEvent>(
nullptr,
CurrentStep);
314 bool isCompleted =
true;
317 if (!steps.Completed)
327 bool StoryAlreadyInArray =
false;
328 int32 FoundedStoryIndex = 0;
333 StoryAlreadyInArray =
true;
334 FoundedStoryIndex = i;
337 if (StoryAlreadyInArray)
352 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
373 UE_LOG(LogStoryManager,
Error, TEXT(
"AStoryManager::UInitializationEvent StoryDataArray is empty"));
#define DEFINE_EVENT_HANDLER(TEventType)
DEFINE_LOG_CATEGORY(LogStoryManager)
void HandleEvent_Impl(class UBaseEvent *Event)
Event called when we on init experience.
A component responsible for managing the story progression in story actors.
TArray< FStepData > StepData
UPROPERTY(EditAnywhere)
Manager that provides handling story-related operations and data.
int StoryIndex
UPROPERTY(BlueprintReadWrite, Replicated)
FOnStepSkipped OnStepSkipped
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
TArray< UStoryComponent * > StoryComponents
UPROPERTY()
FOnNewStep OnNewStep
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
FStoryStep PreviousStep
UPROPERTY(BlueprintReadWrite, Replicated)
bool JumpToStepByIndex(int index)
UFUNCTION(BlueprintCallable)
void RecordStoryStepData()
Records the data for a story step. It checks if the story is already present in the PassedExperiences...
bool JumpToStepByName(FText stepId)
UFUNCTION(BlueprintCallable)
UStoryData * StoryData
UPROPERTY(BlueprintReadWrite, Replicated)
TArray< FPassedExperiences > PassedExperiencesArray
UPROPERTY(BlueprintReadWrite)
FStoryStep CurrentSubStep
UPROPERTY(BlueprintReadWrite, Replicated)
int StepIndex
UPROPERTY(BlueprintReadWrite, Replicated)
FOnStoryLoaded OnStoryLoaded
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
int SubStepIndex
UPROPERTY(BlueprintReadWrite, Replicated)
void CompleteSubStep(FStoryStep completedStep)
UFUNCTION(BlueprintCallable)
static TArray< FText > StoryParameters
void AddStoryComponent(UStoryComponent *storyComponent)
bool InitNewStory(int newStoryIndex)
Choose one story from StoryDataArray.
bool BlockStory
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray< UStoryData * > StoryDataArray
UPROPERTY(EditAnywhere, BlueprintReadWrite)
virtual void GetLifetimeReplicatedProps(TArray< FLifetimeProperty > &OutLifetimeProps) const override
bool GoToNextSubStep()
UFUNCTION(BlueprintCallable)
bool GoToNextStep()
UFUNCTION(BlueprintCallable)
static void SetupNextStory(int newNextStoryIndex, TArray< FText > newStoryParameters)
UFUNCTION(BlueprintCallable)
TArray< FStepData > StepData
UPROPERTY(BlueprintReadWrite, Replicated)
FOnStepCompleted OnStepCompleted
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
void StepCompleted(FText stepToUpdate, bool goToNext=true)
UFUNCTION(BlueprintCallable)
bool StoryFinished
UPROPERTY(BlueprintReadOnly)
FOnNewSubStep OnNewSubStep
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
static int NextStoryIndex
Keeps track of which story should be loaded next by index, saved between levels.
bool IsAllSubStepsCompleted()
UFUNCTION()
FStoryStep CurrentStep
UPROPERTY(BlueprintReadWrite, Replicated)
FOnEndOfStory OnEndOfStory
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
int32 StoryIndex
UPROPERTY(BlueprintReadWrite)
TArray< FStepData > PassedStepData
UPROPERTY(BlueprintReadWrite)
bool operator==(const FStoryStep &Step) const
FText StepName
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool Completed
UPROPERTY(BlueprintReadWrite, EditAnywhere)