#include "PerWorldServiceLocator.h"

#include "Engine/Engine.h"

FServiceLocator* UPerWorldServiceLocator::Get(UObject* WorldContextObject)
{
	UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
	if(!World)
		return nullptr;

	UPerWorldServiceLocator* PerWorldServiceLocator = World->GetSubsystem<UPerWorldServiceLocator>();
	if(!PerWorldServiceLocator)
		return nullptr;

	return &PerWorldServiceLocator->GetServiceLocator();
}

FServiceLocator& UPerWorldServiceLocator::GetServiceLocator()
{
	return ServiceLocator;
}
