2022-05-23 18:41:30 +00:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
#include "LyraActorUtilities.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
|
2022-05-23 18:41:30 +00:00
|
|
|
#include "Components/ActorComponent.h"
|
2022-09-13 07:18:28 +00:00
|
|
|
#include "Engine/EngineBaseTypes.h"
|
|
|
|
#include "GameFramework/Actor.h"
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
#include "Templates/Casts.h"
|
|
|
|
#include "UObject/Object.h"
|
2022-05-23 18:41:30 +00:00
|
|
|
|
|
|
|
EBlueprintExposedNetMode ULyraActorUtilities::SwitchOnNetMode(const UObject* WorldContextObject)
|
|
|
|
{
|
|
|
|
ENetMode NetMode = NM_Standalone;
|
|
|
|
for (const UObject* TestObject = WorldContextObject; TestObject != nullptr; TestObject = TestObject->GetOuter())
|
|
|
|
{
|
|
|
|
if (const UActorComponent* Component = Cast<const UActorComponent>(WorldContextObject))
|
|
|
|
{
|
|
|
|
NetMode = Component->GetNetMode();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (const AActor* Actor = Cast<const AActor>(WorldContextObject))
|
|
|
|
{
|
|
|
|
NetMode = Actor->GetNetMode();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (NetMode)
|
|
|
|
{
|
|
|
|
case NM_Client:
|
|
|
|
return EBlueprintExposedNetMode::Client;
|
|
|
|
case NM_Standalone:
|
|
|
|
return EBlueprintExposedNetMode::Standalone;
|
|
|
|
case NM_DedicatedServer:
|
|
|
|
return EBlueprintExposedNetMode::DedicatedServer;
|
|
|
|
case NM_ListenServer:
|
|
|
|
return EBlueprintExposedNetMode::ListenServer;
|
|
|
|
default:
|
|
|
|
ensure(false);
|
|
|
|
return EBlueprintExposedNetMode::Standalone;
|
|
|
|
}
|
|
|
|
}
|