Files
UnrealEngineUWP/Engine/Source/Runtime/NavigationSystem/Private/NavigationInvokerComponent.cpp
frederic doll 8b4e25d20f Add NavAgent selector in NavInvoker system : it allows to define areas where the navmesh should be generated for specific agents, not necessarily for all of them
#rb mieszko.zielinski, aris.theophanidis
#preflight 63bf05026729b05ec966f890

[CL 23658495 by frederic doll in ue5-main branch]
2023-01-11 20:55:27 -05:00

61 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "NavigationInvokerComponent.h"
#include "NavigationSystem.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(NavigationInvokerComponent)
UNavigationInvokerComponent::UNavigationInvokerComponent(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, TileGenerationRadius(3000)
, TileRemovalRadius(5000)
{
bAutoActivate = true;
SupportedAgents.MarkInitialized();
}
void UNavigationInvokerComponent::Activate(bool bReset)
{
Super::Activate(bReset);
AActor* Owner = GetOwner();
if (Owner)
{
UNavigationSystemV1::RegisterNavigationInvoker(*Owner, TileGenerationRadius, TileRemovalRadius, SupportedAgents);
}
}
void UNavigationInvokerComponent::Deactivate()
{
Super::Deactivate();
AActor* Owner = GetOwner();
if (Owner)
{
UNavigationSystemV1::UnregisterNavigationInvoker(*Owner);
}
}
void UNavigationInvokerComponent::PostInitProperties()
{
Super::PostInitProperties();
SupportedAgents.MarkInitialized();
}
void UNavigationInvokerComponent::RegisterWithNavigationSystem(UNavigationSystemV1& NavSys)
{
if (IsActive())
{
AActor* Owner = GetOwner();
if (Owner)
{
NavSys.RegisterInvoker(*Owner, TileGenerationRadius, TileRemovalRadius, SupportedAgents);
}
}
}
void UNavigationInvokerComponent::SetGenerationRadii(const float GenerationRadius, const float RemovalRadius)
{
TileGenerationRadius = GenerationRadius;
TileRemovalRadius = RemovalRadius;
}