MultiWorld  1.0.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
UMultiWorldManager Class Reference

The subsystem of the MultiWorld plugin. More...

#include <MultiWorldManager.h>

Inheritance diagram for UMultiWorldManager:

Public Member Functions

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (FOnAsyncLoadCompletedDelegate, FMultiWorldHandle, WorldHandle, FMultiWorldLoadParameters, LoadParams)
 OnAsyncLoadCompleted delegate signature. More...
 
 DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams (FOnWorldSwitched, FMultiWorldHandle, PreviousWorld, FMultiWorldHandle, CurrentWorld)
 FOnWorldSwitched delegate signature. More...
 
virtual void Deinitialize () override
 Override USubsystem::Deinitialize. More...
 
void EndWorld (const FMultiWorldHandle &InWorldHandle)
 Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed. More...
 
void FixUpLocalPlayers ()
 Check local player setup and fixup if it's invalid. More...
 
FMultiWorldHandle GetActiveWorldHandle () const
 Return the world handle of the active World. More...
 
FMultiWorldHandle GetMainWorldHandle () const
 Return the main world handle. More...
 
FMultiWorldHandle GetThisWorldHandle (const UObject *WorldContextObject) const
 Return the world handle where the caller lives. More...
 
FMultiWorldHandle GetWorldHandleByName (FName WorldName) const
 Return the world handle of the world with the given name if found or an invalid handle otherwise. More...
 
virtual void Initialize (FSubsystemCollectionBase &Collection) override
 Override USubsystem::Initialize. More...
 
void InitializeWorld (const FMultiWorldHandle &InWorldHandle)
 Setup the input World for playing; Actors are intialized, BeginPlay is called etc... More...
 
bool IsValidHandle (const FMultiWorldHandle &InWorldHandle) const
 Return true if the input world handle is valid, false otherwise. More...
 
FMultiWorldHandle LoadWorld (TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams)
 Synchronously load a World into memory. More...
 
void LoadWorldAsync (TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams)
 Asynchronously load a World into memory. More...
 
bool ReturnToMainWorld ()
 Travel the local players to the main world. More...
 
void SetAutoHandleWidgetsForMainWorld (bool bAutoHandleWidgets)
 Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not). More...
 
void SetShouldTickWhenInBackground (const FMultiWorldHandle &InWorldHandle, bool bShouldTick)
 Sets whether or not the input world is ticked by the engine when it is in background (when not in play). More...
 
AActor * SpawnActorInWorld (TSubclassOf< class AActor > ActorClass, const FMultiWorldHandle &InWorldHandle, const FTransform &SpawnTransform, ESpawnActorCollisionHandlingMethod CollisionHandlingOverride, AActor *Owner)
 Create an actor and place it in the input world. More...
 
bool SwitchWorld (const FMultiWorldHandle &InWorldHandle)
 Change the Active World, travelling the local players to the input world. More...
 
void TransferActorToWorld (AActor *InActor, const FMultiWorldHandle &InWorldHandle, const FMultiWorldTransferActorParameters &Options)
 Transfer the input actor from its actual world to the input one. More...
 

Static Public Member Functions

static UMultiWorldManagerGetInstance (const UObject *context)
 Return the multi world manager instance. More...
 

Public Attributes

FOnAsyncLoadCompletedDelegate OnAsyncLoadCompleted
 Delegate called when the async load has terminated. More...
 
FOnWorldSwitched OnWorldSwitched
 Delegate called when the world is switched. More...
 

Friends

class UMultiWorldOverrides
 

Detailed Description

The subsystem of the MultiWorld plugin.

Member Function Documentation

◆ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams() [1/2]

UMultiWorldManager::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams ( FOnAsyncLoadCompletedDelegate  ,
FMultiWorldHandle  ,
WorldHandle  ,
FMultiWorldLoadParameters  ,
LoadParams   
)

OnAsyncLoadCompleted delegate signature.

◆ DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams() [2/2]

UMultiWorldManager::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams ( FOnWorldSwitched  ,
FMultiWorldHandle  ,
PreviousWorld  ,
FMultiWorldHandle  ,
CurrentWorld   
)

