A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
BaseStoryActor.cpp
Go to the documentation of this file.
1// Copyright(c) Pixo Group. All Rights Reserved.
2
4#include "GameFramework/GameModeBase.h"
6
8{
9 PrimaryActorTick.bCanEverTick = true;
10 Story = CreateDefaultSubobject<UStoryComponent>(TEXT("StoryComponent"));
11
12 HighlightComponent = CreateDefaultSubobject<UHighlightComponent>("HighlightComponent");
14}
15
20
21void ABaseStoryActor::StepSkipped_Implementation(FStoryStep SkippedStep, bool IsForward)
22{
23}
24
25void ABaseStoryActor::OnHintActivated_Implementation(bool Activate)
26{
28 {
30 {
32 }
34 {
35 bool ItemFounded = false;
36 for (auto Item : HighlightComponent->HighlightActiveOnSteps)
37 {
38 if (Item.EqualTo(Story->StoryManager->CurrentStep.StepName))
39 ItemFounded = true;
40 }
41 if (ItemFounded)
43 }
44 }
45}
46
47void ABaseStoryActor::ActivateHighlightOnActiveStep_Implementation()
48{
49 bool ItemFounded = false;
50 //Activate Highlight if there is matching steps
51 for (auto Item : HighlightComponent->HighlightActiveOnSteps)
52 {
53 if (Item.EqualTo(Story->StoryManager->CurrentStep.StepName) || Item.EqualTo(Story->StoryManager->CurrentSubStep.StepName))
54 {
56 ItemFounded = true;
57 break;
58 }
59 }
60
61 //Deactivate highlight if there is no matching steps
62 if (!ItemFounded && HighlightComponent->PulseHighlightTimerHandle.IsValid())
63 {
65 }
66}
67
69{
70 Super::BeginPlay();
71
73 {
77
79 {
80 FTimerDelegate HighlightActivateDelegate;
81 HighlightActivateDelegate.BindUFunction(this, "ActivateHighlightOnActiveStep");
82 GetWorld()->GetTimerManager().SetTimerForNextTick(HighlightActivateDelegate);
83 }
84 else
85 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "HighlightComponent IsNotValid");
86 }
87
88 if (GetLocalRole() == ROLE_Authority && GetWorld()->GetAuthGameMode()->GetClass()->ImplementsInterface(UPixoCoreInterface::StaticClass()))
89 {
90 HintManager = Cast<UHintManager>(IPixoCoreInterface::Execute_GetManagerRef(GetWorld()->GetAuthGameMode(), UHintManager::StaticClass()));
91 if (HintManager)
92 {
94 }
95 }
96}
97
98void ABaseStoryActor::NewStepActivated(FStoryStep NewStep, bool IsForward)
99{
101 {
103 {
105 }
107 {
109 }
110 }
111 else
112 GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "HighlightComponent IsNotValid");
113}
114
116{
117 NewStepActivated(NewSubStep, false);
118}
UStoryComponent * Story
UPROPERTY(BlueprintReadWrite, EditAnywhere)
void NewStepActivated(FStoryStep NewStep, bool IsForward)
Callback function for when a new step is activated.
void OnHintActivated(bool Activate)
Event called when a hint is activated.
virtual bool IsObjectActive_Implementation() override
Implementation of the IsObjectActive function from the IPixoVRStoryObject interface.
void NewSubStepActivated(FStoryStep NewSubStep)
Callback function for when a new substep is activated.
void ActivateHighlightOnActiveStep()
Event called to activate the highlight on the active step.
virtual void BeginPlay() override
UHintManager * HintManager
UPROPERTY(BlueprintReadWrite)
ABaseStoryActor()
UHighlightComponent * HighlightComponent
UPROPERTY(EditAnywhere, BlueprintReadWrite)
void StepSkipped(FStoryStep SkippedStep, bool IsForward)
Event called when a step is skipped.
bool AlwaysEmissiveHighlight
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Highlight")
FTimerHandle PulseHighlightTimerHandle
UPROPERTY(BlueprintReadWrite)
void ActivatePulseHighlight(bool Activate)
Activates or deactivates the pulse highlight effect.
bool ActivateHighlightOnEachStep
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Highlight")
bool UseIsObjectActiveInsteadOfActiveSteps
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Highlight")
FOnHintActivated OnHintActivated
Event delegate for hint activation.
Definition HintManager.h:45
bool ObjectActive
UPROPERTY(BlueprintReadWrite)
UStoryManager * StoryManager
UPROPERTY(BlueprintReadWrite)
FOnStepSkipped OnStepSkipped
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
FOnNewStep OnNewStep
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
FStoryStep CurrentSubStep
UPROPERTY(BlueprintReadWrite, Replicated)
FOnNewSubStep OnNewSubStep
UPROPERTY(BlueprintAssignable, Category = "Story Delegate")
FStoryStep CurrentStep
UPROPERTY(BlueprintReadWrite, Replicated)
USTRUCT(BlueprintType)
FText StepName
UPROPERTY(BlueprintReadWrite, EditAnywhere)