hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
171 lines (78 loc) • 2.42 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [WorldLoop](./server.worldloop.md)
## WorldLoop class
Manages the tick loop for a world.
When to use: advanced scheduling or instrumentation of a world's tick cycle. Do NOT use for: normal lifecycle control—use `World.start` and `World.stop`<!-- -->.
**Signature:**
```typescript
export default class WorldLoop extends EventRouter
```
**Extends:** [EventRouter](./server.eventrouter.md)
## Remarks
The world loop automatically handles ticking physics, entities, and other world logic.
The internal order of tick operations is: 1) Tick entity logic 2) Step physics 3) Check and emit entity updates 4) Synchronize network packets with player clients
<h2>Events</h2>
This class is an EventRouter, and instances of it emit events with payloads listed under `WorldLoopEventPayloads`<!-- -->.
\*\*Category:\*\* Core
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WorldLoop` class.
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[currentTick](./server.worldloop.currenttick.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The current tick count of the world loop.
\*\*Category:\*\* Core
</td></tr>
<tr><td>
[isStarted](./server.worldloop.isstarted.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the world loop is started.
\*\*Category:\*\* Core
</td></tr>
<tr><td>
[nextTickMs](./server.worldloop.nexttickms.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The next scheduled tick time in milliseconds.
\*\*Category:\*\* Core
</td></tr>
<tr><td>
[timestepS](./server.worldloop.timesteps.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The fixed timestep of the world loop in seconds.
\*\*Category:\*\* Core
</td></tr>
<tr><td>
[world](./server.worldloop.world.md)
</td><td>
`readonly`
</td><td>
[World](./server.world.md)
</td><td>
The world this loop manages.
\*\*Category:\*\* Core
</td></tr>
</tbody></table>