A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
StoryManager.h
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Engine/DataAsset.h"
8#include "StoryManager.generated.h"
9
10class UStoryComponent;
11
12DECLARE_LOG_CATEGORY_EXTERN(LogStoryManager, Log, All);
13
14USTRUCT(BlueprintType)
15struct PIXOCORE_API FStoryStep
16{
17 GENERATED_BODY()
19 UPROPERTY(BlueprintReadWrite, EditAnywhere)
20 FText StepName;
21 UPROPERTY(BlueprintReadWrite, EditAnywhere)
22 bool Completed;
23
24 bool operator==(const FStoryStep& Step) const;
25};
26
27USTRUCT(BlueprintType)
28struct PIXOCORE_API FStepData
29{
30 GENERATED_BODY()
31
32 UPROPERTY(BlueprintReadWrite, EditAnywhere)
34 UPROPERTY(BlueprintReadWrite, EditAnywhere)
35 TArray<FStoryStep> SubStep;
36};
37
38USTRUCT(BlueprintType)
39struct PIXOCORE_API FPassedExperiences
40{
41 GENERATED_BODY()
43 UPROPERTY(BlueprintReadWrite)
44 TArray<FStepData> PassedStepData;
45 UPROPERTY(BlueprintReadWrite)
46 int32 StoryIndex;
47};
48
49UCLASS()
50class PIXOCORE_API UStoryData : public UPrimaryDataAsset
52 GENERATED_BODY()
53
54public:
55 UPROPERTY(EditAnywhere)
56 TArray<FStepData> StepData;
57};
58
59DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNewStep, FStoryStep, newStep, bool, isForward);
61DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnStepCompleted, FStoryStep, completedStep);
62DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnRecordStepScore, FStoryStep, step, float, score);
63DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStepSkipped, FStoryStep, skippedStep, bool, isForward);
70UCLASS(Blueprintable)
71class PIXOCORE_API UStoryManager : public UBaseManager
73 GENERATED_BODY()
74
75public:
76 //Manager event declaration
78
79public:
81
82 UPROPERTY(EditAnywhere, BlueprintReadWrite)
83 TArray<UStoryData*> StoryDataArray;
84 UPROPERTY(BlueprintReadWrite)
85 TArray<FPassedExperiences> PassedExperiencesArray;
86
87 UPROPERTY(BlueprintReadWrite, Replicated)
88 TArray<FStepData> StepData;
89
90 UPROPERTY(BlueprintReadWrite, Replicated)
91 FStoryStep CurrentStep;
92 UPROPERTY(BlueprintReadWrite, Replicated)
93 FStoryStep CurrentSubStep;
94 UPROPERTY(BlueprintReadWrite, Replicated)
95 int StepIndex;
96 UPROPERTY(BlueprintReadWrite, Replicated)
97 int SubStepIndex;
98 UPROPERTY(BlueprintReadWrite, Replicated)
99 FStoryStep PreviousStep;
101 UPROPERTY(BlueprintReadWrite, Replicated)
102 int StoryIndex = -1;
103
104 UPROPERTY(EditAnywhere, BlueprintReadWrite)
105 bool BlockStory;
106
107 UPROPERTY(BlueprintReadOnly)
108 bool StoryFinished;
109
115 UFUNCTION(BlueprintCallable)
116 bool InitNewStory(int newStoryIndex);
117
118 UFUNCTION(BlueprintCallable)
119 bool GoToNextStep();
120 UFUNCTION(BlueprintCallable)
121 bool GoToNextSubStep();
122 UFUNCTION(BlueprintCallable)
123 void CompleteSubStep(FStoryStep completedStep);
124 UFUNCTION(BlueprintCallable)
125 bool JumpToStepByIndex(int index);
126 UFUNCTION(BlueprintCallable)
127 bool JumpToStepByName(FText stepId);
128
129 UFUNCTION(BlueprintCallable)
130 void StepCompleted(FText stepToUpdate, bool goToNext = true);
132
133 void AddStoryComponent(UStoryComponent* storyComponent);
134
135 UFUNCTION(BlueprintCallable)
136 static void SetupNextStory(int newNextStoryIndex, TArray<FText> newStoryParameters);
137
138 UFUNCTION(BlueprintCallable)
139 static int GetNextStoryIndex() { return NextStoryIndex; }
140
141 UFUNCTION(BlueprintCallable)
142 static TArray<FText> GetStoryParameters() { return StoryParameters; }
143
144 // Delegates
146 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
147 FOnNewStep OnNewStep;
148 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
149 FOnNewSubStep OnNewSubStep;
150 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
151 FOnStepCompleted OnStepCompleted;
152 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
153 FOnRecordStepScore OnRecordStepScore;
154 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
155 FOnStoryLoaded OnStoryLoaded;
156 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
157 FOnEndOfStory OnEndOfStory;
158 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
159 FOnStepSkipped OnStepSkipped;
160
161protected:
162 UFUNCTION()
163 bool IsAllSubStepsCompleted();
169 UFUNCTION()
170 void RecordStoryStepData();
171
172 UPROPERTY(BlueprintReadWrite, Replicated)
173 UStoryData* StoryData;
174
175 static int NextStoryIndex;
176 static TArray<FText> StoryParameters;
177
178 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
179
180private:
181 UPROPERTY()
182 TArray<UStoryComponent*> StoryComponents;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnApexWebSocketConnectFailed, const FString &, Error)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnApexRequestComplete, EApexRequestType, RequestType, const class UVaRestRequestJSON *, Request)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnApexWebSocketConnected)
#define DECLARE_EVENT_HANDLER(TEvent)
Definition BaseManager.h:11
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStoryLoaded)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNewStep, FStoryStep, newStep, bool, isForward)
DECLARE_LOG_CATEGORY_EXTERN(LogStoryManager, Log, All)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnNewSubStep, FStoryStep, newSubStep)
It provides functionalities for handling events, sending events, and managing a private owner....
Definition BaseManager.h:32
Event called when we on init experience.
A component responsible for managing the story progression in story actors.
UCLASS()
GENERATED_BODY()
TArray< FStepData > StepData
UPROPERTY(EditAnywhere)
Manager that provides handling story-related operations and data.
DECLARE_EVENT_HANDLER(UInitializationEvent)
static int GetNextStoryIndex()
UFUNCTION(BlueprintCallable)
FOnStepSkipped OnStepSkipped
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
TArray< UStoryComponent * > StoryComponents
UPROPERTY()
FOnNewStep OnNewStep
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
FStoryStep PreviousStep
UPROPERTY(BlueprintReadWrite, Replicated)
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)
static TArray< FText > StoryParameters
bool BlockStory
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray< UStoryData * > StoryDataArray
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FOnRecordStepScore OnRecordStepScore
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
static TArray< FText > GetStoryParameters()
UFUNCTION(BlueprintCallable)
TArray< FStepData > StepData
UPROPERTY(BlueprintReadWrite, Replicated)
FOnStepCompleted OnStepCompleted
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
GENERATED_BODY()
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.
FStoryStep CurrentStep
UPROPERTY(BlueprintReadWrite, Replicated)
FOnEndOfStory OnEndOfStory
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
USTRUCT(BlueprintType)
int32 StoryIndex
UPROPERTY(BlueprintReadWrite)
TArray< FStepData > PassedStepData
UPROPERTY(BlueprintReadWrite)
USTRUCT(BlueprintType)
TArray< FStoryStep > SubStep
UPROPERTY(BlueprintReadWrite, EditAnywhere)
FStoryStep Step
UPROPERTY(BlueprintReadWrite, EditAnywhere)
USTRUCT(BlueprintType)
FText StepName
UPROPERTY(BlueprintReadWrite, EditAnywhere)
bool Completed
UPROPERTY(BlueprintReadWrite, EditAnywhere)
GENERATED_BODY()