FOnWorldSwitched delegate signature.

◆ Deinitialize()

virtual void UMultiWorldManager::Deinitialize ( )
overridevirtual

Override USubsystem::Deinitialize.

◆ EndWorld()

void UMultiWorldManager::EndWorld ( const FMultiWorldHandle InWorldHandle)

Call the EndPlay to the input World and to all its actors; The World and all actors are destroyed.

The input world handle is not more valid after.

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle

◆ FixUpLocalPlayers()

void UMultiWorldManager::FixUpLocalPlayers ( )

Check local player setup and fixup if it's invalid.

It must be invoked by UGameViewportClient::LayoutPlayers

◆ GetActiveWorldHandle()

FMultiWorldHandle UMultiWorldManager::GetActiveWorldHandle ( ) const

Return the world handle of the active World.

Parameters
[in]WorldContextObjectthe world context object

◆ GetInstance()

static UMultiWorldManager& UMultiWorldManager::GetInstance ( const UObject *  context)
static

Return the multi world manager instance.

◆ GetMainWorldHandle()

FMultiWorldHandle UMultiWorldManager::GetMainWorldHandle ( ) const
inline

Return the main world handle.

The main world is the world loaded by the Unreal Engine itself.

Parameters
[in]WorldContextObjectthe world context object

◆ GetThisWorldHandle()

FMultiWorldHandle UMultiWorldManager::GetThisWorldHandle ( const UObject *  WorldContextObject) const

Return the world handle where the caller lives.

Technically it's the UWorld of the World Context Object implicitly passed by UE4 to the function.

Parameters
[in]WorldContextObjectthe world context object

◆ GetWorldHandleByName()

FMultiWorldHandle UMultiWorldManager::GetWorldHandleByName ( FName  WorldName) const

Return the world handle of the world with the given name if found or an invalid handle otherwise.

If two or more worlds have the same name, the first found is returned.

Parameters
[in]WorldContextObjectthe world context object
[in]WorldNamethe name of the world to looking for

◆ Initialize()

virtual void UMultiWorldManager::Initialize ( FSubsystemCollectionBase &  Collection)
overridevirtual

Override USubsystem::Initialize.

◆ InitializeWorld()

void UMultiWorldManager::InitializeWorld ( const FMultiWorldHandle InWorldHandle)

Setup the input World for playing; Actors are intialized, BeginPlay is called etc...

After you call this method, you can switch world calling SwitchWorld.

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world to setup; it should came from the function LoadWorld.

◆ IsValidHandle()

bool UMultiWorldManager::IsValidHandle ( const FMultiWorldHandle InWorldHandle) const

Return true if the input world handle is valid, false otherwise.

Parameters
[in]WorldContextObjectthe world context object
[in]InWorldHandlethe world handle to check

◆ LoadWorld()

FMultiWorldHandle UMultiWorldManager::LoadWorld ( TSoftObjectPtr< UWorld >  MapAsset,
FMultiWorldLoadParameters  InParams 
)

Synchronously load a World into memory.

Be aware that the loaded world exists only on the local client and is not replicated.

Parameters
[in]WorldContextObjectthe world context object
MapAssetthe map asset where the World is located.
InParamsoptional params to customize the loading.
Returns
the loaded world handle if success, an invalid handle otherwise
See also
LoadWorldAsync() to load a world asynchronously.
MultiWorldLoadParameters to customize the loading.

◆ LoadWorldAsync()

void UMultiWorldManager::LoadWorldAsync ( TSoftObjectPtr< UWorld >  MapAsset,
FMultiWorldLoadParameters  InParams 
)

Asynchronously load a World into memory.

Use the delegate UMultiWorldManager::OnAsyncLoadCompleted to be notified when the load is completed. Be aware that the loaded world exists only on the local client and is not replicated.

Attention
to work asynchronously, the project setting "Async Loading Thread Enabled" MUST be enabled (under section "Engine - Streaming") and project data MUST be cooked. You can also enable the flag adding in DefaultEngine.ini:
[/Script/Engine.StreamingSettings]
s.AsyncLoadingThreadEnable=true
Parameters
[in]WorldContextObjectthe world context object
MapAssetthe map asset where the World is located.
InParamsoptional params to customize the loading.
See also
LoadWorld() to load a world synchronously.
MultiWorldLoadParameters to customize the loading.

