UNPKG

hytopia

Version:

The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.

640 lines (282 loc) 7.63 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [server](./server.md) &gt; [World](./server.world.md) ## World class Represents a world in the game server. **Signature:** ```typescript export default class World extends EventRouter implements protocol.Serializable ``` **Extends:** [EventRouter](./server.eventrouter.md) **Implements:** protocol.Serializable ## Remarks Worlds are the primary container for game objects and interactions. A game can have multiple worlds running simultaneously, each uniquely isolated from each other. Players who have joined your server can be assigned to a world programmatically by your game logic if desired. This is useful for things like mini-games, or complex dungeons with multiple floors that can be optimized by splitting them into seperate world or "room" simulations, etc. In most cases, the single automatically created default world is all you need, but this flexibility is available for more complex games. <h2>Events</h2> This class is an EventRouter, and instances of it emit events with payloads listed under [WorldEventPayloads](./server.worldeventpayloads.md) ## Example ```typescript const world = new World({ id: 1, name: 'My World', skyboxUri: 'skyboxes/partly-cloudy', }); ``` ## Constructors <table><thead><tr><th> Constructor </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [(constructor)(options)](./server.world._constructor_.md) </td><td> </td><td> Constructs a new instance of the `World` class </td></tr> </tbody></table> ## Properties <table><thead><tr><th> Property </th><th> Modifiers </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> [ambientLightColor](./server.world.ambientlightcolor.md) </td><td> `readonly` </td><td> [RgbColor](./server.rgbcolor.md) </td><td> The color of the ambient light. </td></tr> <tr><td> [ambientLightIntensity](./server.world.ambientlightintensity.md) </td><td> `readonly` </td><td> number </td><td> The intensity of the ambient light. </td></tr> <tr><td> [audioManager](./server.world.audiomanager.md) </td><td> `readonly` </td><td> [AudioManager](./server.audiomanager.md) </td><td> The audio manager for the world. </td></tr> <tr><td> [blockTypeRegistry](./server.world.blocktyperegistry.md) </td><td> `readonly` </td><td> [BlockTypeRegistry](./server.blocktyperegistry.md) </td><td> The block type registry for the world. </td></tr> <tr><td> [chatManager](./server.world.chatmanager.md) </td><td> `readonly` </td><td> [ChatManager](./server.chatmanager.md) </td><td> The chat manager for the world. </td></tr> <tr><td> [chunkLattice](./server.world.chunklattice.md) </td><td> `readonly` </td><td> [ChunkLattice](./server.chunklattice.md) </td><td> The chunk lattice for the world. </td></tr> <tr><td> [directionalLightColor](./server.world.directionallightcolor.md) </td><td> `readonly` </td><td> [RgbColor](./server.rgbcolor.md) </td><td> The color of the directional light. </td></tr> <tr><td> [directionalLightIntensity](./server.world.directionallightintensity.md) </td><td> `readonly` </td><td> number </td><td> The intensity of the directional light. </td></tr> <tr><td> [directionalLightPosition](./server.world.directionallightposition.md) </td><td> `readonly` </td><td> [Vector3Like](./server.vector3like.md) </td><td> The position the directional light originates from. </td></tr> <tr><td> [entityManager](./server.world.entitymanager.md) </td><td> `readonly` </td><td> [EntityManager](./server.entitymanager.md) </td><td> The entity manager for the world. </td></tr> <tr><td> [id](./server.world.id.md) </td><td> `readonly` </td><td> number </td><td> The unique ID of the world. </td></tr> <tr><td> [lightManager](./server.world.lightmanager.md) </td><td> `readonly` </td><td> [LightManager](./server.lightmanager.md) </td><td> The light manager for the world. </td></tr> <tr><td> [loop](./server.world.loop.md) </td><td> `readonly` </td><td> [WorldLoop](./server.worldloop.md) </td><td> The world loop for the world. </td></tr> <tr><td> [name](./server.world.name.md) </td><td> `readonly` </td><td> string </td><td> The name of the world. </td></tr> <tr><td> [sceneUIManager](./server.world.sceneuimanager.md) </td><td> `readonly` </td><td> [SceneUIManager](./server.sceneuimanager.md) </td><td> The scene UI manager for the world. </td></tr> <tr><td> [simulation](./server.world.simulation.md) </td><td> `readonly` </td><td> [Simulation](./server.simulation.md) </td><td> The simulation for the world. </td></tr> <tr><td> [skyboxIntensity](./server.world.skyboxintensity.md) </td><td> `readonly` </td><td> number </td><td> The intensity of the world's skybox brightness. </td></tr> <tr><td> [skyboxUri](./server.world.skyboxuri.md) </td><td> `readonly` </td><td> string </td><td> The URI of the skybox cubemap for the world. </td></tr> <tr><td> [tag](./server.world.tag.md) </td><td> `readonly` </td><td> string \| undefined </td><td> An arbitrary identifier tag of the world. Useful for your own logic. </td></tr> </tbody></table> ## Methods <table><thead><tr><th> Method </th><th> Modifiers </th><th> Description </th></tr></thead> <tbody><tr><td> [loadMap(map)](./server.world.loadmap.md) </td><td> </td><td> Loads a map into the world, clearing any prior map. </td></tr> <tr><td> [setAmbientLightColor(color)](./server.world.setambientlightcolor.md) </td><td> </td><td> Sets the color of the world's ambient light. </td></tr> <tr><td> [setAmbientLightIntensity(intensity)](./server.world.setambientlightintensity.md) </td><td> </td><td> Sets the intensity of the world's ambient light. </td></tr> <tr><td> [setDirectionalLightColor(color)](./server.world.setdirectionallightcolor.md) </td><td> </td><td> Sets the color of the world's directional light. </td></tr> <tr><td> [setDirectionalLightIntensity(intensity)](./server.world.setdirectionallightintensity.md) </td><td> </td><td> Sets the intensity of the world's directional light. </td></tr> <tr><td> [setDirectionalLightPosition(position)](./server.world.setdirectionallightposition.md) </td><td> </td><td> Sets the position the world's directional light originates from. </td></tr> <tr><td> [setSkyboxIntensity(intensity)](./server.world.setskyboxintensity.md) </td><td> </td><td> Sets the intensity of the world's skybox brightness. </td></tr> <tr><td> [start()](./server.world.start.md) </td><td> </td><td> Starts the world loop, which begins ticking physics, entities, etc. </td></tr> <tr><td> [stop()](./server.world.stop.md) </td><td> </td><td> Stops the world loop, which stops ticking physics, entities, etc. </td></tr> </tbody></table>