60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
// Oleg Petruny proprietary.
|
|
|
|
|
|
#include "InteractableActivator.h"
|
|
|
|
#include "Engine/CollisionProfile.h"
|
|
|
|
#include "PlayerBase.h"
|
|
|
|
UInteractableActivator::UInteractableActivator(const FObjectInitializer& ObjectInitializer)
|
|
: USceneComponent(ObjectInitializer)
|
|
{
|
|
if(HasAnyFlags(RF_ClassDefaultObject | RF_ArchetypeObject))
|
|
{
|
|
return;
|
|
}
|
|
world = GetWorld();
|
|
player = Cast<APlayerBase>(GetOwner());
|
|
|
|
collisionChannel = ECC_GameTraceChannel1;
|
|
if(auto collisions = UCollisionProfile::Get())
|
|
{
|
|
for(int32 i = 0; i < ECC_MAX; ++i)
|
|
{
|
|
if(collisions->ReturnChannelNameFromContainerIndex(i) == FName{ TEXT("Interactable") })
|
|
{
|
|
collisionChannel = (ECollisionChannel)i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!world || !player || collisionChannel == ECC_MAX)
|
|
{
|
|
DestroyComponent();
|
|
return;
|
|
}
|
|
|
|
PrimaryComponentTick.TickInterval = 0.05f;
|
|
PrimaryComponentTick.bCanEverTick = true;
|
|
PrimaryComponentTick.bStartWithTickEnabled = true;
|
|
RegisterComponent();
|
|
}
|
|
|
|
void UInteractableActivator::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
|
{
|
|
USceneComponent::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
|
|
|
switch(TickType)
|
|
{
|
|
case ELevelTick::LEVELTICK_TimeOnly:
|
|
case ELevelTick::LEVELTICK_ViewportsOnly:
|
|
case ELevelTick::LEVELTICK_All:
|
|
Scan_Implementation();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|