4#include "Kismet/KismetMathLibrary.h"
10#include "GameFramework/GameModeBase.h"
29 int32 CompletedStepsCount = 0;
30 int32 TotalNumberOfSteps = 0;
32 if (GetWorld()->GetAuthGameMode()->GetClass()->ImplementsInterface(UPixoCoreInterface::StaticClass()))
34 if (
UStoryManager* StoryManagerRef = Cast<UStoryManager>(IPixoCoreInterface::Execute_GetManagerRef(GetWorld()->GetAuthGameMode(), UStoryManager::StaticClass())))
36 TArray<FPassedExperiences> PassedExperiences = StoryManagerRef->PassedExperiencesArray;
38 for (
const auto & PassExpElement : PassedExperiences)
40 TotalNumberOfSteps += PassExpElement.PassedStepData.Num();
49 NewSessionData.
ScoreScaled = UKismetMathLibrary::SafeDivide((
float)CompletedStepsCount, (
float)TotalNumberOfSteps);
56FXAPIStatement UApexReportingManager::GetStatementData_Implementation()
60 StatementData.
Verb.
ID = FString(
"https://pixovr.com/xapi/verbs/completed");
61 StatementData.
Target.
ID = FString(
"https://pixovr.com/xapi/objects/") +
70 for (
const auto & PassExpElement : PassedExperiences)
72 for (
const auto & Step : PassExpElement.PassedStepData)
74 if (Step.Step.Completed)
85 return (UKismetMathLibrary::Now() -
ApexStartTime).GetTotalSeconds();
101 UE_LOG(LogTemp,
Error, TEXT (
"Apex SubSystem is not valid"));
114 const UStoryManager* StoryManager = Cast<UStoryManager>(IPixoCoreInterface::Execute_GetManagerRef(GetWorld()->GetAuthGameMode(), UStoryManager::StaticClass()));
127 UE_LOG(LogTemp,
Error, TEXT(
"ApexSubSystem reference is not valid!"));
#define DEFINE_EVENT_HANDLER(TEventType)
UCLASS(BlueprintType, Blueprintable)
bool SendSessionEvent(const FXAPIStatement &InStatement)
UFUNCTION(BlueprintCallable, Category = "Apex|API")
bool CompleteSession(const FSessionData &InSessionData)
UFUNCTION(BlueprintCallable, Category = "Apex|API")
bool JoinSession(FString InScenarioId, const FXAPIExtension &InContextExtension)
UFUNCTION(BlueprintCallable, Category = "Apex|API")
int LoadedModuleId
UPROPERTY(BlueprintReadOnly, Meta=(DisplayName="Module Id"))
UApexAPI * ApexSubSystem
UPROPERTY(BlueprintReadOnly)
FXAPIStatement GetStatementData()
This function can be implemented in blueprint to send custom FXAPIStatement.
void CompleteApexSession(bool Completed, bool Success)
This function is responsible for completing the session.
bool UseReportingEachStep
Indicates whether reporting should occur after completing each step.
int32 GetApexSessionDuration()
Retrieves the duration of the Apex session.
void OnInitialized()
UFUNCTION(BlueprintImplementableEvent)
FText CurrentStep
UPROPERTY(BlueprintReadOnly)
int32 ScoreFactor
The value by which the score reported in 'CompleteApexSession' will be multiplied.
TArray< int32 > LoadedStoryIndexesHistory
Array storing the history of loaded story indexes.
bool UseDefaultSessionEnd
Indicates whether the default session end should be used on UEndOfStoryReached.
int32 GetAmountOfCompletedSteps(const TArray< FPassedExperiences > PassedExperiences) const
bool UseDefaultSessionStart
Indicates whether the default session start should be used on UInitializationEvent.
void HandleEvent_Impl(class UBaseEvent *Event)
Event called when we complete last step.
Event called when we on init experience.
Event called when new step is loaded.
Event called when new story is loaded.
Event called when step is completed.
Manager that provides handling story-related operations and data.
int StoryIndex
UPROPERTY(BlueprintReadWrite, Replicated)
bool Complete
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
float Score
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
float ScoreMin
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
float ScoreScaled
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
float ScoreMax
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
int Duration
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
bool Success
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|Session Data")
FString ID
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|XAPI|Activity")
FXAPIVerb Verb
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|XAPI|Statement")
FXAPIActivity Target
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|XAPI|Statement")
FString ID
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Apex|XAPI|Verb")