Documentation for the Unreal C++ Plugin
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 UDataAsset
52 GENERATED_BODY()
53
54public:
55 UPROPERTY(EditAnywhere, BlueprintReadWrite)
56 TArray<FStepData> StepData;
57};
58
59USTRUCT(BlueprintType)
61{
62 GENERATED_BODY()
63
64 UPROPERTY(EditAnywhere, BlueprintReadWrite)
65 TSubclassOf<AActor> InteractiveObject;
66 UPROPERTY(EditAnywhere, BlueprintReadWrite)
67 TArray<FText> StorySteps;
68 UPROPERTY(EditAnywhere, BlueprintReadWrite)
69 TArray<FText> HighlightSteps;
70};
71
72UCLASS()
74{
75 GENERATED_BODY()
76public:
77 UPROPERTY(EditAnywhere, BlueprintReadWrite)
78 TArray<FInteractiveObjectData> InteractiveObjectData;
79};
80
82
83USTRUCT(BlueprintType)
84struct PIXOCORE_API FDynamicStoryData
86 GENERATED_BODY()
87
88 UPROPERTY(BlueprintReadWrite)
89 TArray<UStoryData*> DynamicStoryData;
90
91 UPROPERTY(BlueprintReadWrite)
92 TArray<UStoryScriptClassData*> StoryScripts;
94 UPROPERTY(BlueprintReadWrite)
95 TArray<UInteractiveObjectDataBase*> InteractiveObjectData;
96};
97
98DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnNewStep, FStoryStep, newStep, bool, isForward);
101DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnRecordStepScore, FStoryStep, step, float, score);
102DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnStepSkipped, FStoryStep, skippedStep, bool, isForward);
105
109UCLASS(Blueprintable)
110class PIXOCORE_API UStoryManager : public UBaseManager
111{
112 GENERATED_BODY()
113
114public:
115 //Manager event declaration
117
118public:
120
121 UPROPERTY(EditAnywhere, BlueprintReadWrite)
122 TArray<UStoryData*> StoryDataArray;
123 UPROPERTY(BlueprintReadWrite)
124 TArray<FPassedExperiences> PassedExperiencesArray;
125
126 UPROPERTY(BlueprintReadWrite, Replicated)
127 TArray<FStepData> StepData;
128
129 UPROPERTY(BlueprintReadWrite, Replicated)
130 FStoryStep CurrentStep;
131 UPROPERTY(BlueprintReadWrite, Replicated)
132 FStoryStep CurrentSubStep;
133 UPROPERTY(BlueprintReadWrite, Replicated)
134 int StepIndex;
135 UPROPERTY(BlueprintReadWrite, Replicated)
136 int SubStepIndex;
137 UPROPERTY(BlueprintReadWrite, Replicated)
138 FStoryStep PreviousStep;
139
140 UPROPERTY(BlueprintReadWrite, Replicated)
141 int StoryIndex = -1;
142
143 UPROPERTY(EditAnywhere, BlueprintReadWrite)
144 bool BlockStory;
146 UPROPERTY(BlueprintReadOnly)
147 bool StoryFinished = true;
148
149 UPROPERTY(EditInstanceOnly, Category = "StoryManager|Properties")
150 bool IsAutoSwitchingToNextStoryActive = false;
151
157 UFUNCTION(BlueprintCallable)
158 bool InitNewStory(int newStoryIndex);
160 UFUNCTION(BlueprintCallable)
161 bool GoToNextStep();
162 UFUNCTION(BlueprintCallable)
163 bool GoToNextSubStep();
164 UFUNCTION(BlueprintCallable)
165 void CompleteSubStep(FStoryStep completedStep);
166 UFUNCTION(BlueprintCallable)
167 bool JumpToStepByIndex(int index);
168 UFUNCTION(BlueprintCallable)
169 bool JumpToStepByName(FText stepId);
171 UFUNCTION(BlueprintCallable)
172 void StepCompleted(FText stepToUpdate, bool goToNext = true);
175 void AddStoryComponent(UStoryComponent* storyComponent);
176
177 // Setup story static parameters
178 UFUNCTION(BlueprintCallable)
179 static void SetupNextStory(int newNextStoryIndex, TArray<FText> newStoryParameters);
180
181 UFUNCTION(BlueprintCallable)
182 static int GetNextStoryIndex() { return NextStoryIndex; }
184 UFUNCTION(BlueprintCallable)
185 static TArray<FText> GetStoryParameters() { return StoryParameters; }
186
187 UFUNCTION(BlueprintCallable)
188 static bool IsSpecificParametersExist(TArray<FText> SpecificParameters);
190 //Misc
191 UFUNCTION(BlueprintCallable, Category = "StoryManager|Misc")
192 float GetCurrentStepDuration() const;
193
194 // Delegates
195
196 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
197 FOnNewStep OnNewStep;
198 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
199 FOnNewSubStep OnNewSubStep;
200 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
201 FOnStepCompleted OnStepCompleted;
202 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
203 FOnRecordStepScore OnRecordStepScore;
204 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
205 FOnStoryLoaded OnStoryLoaded;
206 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
207 FOnEndOfStory OnEndOfStory;
208 UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
209 FOnStepSkipped OnStepSkipped;
210
211protected:
212 UFUNCTION()
213 bool IsAllSubStepsCompleted();
219 UFUNCTION()
220 void RecordStoryStepData();
221
222 UPROPERTY(BlueprintReadWrite, Replicated)
223 UStoryData* StoryData;
225 static int NextStoryIndex;
226 static TArray<FText> StoryParameters;
227
228 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
229
230private:
231 UPROPERTY()
232 TArray<UStoryComponent*> StoryComponents;
233
234 FDateTime StepStartingTime;
235};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnActorStopped, ABaseGrippableStoryActor *, GrippableStoryActor)
#define DECLARE_EVENT_HANDLER(TEvent)
Definition BaseManager.h:11
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnWristMenuButtonPressedDelegate)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FLaserBeamActivated, APixoVRLaser *, Laser, bool, bActivated)
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.
TArray< FInteractiveObjectData > InteractiveObjectData
UPROPERTY(EditAnywhere, BlueprintReadWrite)
A component responsible for managing the story progression in story actors.
UCLASS()
GENERATED_BODY()
TArray< FStepData > StepData
UPROPERTY(EditAnywhere, BlueprintReadWrite)
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()
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")
FDateTime StepStartingTime
Data asset class for storing story script class data.
Definition StoryScript.h:83
USTRUCT(BlueprintType)
TArray< UStoryData * > DynamicStoryData
UPROPERTY(BlueprintReadWrite)
TArray< UStoryScriptClassData * > StoryScripts
UPROPERTY(BlueprintReadWrite)
GENERATED_BODY()
TArray< UInteractiveObjectDataBase * > InteractiveObjectData
UPROPERTY(BlueprintReadWrite)
USTRUCT(BlueprintType)
TSubclassOf< AActor > InteractiveObject
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray< FText > StorySteps
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray< FText > HighlightSteps
UPROPERTY(EditAnywhere, BlueprintReadWrite)
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()