-
Notifications
You must be signed in to change notification settings - Fork 6
World
On occasion, you may need access to the World itself. For this reason, Thyseus
also provides a World system parameter. In general, it is best to avoid
accessing the world itself - most APIs that require direct access to the world
are low-level and difficult to use correctly. Additionally, accessing the world
creates a hard sync point when multithreading - no other system can run while
the world is being accessed.
All data in the world is public.
The most common use case for accessing the world is running a custom schedule:
import { MySchedule } from './somewhere';
async function mySystem(world: World) {
const someCondition = true; // Complex logic here
if (someCondition) {
await world.runSchedule(MySchedule);
}
}When your system requires access to the world, you are guaranteed to always access the world from the main thread. World instances constructed in threads do not have access to all data (e.g., mainthread-only resources) and do not have the ability to communicate with threads other than the main thread. Additionally, most world methods depend on being called only on the main thread!
Getting Started
Introduction
Installation & Setup
Core Concepts
Entities
Components
Systems
Worlds
System Parameters
Queries
Resources
Events
World
Threads
Advanced Patterns
Custom System Parameters