-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPureCPPInterfaceTest.cpp
More file actions
64 lines (52 loc) · 2.05 KB
/
Copy pathPureCPPInterfaceTest.cpp
File metadata and controls
64 lines (52 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright Tango Alpha LLC All Rights Reserved.
#include "PureCPPInterfaceTest.h"
#include "Kismet/KismetSystemLibrary.h"
APureCPPInterfaceTest::APureCPPInterfaceTest()
{
// Set this actor to call Tick() every frame
PrimaryActorTick.bCanEverTick = true;
// Create components
Cube = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Cube"));
RootComponent = Cube;
CollisionBox = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionBox"));
CollisionBox->SetupAttachment(RootComponent);
CollisionBox->SetHiddenInGame(false);
CollisionBox->SetVisibility(true);
// Set default values for variables
ReturnValueSecondsStart = 0;
ReturnValueMillisecondsStart = 0;
ReturnValueSecondsEnd = 0;
ReturnValueMillisecondsEnd = 0;
// Bind overlap event
CollisionBox->OnComponentBeginOverlap.AddDynamic(this, &APureCPPInterfaceTest::OnActorBeginOverlap);
}
void APureCPPInterfaceTest::BeginPlay()
{
Super::BeginPlay();
}
void APureCPPInterfaceTest::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void APureCPPInterfaceTest::OnActorBeginOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult& SweepResult)
{
FDateTime Now = FDateTime::Now();
ReturnValueSecondsStart = Now.GetSecond();
ReturnValueMillisecondsStart = Now.GetMillisecond();
for (int32 i = 0; i < 20000; i++)
{
if (OtherActor && OtherActor->GetClass()->ImplementsInterface(UCharacterInterface::StaticClass()))
{
ICharacterInterface::Execute_SetIsHostageCPP(OtherActor);
}
}
Now = FDateTime::Now();
ReturnValueSecondsEnd = Now.GetSecond();
ReturnValueMillisecondsEnd = Now.GetMillisecond();
FString TimeTakenMessage = FString::Printf(TEXT("Interface Test - Seconds: %d Milliseconds %d"),
ReturnValueSecondsEnd - ReturnValueSecondsStart,
ReturnValueMillisecondsEnd - ReturnValueMillisecondsStart);
GEngine->AddOnScreenDebugMessage(-1, 120.0f, FColor::Blue, TimeTakenMessage);
}