◆ ReturnToMainWorld()

bool UMultiWorldManager::ReturnToMainWorld ( )

Travel the local players to the main world.

The main world is the world loaded by the Unreal Engine itself. If you call from the main world, the call doesn't have any effect.

Parameters
[in]WorldContextObjectthe world context object
Returns
true if succeeded, false otherwise

◆ SetAutoHandleWidgetsForMainWorld()

void UMultiWorldManager::SetAutoHandleWidgetsForMainWorld ( bool  bAutoHandleWidgets)

Sets whenever the UMG main world widgets must be handled automatically or not (shown when the world is active, hidden when the world is not).

Parameters
[in]WorldContextObjectthe world context object
[in]bAutoHandleWidgetstrue if widgets are handled automatically for the main world, false otherwise.

◆ SetShouldTickWhenInBackground()

void UMultiWorldManager::SetShouldTickWhenInBackground ( const FMultiWorldHandle InWorldHandle,
bool  bShouldTick 
)

Sets whether or not the input world is ticked by the engine when it is in background (when not in play).

Attention
You MUST NOT disable the background ticking of the Main World in a multi-player game.
Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle for which to apply the setting
bShouldTickthe "tick-when-in-background" flag

◆ SpawnActorInWorld()

AActor* UMultiWorldManager::SpawnActorInWorld ( TSubclassOf< class AActor >  ActorClass,
const FMultiWorldHandle InWorldHandle,
const FTransform &  SpawnTransform,
ESpawnActorCollisionHandlingMethod  CollisionHandlingOverride,
AActor *  Owner 
)

Create an actor and place it in the input world.

Parameters
[in]WorldContextObjectthe world context object
[in]ActorClassthe class to use to create the actor
[in]InWorldHandlethe world where to place the actor
[in]SpawnTransformthe absolute world transform of the new actor
[in]CollisionHandlingOverridethe strategy for handling the case of collision when the actor is spawned
[in]Ownerthe owner of the new actor
Returns
the new created actor

◆ SwitchWorld()

bool UMultiWorldManager::SwitchWorld ( const FMultiWorldHandle InWorldHandle)

Change the Active World, travelling the local players to the input world.

Secondary Worlds are not replicated.

All actors implementing the interface IMultiWorldActorInterface are notified accordingly to the interface.

The delegate UMultiWorldManager::OnWorldSwitched is notified.

UMG widgets are managed accordingly to the configuration (see FMultiWorldLoadParameters::bAutoHandleWidgets and SetAutoHandleWidgetsForMainWorld()).

Parameters
[in]WorldContextObjectthe world context object
InWorldHandlethe world handle where to go
Returns
true if succeeded, false otherwise

◆ TransferActorToWorld()

void UMultiWorldManager::TransferActorToWorld ( AActor *  InActor,
const FMultiWorldHandle InWorldHandle,
const FMultiWorldTransferActorParameters Options 
)

Transfer the input actor from its actual world to the input one.

It's not network-replicated.

Attention
While the method UMultiWorldStatics::TransferActorToWorld() provides a convenient way to transfer an actor between different UWorld instances, and its implementation is generic enough to manage most common cases, particular actor setups or advanced uses could require a different and manual procedure. In this case, the suggested approach is to serialize the actor from the source World into a temporary buffer, destroy the actor and create a new instance in the destination World (e.g. using UMultiWorldStatics::SpawnActorInWorld()), finally restoring its state from the serialized data.
Parameters
[in]WorldContextObjectthe world context object
InActorthe actor to transfer
InWorldHandlethe new world of the input actor
OptionsOptions to customize the transfer (including setting a final transform for the actor).

Member Data Documentation

◆ OnAsyncLoadCompleted

FOnAsyncLoadCompletedDelegate UMultiWorldManager::OnAsyncLoadCompleted

Delegate called when the async load has terminated.

◆ OnWorldSwitched

FOnWorldSwitched UMultiWorldManager::OnWorldSwitched

Delegate called when the world is switched.


The documentation for this class was generated from the following file: