2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-06-10 12:22:13 -04:00
|
|
|
|
|
|
|
|
#include "AROriginActor.h"
|
|
|
|
|
#include "EngineUtils.h"
|
2019-09-20 09:55:27 -04:00
|
|
|
#include "Engine/Engine.h"
|
2019-06-10 12:22:13 -04:00
|
|
|
|
|
|
|
|
AAROriginActor::AAROriginActor(const FObjectInitializer& ObjectInitializer)
|
|
|
|
|
: Super(ObjectInitializer)
|
|
|
|
|
{
|
|
|
|
|
PrimaryActorTick.bCanEverTick = false;
|
|
|
|
|
bAllowTickBeforeBeginPlay = false;
|
|
|
|
|
bReplicates = false;
|
2019-09-29 16:49:10 -04:00
|
|
|
SetReplicatingMovement(false);
|
|
|
|
|
SetCanBeDamaged(false);
|
2019-06-10 12:22:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AAROriginActor* AAROriginActor::GetOriginActor()
|
|
|
|
|
{
|
2019-09-19 18:36:43 -04:00
|
|
|
// Have to find the game world, not the editor world, if we are in vr preview
|
|
|
|
|
UWorld* GameWorld = nullptr;
|
|
|
|
|
for (const FWorldContext& Context : GEngine->GetWorldContexts())
|
|
|
|
|
{
|
|
|
|
|
if (Context.WorldType == EWorldType::Game || Context.WorldType == EWorldType::PIE)
|
|
|
|
|
{
|
|
|
|
|
GameWorld = Context.World();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GameWorld != nullptr)
|
2019-06-10 12:22:13 -04:00
|
|
|
{
|
|
|
|
|
AAROriginActor* FoundActor = nullptr;
|
2019-09-19 18:36:43 -04:00
|
|
|
for (TActorIterator<AAROriginActor> Iter(GameWorld); Iter; ++Iter)
|
2019-06-10 12:22:13 -04:00
|
|
|
{
|
|
|
|
|
if (!(*Iter)->IsPendingKill())
|
|
|
|
|
{
|
|
|
|
|
FoundActor = *Iter;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (FoundActor == nullptr)
|
|
|
|
|
{
|
|
|
|
|
// None spawned yet
|
2019-09-19 18:36:43 -04:00
|
|
|
FoundActor = GameWorld->SpawnActor<AAROriginActor>(AAROriginActor::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);
|
2019-06-10 12:22:13 -04:00
|
|
|
}
|
|
|
|
|
return FoundActor;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|