Stratkit World Reference¶
This Module Contains components to hold references to ECS worlds on a bootstrap with two World. One Persistent and one Disposable after each Map Load.
On your bootstrap, when creating worlds, you can set Reference from one world to the other by doing:
MapWorld.EntityManager.CreateSingleton(new PersistentWorldReferenceComponent {
World = PersistentWorld,
});
PersistentWorld.EntityManager.SetSingletonSafely(new MapWorldReferenceComponent {
World = MapWorld,
});
Those worlds can later be retrieved from your systems by doing:
// From the Map World to get the PersistentWorld
EntityManager.GetSingleton<PersistentWorldReferenceComponent>().World;
// From the Persistent World to get the MapWorld
EntityManager.GetSingleton<MapWorldReferenceComponent>().World;
WorldReferenceUtils
class provides convenience methods to obtain references to the Map and Persistent worlds.
For the util to work correctly, references to the worlds need to be updated inside the appropriate ModuleBootstrap
implementation.