// Distributed under the MIT License (MIT) (see accompanying LICENSE file) #pragma once #include #include // Utilities helping to get a World Context. namespace Utilities { FORCEINLINE const FWorldContext* GetWorldContext(const UGameInstance& GameInstance) { return GameInstance.GetWorldContext(); } template FORCEINLINE const FWorldContext* GetWorldContext(const TWeakObjectPtr& Obj) { return Obj.IsValid() ? GetWorldContext(*Obj.Get()) : nullptr; } template FORCEINLINE const FWorldContext* GetWorldContext(const T* Obj) { return Obj ? GetWorldContext(*Obj) : nullptr; } FORCEINLINE const FWorldContext* GetWorldContext(const UGameViewportClient& GameViewportClient) { return GetWorldContext(GameViewportClient.GetGameInstance()); } FORCEINLINE const FWorldContext* GetWorldContext(const UWorld& World) { return GetWorldContext(World.GetGameInstance()); } const FWorldContext* GetWorldContextFromNetMode(ENetMode NetMode); }