MWorld
MWorld is a GC root: the mark phase reaches every spawned actor through the MPROPERTY m_actors list (and from there components via the actors' own MPROPERTY fields). An actor's Outer pointing at the world does NOT keep the actor alive — only the m_actors edge does.
- Module
- Game
- Header
#include "Game/MWorld.h"- Namespace
Mowo- Reflection
- Reflected by MowoHeaderTool
Constructors
Public functions
| Returns | Name | Description |
|---|---|---|
MWorld& | operator= | |
TWeakObjectPtr<T> | SpawnActor | Spawning Construct + register an actor in this world. |
AActor* | SpawnActorByClass | Spawn by runtime class (hot-reload restore, scene-deserialized actors). |
AActor* | SpawnActorFromTemplate | Spawn an instance of a registered template (archetype instancing). |
AGameMode* | InitializeGameMode | Game framework Spawn the game mode (cls, or base AGameMode when null), call InitGame + StartMatch. |
AGameMode* | GetGameMode | |
void | BeginPlay | Registration and play are separate transitions. |
void | EndPlay | |
bool | HasBegunPlay | |
void | Tick | Lifecycle Whole-frame tick: BeginTickFrame, all four groups in order, then SyncActorTransforms. |
void | BeginTickFrame | The frame-ordered pieces of Tick, so the caller can interleave a physics step. |
void | TickGroup | |
FTimerManager& | GetTimerManager | World-scoped timers (UE parity): set here, a timer dies WITH the world — it can never fire into a torn-down actor the way an engine-scope FTimerManager::Get() timer can. |
float | GetTimeSeconds | Time (UWorld parity). |
float | GetRealTimeSeconds | |
float | GetDeltaSeconds | |
uint64_t | GetFrameNumber | |
float | TimeSince | Game seconds since a stamp taken from GetTimeSeconds(). |
float | GetTimeDilation | |
void | SetTimeDilation | |
float | GetEffectiveTimeDilation | The dilation actually applied to this frame's tick delta: zero while paused. |
bool | IsPaused | |
void | SetPaused | |
void | SetWorldPaused | Per-WORLD pause/dilation — a second axis on top of the process-global FTime clock the methods above mirror (TimeTests pins that mirroring). |
bool | IsWorldPaused | |
void | SetWorldTimeDilation | |
float | GetWorldTimeDilation | |
void | SyncActorTransforms | Push each actor's root world transform into its backing entity. |
void | Destroy | Despawn an actor: calls EndPlay, removes it from the list, deletes it. |
bool | EjectActor | |
bool | AdoptActor | |
void | NotifyBackingEntityDestroyed | The scene deleted an entity out from under its actor (outliner delete): tear the actor down too, without re-entering the entity destruction hooks. |
const std::vector<AActor*>& | GetActors | Removal leaves a null hole so it costs no search and no shift; the holes are squeezed out here and once a frame by the tick schedule, so a caller never sees one. |
void | InvalidateTickLists | The tick schedule is rebuilt once a frame from canEverTick, primaryTickGroup and the components' tickGroupOverride, which are plain fields. |
void | NotifyActorComponentAdded | AActor::AddComponent reports here so a component added mid-frame with a tickGroupOverride still ticks in this frame's pass, as it did when every pass walked the whole actor list. |
AActor* | FindActorByEntity | Resolve the actor backing an ECS entity, or nullptr when the entity is plain ECS data (or its actor is pending kill). |
World* | GetECSWorld | ECS bridge Backing ECS world — systems that prefer flat iteration of typed components read from here. |
void | SetECSWorld | Also tells FViewerRegistry, so a scene system holding only the ECS world can still ask where the viewers are. |
EWorldType | GetWorldType | World type. |
void | SetWorldType | |
bool | IsEditorWorld | The level as authored: actors here tick only through TickInEditor. |
bool | IsPlayWorld | A world that plays: a PIE copy or a game. |
void | TickInEditor | Edit-mode tick: gives each actor that opted in (AActor::ShouldTickInEditor) one TickInEditor(dt), round-robin from where the previous frame stopped, and stops early once ed.TickBudgetMs is spent, so a slow generator cannot stall the editor frame; the actors it skipped run first next frame. |
const FEditorTickStats& | GetEditorTickStats | |
void | AddPinWire | |
void | ClearPinWires | |
const std::vector<FPinWire>& | GetPinWires | |
void | FirePin | |
void | SetBackingEntityHooks | |
T* | GetSubsystem | World subsystems (UE-style) Auto-instanced MWorldSubsystem singletons. |
Function details
MWorld
MWorld()~MWorld
~MWorld() overrideMWorld
MWorld(const MWorld&) = deleteoperator=
MWorld& operator=(const MWorld&) = deleteSpawnActor
template<typename T, typename... Args> TWeakObjectPtr<T> SpawnActor(Args&&... args)Spawning Construct + register an actor in this world. The world becomes the actor's outer; BeginPlay fires (or is queued if tick is mid-frame). Returns a TWeakObjectPtr so callers can detect post-GC sweep — DON'T store as raw AActor*.
SpawnActorByClass
AActor* SpawnActorByClass(MClass* cls, const std::function<void(AActor*)>& preRegister = {}, const FActorSpawnTransform* initialTransform = nullptr)Spawn by runtime class (hot-reload restore, scene-deserialized actors). Returns nullptr when cls is null, lacks a codegen factory, or isn't an AActor subclass. preRegister runs after construction (default subobjects exist) but BEFORE RegisterActor — restore property values there so the ECS mirror publishes them. initialTransform is applied during registration, ahead of OnConstruct and BeginPlay: onto the root component when the actor has one, else onto the backing TransformComponent the moment it exists.
SpawnActorFromTemplate
AActor* SpawnActorFromTemplate(FName templateName, const std::function<void(AActor*)>& preRegister = {}, const FActorSpawnTransform* initialTransform = nullptr)Spawn an instance of a registered template (archetype instancing). The instance derives its defaults from the template rather than the class CDO and remembers the template's name, so the scene writer diffs it against the template. Returns nullptr when the template is not registered in FActorTemplateRegistry.
InitializeGameMode
AGameMode* InitializeGameMode(MClass* gameModeClass = nullptr, bool spawnLocalPlayer = true)Game framework Spawn the game mode (cls, or base AGameMode when null), call InitGame + StartMatch. One per world; repeated calls return the existing mode. Typically invoked by the runtime after the start scene loads, with the class named in project settings. spawnLocalPlayer false = dedicated server: no local PlayerController or default pawn; connections get pawns through AGameMode::RestartPlayer.
GetGameMode
AGameMode* GetGameMode() constBeginPlay
void BeginPlay()Registration and play are separate transitions. Registering an actor publishes its ECS mirror — that is what makes a placed actor visible and inspectable in the editor, and it happens at scene load. BeginPlay fans out only here, when the host enters play (Scene::OnRuntimeStart / OnSimulationStart). Both are idempotent and each actor begins play at most once per play session: an actor spawned mid-play begins play during its registration and is skipped by a later world BeginPlay, and a Play → Stop → Play cycle re-runs BeginPlay exactly once per cycle.
EndPlay
void EndPlay()HasBegunPlay
bool HasBegunPlay() const noexceptTick
void Tick(float deltaSeconds)Lifecycle Whole-frame tick: BeginTickFrame, all four groups in order, then SyncActorTransforms. Correct only when nothing needs to run BETWEEN groups — a host that steps physics mid-frame drives the pieces below instead (Scene::OnUpdateRuntime does exactly that, so PostPhysics actors observe post-physics poses). Begins play first when it has not begun. This path is a game path by construction — an editor host drives the pieces below and calls BeginPlay itself — so a headless driver that only ticks still gets the lifecycle it expects rather than silently unplayed actors.
BeginTickFrame
void BeginTickFrame()The frame-ordered pieces of Tick, so the caller can interleave a physics step. Call order per frame: BeginTickFrame → TickGroup (PrePhysics) → TickGroup(DuringPhysics) → SyncActorTransforms(false) → physics → TickGroup(PostPhysics) → TickGroup(PostUpdateWork) → SyncActorTransforms(true). BeginTickFrame advances the frame stamp the prerequisite resolver dedups against — exactly once per frame, never per group.
TickGroup
void TickGroup(AActor::ETickGroup group, float deltaSeconds)GetTimerManager
FTimerManager& GetTimerManager()World-scoped timers (UE parity): set here, a timer dies WITH the world — it can never fire into a torn-down actor the way an engine-scope FTimerManager::Get() timer can. Ticked at the start of the PrePhysics group, so it pauses when the world stops ticking.
GetTimeSeconds
float GetTimeSeconds() constTime (UWorld parity). All of it reads the process frame clock in Core — a world does not own a clock, it presents one — so the numbers agree with FTime, FApp and every other module that asks. Defined out of line so a caller in another DLL resolves them here rather than inlining its own read.
GetRealTimeSeconds
float GetRealTimeSeconds() constGetDeltaSeconds
float GetDeltaSeconds() constGetFrameNumber
uint64_t GetFrameNumber() constTimeSince
float TimeSince(float gameTimeSeconds) constGame seconds since a stamp taken from GetTimeSeconds(). Does not advance while paused.
GetTimeDilation
float GetTimeDilation() constSetTimeDilation
void SetTimeDilation(float dilation)GetEffectiveTimeDilation
float GetEffectiveTimeDilation() constThe dilation actually applied to this frame's tick delta: zero while paused.
IsPaused
bool IsPaused() constSetPaused
void SetPaused(bool paused)SetWorldPaused
void SetWorldPaused(bool paused)Per-WORLD pause/dilation — a second axis on top of the process-global FTime clock the methods above mirror (TimeTests pins that mirroring). This axis lets two worlds differ: a paused PIE world under a live editor world, a slow-motion cutscene world beside a real-time UI world. Applied inside TickGroup, so both MWorld::Tick and hosts that drive TickGroup directly (Scene::OnUpdateRuntime) honour it; a paused world fires no timers and ticks no actors.
IsWorldPaused
bool IsWorldPaused() constSetWorldTimeDilation
void SetWorldTimeDilation(float dilation)GetWorldTimeDilation
float GetWorldTimeDilation() constSyncActorTransforms
void SyncActorTransforms(bool onlyChanged = false)Push each actor's root world transform into its backing entity. onlyChanged writes only actors whose root moved since the previous sync this frame — which is what lets the post-physics sync land PostPhysics actor movement WITHOUT clobbering the poses physics just wrote for actors that did not move themselves.
Destroy
void Destroy(AActor* actor)Despawn an actor: calls EndPlay, removes it from the list, deletes it.
EjectActor
bool EjectActor(AActor* actor)AdoptActor
bool AdoptActor(AActor* actor)NotifyBackingEntityDestroyed
void NotifyBackingEntityDestroyed(EntityID entity)The scene deleted an entity out from under its actor (outliner delete): tear the actor down too, without re-entering the entity destruction hooks. No-op for plain entities.
GetActors
const std::vector<AActor*>& GetActors() constRemoval leaves a null hole so it costs no search and no shift; the holes are squeezed out here and once a frame by the tick schedule, so a caller never sees one.
InvalidateTickLists
void InvalidateTickLists()The tick schedule is rebuilt once a frame from canEverTick, primaryTickGroup and the components' tickGroupOverride, which are plain fields. A mid-frame change that takes an actor OUT of a group applies at once (dispatch re-checks the fields); one that puts it INTO a group still to run this frame needs this call, or it lands next frame. Spawning, destroying and AddComponent invalidate on their own.
NotifyActorComponentAdded
void NotifyActorComponentAdded(AActor* actor, MActorComponent* component)AActor::AddComponent reports here so a component added mid-frame with a tickGroupOverride still ticks in this frame's pass, as it did when every pass walked the whole actor list.
FindActorByEntity
AActor* FindActorByEntity(EntityID entity) constResolve the actor backing an ECS entity, or nullptr when the entity is plain ECS data (or its actor is pending kill). This is the address translation the networking layer needs: replication, relevancy and RPC routing all key off the entity carrying NetworkObjectComponent, and this is what turns one of those ids back into the gameplay object that owns it.
GetECSWorld
World* GetECSWorld() constECS bridge Backing ECS world — systems that prefer flat iteration of typed components read from here. Set by Scene during world initialisation.
SetECSWorld
void SetECSWorld(World* w)Also tells FViewerRegistry, so a scene system holding only the ECS world can still ask where the viewers are.
GetWorldType
EWorldType GetWorldType() const noexceptWorld type. The Scene that owns the world keeps it current: Editor while the level is ticked in edit mode, PIE for a play copy, Game otherwise.
SetWorldType
void SetWorldType(EWorldType type) noexceptIsEditorWorld
bool IsEditorWorld() const noexceptThe level as authored: actors here tick only through TickInEditor.
IsPlayWorld
bool IsPlayWorld() const noexceptA world that plays: a PIE copy or a game. Opposite of IsEditorWorld.
TickInEditor
void TickInEditor(float deltaSeconds)Edit-mode tick: gives each actor that opted in (AActor::ShouldTickInEditor) one TickInEditor(dt), round-robin from where the previous frame stopped, and stops early once ed.TickBudgetMs is spent, so a slow generator cannot stall the editor frame; the actors it skipped run first next frame. No-op unless this is an editor world: a PIE copy and a game never call it.
GetEditorTickStats
const FEditorTickStats& GetEditorTickStats() const noexceptAddPinWire
void AddPinWire(EntityID srcEntity, const std::string& srcPin, EntityID dstEntity, const std::string& dstPin)ClearPinWires
void ClearPinWires()GetPinWires
const std::vector<FPinWire>& GetPinWires() constFirePin
void FirePin(EntityID srcEntity, const std::string& pin, const struct VisualScriptValue& payload)SetBackingEntityHooks
void SetBackingEntityHooks(FBackingEntityHooks hooks)GetSubsystem
template<typename T> T* GetSubsystem()World subsystems (UE-style) Auto-instanced MWorldSubsystem singletons. One per world; Initialize(this) fires on first GetSubsystem<T>(). Lifetime = world lifetime; ~MWorld destroys all.