2017-09-27 20:16:54 +00:00
|
|
|
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core.h>
|
|
|
|
#include <Engine.h>
|
|
|
|
|
|
|
|
|
|
|
|
// Utilities helping to get a World Context.
|
|
|
|
|
|
|
|
namespace Utilities
|
|
|
|
{
|
2018-03-05 13:33:38 +00:00
|
|
|
template<typename T>
|
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const T* Obj);
|
|
|
|
|
2018-02-02 23:14:17 +00:00
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const UGameInstance& GameInstance)
|
|
|
|
{
|
|
|
|
return GameInstance.GetWorldContext();
|
|
|
|
}
|
|
|
|
|
2017-09-27 20:16:54 +00:00
|
|
|
template<typename T>
|
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const TWeakObjectPtr<T>& Obj)
|
|
|
|
{
|
|
|
|
return Obj.IsValid() ? GetWorldContext(*Obj.Get()) : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const UGameViewportClient& GameViewportClient)
|
|
|
|
{
|
|
|
|
return GetWorldContext(GameViewportClient.GetGameInstance());
|
|
|
|
}
|
|
|
|
|
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const UWorld& World)
|
|
|
|
{
|
|
|
|
return GetWorldContext(World.GetGameInstance());
|
|
|
|
}
|
|
|
|
|
2018-03-05 13:33:38 +00:00
|
|
|
template<typename T>
|
|
|
|
FORCEINLINE const FWorldContext* GetWorldContext(const T* Obj)
|
|
|
|
{
|
|
|
|
return Obj ? GetWorldContext(*Obj) : nullptr;
|
|
|
|
}
|
|
|
|
|
2017-09-27 20:16:54 +00:00
|
|
|
const FWorldContext* GetWorldContextFromNetMode(ENetMode NetMode);
|
|
|
|
}
|