MultiWorld 1.9.1
Manage multiple isolated UWorld instances simultaneously in Unreal Engine, transferring player and actors between worlds.
|
The subsystem of the MultiWorld plugin. More...
#include <MultiWorldManager.h>
Public Member Functions | |
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam (FOnPreEndWorld, FMultiWorldHandle, WorldToEnd) | |
FOnPreEndWorld 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... | |
void | ForEachSecondaryWorld (TFunction< void(UWorld *)> Predicate) |
FMultiWorldHandle | GetActiveWorldHandle () const |
Return the world handle of the active World. More... | |
FMultiWorldHandle | GetMainWorldHandle () const |
Return the main world handle. More... | |
virtual TStatId | GetStatId () const override |
Override. 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... After you call this method, you can switch world calling SwitchWorld. More... | |
virtual bool | IsTickable () const override |
Override. More... | |
bool | IsValidHandle (const FMultiWorldHandle &InWorldHandle) const |
Return true if the input world handle is valid, false otherwise. More... | |
void | LoadWorld (TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams, TFunction< void(bool, FMultiWorldHandle, FMultiWorldLoadParameters)> OnCompleteCallback) |
Synchronously load a World into memory. More... | |
void | LoadWorldAsync (TSoftObjectPtr< UWorld > MapAsset, FMultiWorldLoadParameters InParams, TFunction< void(bool, FMultiWorldHandle, FMultiWorldLoadParameters)> OnCompleteCallback) |
Asynchronously load a World into memory. More... | |
void | RequestSwitchWorld (const FMultiWorldHandle &InWorldHandle, TFunction< void(bool)> OnSwitchWorldCompleted) |
Like SwitchWorld() but the switch will take place in the next frame and outside the worlds ticking. 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... | |
virtual void | Tick (float DeltaTime) override |
Override. 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 UMultiWorldManager & | GetInstance (const UObject *context) |
Return the multi world manager instance. More... | |
Public Attributes | |
FOnLoadWorldCompletedDelegate | OnLoadWorldCompleted |
Delegate called when the world load has terminated. More... | |
FOnPreEndWorld | OnPreWorldEnded |
Delegate called before the world is ended. More... | |
FOnWorldSwitched | OnWorldSwitched |
Delegate called when the world is switched. More... | |
Friends | |
class | UMultiWorldOverrides |
The subsystem of the MultiWorld plugin.
UMultiWorldManager::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam | ( | FOnPreEndWorld | , |
FMultiWorldHandle | , | ||
WorldToEnd | |||
) |
FOnPreEndWorld delegate signature.
UMultiWorldManager::DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams | ( | FOnWorldSwitched | , |
FMultiWorldHandle | , | ||
PreviousWorld | , | ||
FMultiWorldHandle | , | ||
CurrentWorld | |||
) |
FOnWorldSwitched delegate signature.
|
overridevirtual |
Override USubsystem::Deinitialize.
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. If InWorldHandle is the active world (equals to GetActiveWorldHandle()), ReturnToMainWorld is called automatically. Can NOT be called with the main world handle (GetMainWorldHandle() is not a valid param). In this case the call doesn't have any effect.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle |
void UMultiWorldManager::FixUpLocalPlayers | ( | ) |
Check local player setup and fixup if it's invalid.
It must be invoked by UGameViewportClient::LayoutPlayers
FMultiWorldHandle UMultiWorldManager::GetActiveWorldHandle | ( | ) | const |
Return the world handle of the active World.
[in] | WorldContextObject | the world context object |
|
static |
Return the multi world manager instance.
|
inline |
Return the main world handle.
The main world is the world loaded by the Unreal Engine itself.
[in] | WorldContextObject | the world context object |
|
overridevirtual |
Override.
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 UE5 to the function.
[in] | WorldContextObject | the world context object |
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.
[in] | WorldContextObject | the world context object |
[in] | WorldName | the name of the world to looking for |
|
overridevirtual |
Override USubsystem::Initialize.
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.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world to setup; it should came from the function LoadWorld. |
|
overridevirtual |
Override.
bool UMultiWorldManager::IsValidHandle | ( | const FMultiWorldHandle & | InWorldHandle | ) | const |
Return true if the input world handle is valid, false otherwise.
[in] | WorldContextObject | the world context object |
[in] | InWorldHandle | the world handle to check |
void UMultiWorldManager::LoadWorld | ( | TSoftObjectPtr< UWorld > | MapAsset, |
FMultiWorldLoadParameters | InParams, | ||
TFunction< void(bool, FMultiWorldHandle, FMultiWorldLoadParameters)> | OnCompleteCallback | ||
) |
Synchronously load a World into memory.
This method works like UMultiWorldStatics::LoadWorldWithDelegate(), but uses a C++ completion callback instead of a delegate.
void UMultiWorldManager::LoadWorldAsync | ( | TSoftObjectPtr< UWorld > | MapAsset, |
FMultiWorldLoadParameters | InParams, | ||
TFunction< void(bool, FMultiWorldHandle, FMultiWorldLoadParameters)> | OnCompleteCallback | ||
) |
Asynchronously load a World into memory.
This method works like UMultiWorldStatics::LoadWorldAsyncWithDelegate(), but uses a C++ completion callback instead of a delegate.
void UMultiWorldManager::RequestSwitchWorld | ( | const FMultiWorldHandle & | InWorldHandle, |
TFunction< void(bool)> | OnSwitchWorldCompleted | ||
) |
Like SwitchWorld() but the switch will take place in the next frame and outside the worlds ticking.
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle where to go |
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.
[in] | WorldContextObject | the world context object |
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).
True by default.
[in] | WorldContextObject | the world context object |
[in] | bAutoHandleWidgets | true if widgets are handled automatically for the main world, false otherwise. |
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).
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle for which to apply the setting | |
bShouldTick | the "tick-when-in-background" flag |
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.
[in] | WorldContextObject | the world context object |
[in] | ActorClass | the class to use to create the actor |
[in] | InWorldHandle | the world where to place the actor |
[in] | SpawnTransform | the absolute world transform of the new actor |
[in] | CollisionHandlingOverride | the strategy for handling the case of collision when the actor is spawned |
[in] | Owner | the owner of the new actor |
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()).
[in] | WorldContextObject | the world context object |
InWorldHandle | the world handle where to go |
|
overridevirtual |
Override.
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.
[in] | WorldContextObject | the world context object |
InActor | the actor to transfer | |
InWorldHandle | the new world of the input actor | |
Options | Options to customize the transfer (including setting a final transform for the actor). |
FOnLoadWorldCompletedDelegate UMultiWorldManager::OnLoadWorldCompleted |
Delegate called when the world load has terminated.
FOnPreEndWorld UMultiWorldManager::OnPreWorldEnded |
Delegate called before the world is ended.
FOnWorldSwitched UMultiWorldManager::OnWorldSwitched |
Delegate called when the world is switched.