-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPureCPPCastTest2.cpp
More file actions
68 lines (56 loc) · 2.15 KB
/
Copy pathPureCPPCastTest2.cpp
File metadata and controls
68 lines (56 loc) · 2.15 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
65
66
67
68
// Copyright Tango Alpha LLC All Rights Reserved.
#include "PureCPPCastTest2.h"
#include "Kismet/KismetSystemLibrary.h"
APureCPPCastTest2::APureCPPCastTest2()
{
// 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, &APureCPPCastTest2::OnActorBeginOverlap);
}
void APureCPPCastTest2::BeginPlay()
{
Super::BeginPlay();
}
void APureCPPCastTest2::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void APureCPPCastTest2::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 < 100000; i++)
{
if (ACrowdCharacterActor* CrowdCharacter = Cast<ACrowdCharacterActor>(OtherActor))
{
CrowdCharacter->isHostage = !CrowdCharacter->isHostage;
}
else if (ALyraCharacter* LyraCharacter = Cast<ALyraCharacter>(OtherActor))
{
LyraCharacter->isHostage = !LyraCharacter->isHostage;
}
}
Now = FDateTime::Now();
ReturnValueSecondsEnd = Now.GetSecond();
ReturnValueMillisecondsEnd = Now.GetMillisecond();
FString TimeTakenMessage = FString::Printf(TEXT("Casting Test - Seconds: %d Milliseconds %d"),
ReturnValueSecondsEnd - ReturnValueSecondsStart,
ReturnValueMillisecondsEnd - ReturnValueMillisecondsStart);
GEngine->AddOnScreenDebugMessage(-1, 120.0f, FColor::Green, TimeTakenMessage);
}