Files
UnrealEngineUWP/Engine/Source/Runtime/NavigationSystem/Private/NavigationObjectRepository.cpp
yoan stamant 4dba3c02c3 [Navigation] Replaced custom NavLink static registration queue by a new world subsystem that will also store NavRelevantObject that are not AActor/UActorComponent based.
This change allow new NavigationSystem created after initial map load (e.g. ANavSystemConfigOverride) to properly recreate its custom nav link mappings and octree.
#rb Aris.Theophanidis, mikko.mononen, robert.seiver

[CL 32486904 by yoan stamant in 5.4 branch]
2024-03-25 17:45:24 -04:00

48 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "NavigationObjectRepository.h"
#include "AI/Navigation/NavRelevantInterface.h"
#include "NavLinkCustomInterface.h"
void UNavigationObjectRepository::RegisterNavRelevantObject(INavRelevantInterface& NavRelevantObject)
{
#if DO_ENSURE // We don't want to execute the Find at all for targets where ensures are disabled
if (!ensureMsgf(NavRelevantObjects.Find(&NavRelevantObject) == INDEX_NONE, TEXT("Same interface pointer can't be registered twice.")))
{
return;
}
#endif
NavRelevantObjects.Emplace(&NavRelevantObject);
OnNavRelevantObjectRegistered.ExecuteIfBound(NavRelevantObject);
}
void UNavigationObjectRepository::UnregisterNavRelevantObject(INavRelevantInterface& NavRelevantObject)
{
ensureMsgf(NavRelevantObjects.Remove(&NavRelevantObject) > 0, TEXT("Interface can't be removed since it was not registered or already unregistered)"));
OnNavRelevantObjectUnregistered.ExecuteIfBound(NavRelevantObject);
}
void UNavigationObjectRepository::RegisterCustomNavLinkObject(INavLinkCustomInterface& CustomNavLinkObject)
{
#if DO_ENSURE // We don't want to execute the Find at all for targets where ensures are disabled
if (!ensureMsgf(CustomLinkObjects.Find(&CustomNavLinkObject) == INDEX_NONE, TEXT("Same interface pointer can't be registered twice.")))
{
return;
}
#endif
CustomLinkObjects.Emplace(&CustomNavLinkObject);
OnCustomNavLinkObjectRegistered.ExecuteIfBound(CustomNavLinkObject);
}
void UNavigationObjectRepository::UnregisterCustomNavLinkObject(INavLinkCustomInterface& CustomNavLinkObject)
{
ensureMsgf(CustomLinkObjects.Remove(&CustomNavLinkObject) > 0, TEXT("Interface can't be removed since it was not registered or already unregistered)"));
OnCustomNavLinkObjectUnregistered.ExecuteIfBound(CustomNavLinkObject);
}