Documentation Index
Fetch the complete documentation index at: https://v5.rpgjs.dev/llms.txt
Use this file to discover all available pages before exploring further.
RpgMap
Reference for theRpgMap class.
Members
- addInDatabase
- applySyncToClient
- broadcast
- clear
- clearLighting
- clearPhysic
- clearWeather
- createDynamicEvent
- createDynamicWorldMaps
- createMovingHitbox
- createShape
- damageFormulas
- database
- dataIsReady$
- deleteWorldMaps
- events
- getBody
- getBodyPosition
- getEvent
- getEventBy
- getEvents
- getEventsBy
- getInWorldMaps
- getLighting
- getPlayer
- getPlayers
- getShape
- getShapes
- getTick
- getWeather
- getWorldMaps
- getWorldMapsManager
- globalConfig
- guiExit
- guiInteraction
- heightPx
- hooks
- id
- interceptorPacket
- isMoving
- maps
- nextTick
- off
- on
- onAction
- onInput
- onJoin
- onLeave
- patchLighting
- patchWeather
- players
- playSound
- processInput
- queryArea
- queryHitbox
- removeEvent
- removeFromWorldMaps
- removeInDatabase
- removeShape
- setAutoTick
- setBodyPosition
- setDay
- setInWorldMaps
- setLighting
- setNight
- setSync
- setWeather
- shakeMap
- showAnimation
- showComponentAnimation
- sounds
- stopSound
- tick$
- transitionLighting
- updateHitbox
- updateMap
- updateWorld
- updateWorldMaps
- widthPx
- worldX
- worldY
addInDatabase
Add data to the map’s database This method delegates to BaseRoom’s implementation to avoid code duplication.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:stringdata:anyoptions?:{ force?: boolean }
Returns
true if data was added, false if ignored (ID already exists)Examples
applySyncToClient
Apply sync to the client This method applies sync to the client by calling the$applySync() method.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Examples
broadcast
Broadcast a custom websocket event to all clients connected to this map. This is a convenience wrapper around$broadcast({ type, value }).
On the client side, receive the event by injecting WebSocketToken
and subscribing with socket.on(type, cb).
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
type:stringvalue?:any
Examples
clear
Clear all server resources and reset state This method should be called to clean up all server-side resources when shutting down or resetting the map. It stops the input processing loop and ensures that all subscriptions are properly cleaned up.Design
This method is used primarily in testing environments to ensure clean state between tests. It stops the tick subscription to prevent memory leaks.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Examples
clearLighting
Clear lighting for this map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
options?:LightingSetOptions
clearPhysic
Clear all physics content and reset to initial state This method completely clears the physics system by:- Removing all hitboxes (static and movable)
- Removing all zones
- Clearing all collision data and events
- Clearing all movement events and sliding data
- Unsubscribing from the tick subscription
- Resetting the physics engine to a clean state
- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Examples
clearWeather
Clear weather for this map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
options?:WeatherSetOptions
createDynamicEvent
Creates a dynamic event on the map This method handles both class-based events and object-based events with hooks. For class-based events, it creates a new instance of the class. For object-based events, it creates a dynamic class that extends RpgEvent and implements the hook methods from the object.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
eventObj:EventPosOptionoptions?:CreateDynamicEventOptions
Examples
createDynamicWorldMaps
Create a world manager dynamically Creates a new WorldMapsManager instance and configures it with the provided map configurations. This is used when loading world data from Tiled or other map editors.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
world:{ id?: string; maps: WorldMapConfig[] }
Returns
The newly created WorldMapsManager instanceExamples
createMovingHitbox
Create a temporary and moving hitbox on the map Allows to create a temporary hitbox that moves through multiple positions sequentially. For example, you can use it to explode a bomb and find all the affected players, or for a gameplay effect that should emit when entities enter a moving area. For instant melee/combat checks, preferqueryHitbox().
The method creates a zone sensor that moves through the specified hitbox positions
at the given speed, detecting collisions with players and events at each step.
- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
hitboxes:Array<{ x: number; y: number; width: number; height: number }>options?:{ speed?: number }
Returns
Observable that emits arrays of hit entities and completes when movement is finishedExamples
createShape
Create a shape dynamically on the map This method creates a static hitbox on the map that can be used for collision detection, area triggers, or visual boundaries. The shape is backed by the physics engine’s static entity system for accurate collision detection.Architecture
Creates a static entity (hitbox) in the physics engine at the specified position and size. The shape is stored internally and can be retrieved by name. When players or events collide with this hitbox, theonInShape and onOutShape hooks are automatically
triggered on both the player and the event.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
obj:{ x: number; y: number; width: number; height: number; name?: string; z?: number; color?: string; collision?: boolean; properties?: Record<string, any>; }
Returns
The created RpgShape instanceExamples
damageFormulas
Damage formulas configuration for the map Contains formulas for calculating damage from skills, physical attacks, critical hits, and element coefficients. Default formulas are merged with custom formulas when the map is loaded.- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
database
Signal containing the map’s database of items, classes, and other game data This database can be dynamically populated usingaddInDatabase() and
removeInDatabase() methods. It’s used to store game entities like items,
classes, skills, etc. that are specific to this map.
- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
Examples
dataIsReady$
BehaviorSubject that completes when the map data is ready This subject is used to signal when the map has finished loading all its data. Players wait for this to complete before the map is fully initialized.- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
Examples
deleteWorldMaps
Delete a world manager by id Removes the world maps manager from this map instance. Currently, only one world manager is supported, so this clears the single manager.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:string
Returns
true if the manager was deleted, false if it didn’t existExamples
events
Synchronized signal containing all events (NPCs, objects) on the map This signal is automatically synchronized with clients using- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
Examples
getBody
Get physics body (entity) for an id- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
id:string
getBodyPosition
Get body position in different modes- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
id:stringmode?:"center" | "top-left"
Returns
Position coordinates or undefined if entity not foundgetEvent
Get an event by its ID Returns the event with the specified ID, or undefined if not found. The return type can be narrowed using TypeScript generics.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
eventId:string
Returns
The event instance, or undefined if not foundExamples
getEventBy
Get the first event that matches a condition Searches through all events on the map and returns the first one that matches the provided callback function.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
cb:(event: RpgEvent) => boolean
Returns
The first matching event, or undefined if none foundExamples
getEvents
Get all events on the map Returns an array of all events (NPCs, objects, etc.) that are currently on this map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Returns
Array of all RpgEvent instances on the mapExamples
getEventsBy
Get all events that match a condition Searches through all events on the map and returns all events that match the provided callback function.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
cb:(event: RpgEvent) => boolean
Returns
Array of all matching eventsExamples
getInWorldMaps
Get attached World Recover the world attached to this map (undefined if no world attached)- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap - Since:
3.0.0-beta.8
Signature
Returns
The world maps manager instance if attached, otherwise undefinedExamples
getLighting
Get the current map lighting state.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
getPlayer
Get a player by their ID Returns the player with the specified ID, or undefined if not found.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
playerId:string
Returns
The player instance, or undefined if not foundExamples
getPlayers
Get all players currently on the map Returns an array of all players that are currently connected to this map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Returns
Array of all RpgPlayer instances on the mapExamples
getShape
Get a shape by its name Returns a shape with the specified name, or undefined if no shape with that name exists on the map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
name:string
Returns
The RpgShape instance, or undefined if not foundExamples
getShapes
Get all shapes on the map Returns an array of all shapes that have been created on this map, regardless of whether they are static shapes or player-attached shapes.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Returns
Array of RpgShape instancesExamples
getTick
Get the current physics tick- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Returns
Current tick numbergetWeather
Get the current map weather state.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
getWorldMaps
Get a world manager by id Returns the world maps manager for the given world ID. Currently, only one world manager is supported per map instance.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:string
Returns
The WorldMapsManager instance, or null if not initializedExamples
getWorldMapsManager
Get the world maps manager- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Returns
WorldMapsManager instance or null if not configuredExamples
globalConfig
Global configuration object for the map This object contains configuration settings that apply to the entire map. It’s populated from the map data whenupdateMap() is called.
- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
guiExit
Handle GUI exit from a player This method is called when a player closes or exits a GUI. It removes the GUI from the player’s active GUIs.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayer{ guiId, data }
Examples
guiInteraction
Handle GUI interaction from a player This method is called when a player interacts with a GUI element. It synchronizes the player’s changes to ensure the client state is up to date.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayervalue:{ guiId: string, name: string, data: any }
Examples
heightPx
Get the height of the map in pixels- Source:
packages/common/src/rooms/Map.ts - Kind:
getter - Defined in:
RpgCommonMap
Signature
Returns
The height of the map in pixels, or 0 if not loadedExamples
hooks
Get the hooks system for this map Returns the dependency-injected Hooks instance that allows you to trigger and listen to various game events.- Source:
packages/server/src/rooms/map.ts - Kind:
getter - Defined in:
RpgMap
Signature
Returns
The Hooks instance for this mapExamples
id
Get the unique identifier of the map- Source:
packages/common/src/rooms/Map.ts - Kind:
getter - Defined in:
RpgCommonMap
Signature
Returns
The map ID, or empty string if not loadedExamples
interceptorPacket
Intercepts and modifies packets before they are sent to clients This method is automatically called by- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayerpacket:anyconn:Parameters<RoomMethods["$send"]>[0]
Returns
Modified packet with timestamp and ack info, or null if player is invalidExamples
isMoving
Check if an entity is currently moving- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
id:string
Returns
Boolean indicating if the entity is in motionExamples
maps
Array of map configurations - can contain MapOptions objects or instances of map classes This array stores the configuration for this map and any related maps. It’s populated when the map is loaded viaupdateMap().
- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
nextTick
Manually trigger a single game tick This method allows you to manually advance the game by one tick (16ms at 60fps). It’s primarily useful for testing where you need precise control over when physics updates occur, rather than relying on the automatic tick$ subscription.Use Cases
- Testing: Control exactly when physics steps occur in unit tests
- Manual control: Step through game state manually for debugging
- Deterministic testing: Ensure consistent timing in test scenarios
Important
This method should NOT be used in production code alongside the automatictick$
subscription, as it will cause double-stepping. Use either:
-
Automatic ticks (via
loadPhysic()which subscribes totick$) -
Manual ticks (via
nextTick()withoutloadPhysic()subscription) -
Source:
packages/common/src/rooms/Map.ts -
Kind:
method -
Defined in:
RpgCommonMap
Signature
Parameters
deltaMs?:number
Returns
Number of physics ticks executedExamples
off
Remove all listeners for a custom client event on this map.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
type:string
on
Listen to custom websocket events sent by clients on this map. The callback receives the player who sent the event and the payload. This is useful for map-wide custom interactions that are not covered by built-in actions such as movement, GUI events, or the action button.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
type:stringcb:(player: RpgPlayer, data: any) => void | Promise<void>
Examples
onAction
Handle action input from a player This method is called when a player performs an action (like pressing a button). It checks for collisions with events and triggers the appropriate hooks.Architecture
- Gets all entities colliding with the player
- Triggers
onActionhook on colliding events - Triggers
onInputhook on the player
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayeraction:any
Examples
onInput
Handle movement input from a player This method is called when a player sends movement input from the client. It queues the input for processing by the game loop. Inputs are processed with frame numbers to ensure proper ordering and client-side prediction.Architecture
-
Inputs are queued in
player.pendingInputs - Duplicate frames are skipped to prevent processing the same input twice
- Inputs are processed asynchronously by the game loop
-
Source:
packages/server/src/rooms/map.ts -
Kind:
method -
Defined in:
RpgMap
Signature
Parameters
player:RpgPlayerinput:any
Examples
onJoin
Called when a player joins the map This method is automatically called by- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayerconn:Parameters<RoomMethods["$send"]>[0]
Examples
onLeave
Called when a player leaves the map This method is automatically called by- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
player:RpgPlayerconn:Parameters<RoomMethods["$send"]>[0]
Examples
patchLighting
Patch the current lighting state. Nestedambient, sun, and shadows values are merged.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
patch:Partial<LightingState>options?:LightingSetOptions
patchWeather
Patch the current weather state. Nestedparams values are merged.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
patch:Partial<WeatherState>options?:WeatherSetOptions
players
Synchronized signal containing all players currently on the map This signal is automatically synchronized with clients using- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
Examples
playSound
Play a sound for all players on the map This method plays a sound for all players currently on the map by iterating over each player and callingplayer.playSound(). The sound must be defined
on the client side (in the client module configuration).
This is ideal for environmental sounds, battle music, or map-wide events that
all players should hear simultaneously.
Design
Iterates over all players on the map and callsplayer.playSound() for each one.
This avoids code duplication and reuses the existing player sound logic.
For player-specific sounds, use player.playSound() directly.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
soundId:stringoptions?:{ volume?: number; loop?: boolean }
Examples
processInput
Process pending inputs for a player with anti-cheat validation This method processes pending inputs for a player while performing anti-cheat validation to prevent time manipulation and frame skipping. It validates the time deltas between inputs and ensures they are within acceptable ranges. To preserve movement itinerary under network bursts, the number of inputs processed per call is capped.Architecture
Important: This method only updates entity velocities - it does NOT step the physics engine. Physics simulation is handled centrally by the game loop (tick$ -> runFixedTicks). This ensures:
- Consistent physics timing (60fps fixed timestep)
- No double-stepping when multiple inputs are processed
- Deterministic physics regardless of input frequency
-
Source:
packages/server/src/rooms/map.ts -
Kind:
method -
Defined in:
RpgMap
Signature
Parameters
playerId:stringcontrols?:Controls
Returns
Promise containing the player and processed input stringsExamples
queryArea
Query players, events, and optional custom targets inside an arbitrary area.queryArea() is a low-level selection primitive. It uses the shape bounds as
a broad phase, then delegates the precise inclusion logic to
shape.contains(). Built-in helpers such as AreaShape.circle() and
AreaShape.cross() are conveniences over the same shape contract.
The method does not apply gameplay effects. Use the returned hits for damage,
healing, target selection, AI, traps, previews, or any custom gameplay.
In a networked game, apply those gameplay effects on the server so the
authoritative state remains synchronized.
Options:
center: point or object withx,y, and optionalhitbox; objects are resolved to their hitbox center.shape: area shape used for broad-phase bounds and precise inclusion.targets:"players","events","custom", an array of them, or"all". Defaults to players and events, plus custom targets whencustomTargetsis provided.customTargets: plain objects to include in the query. They should exposexandy, and may exposeid,width/height, orhitbox.excludeIds: target ids to ignore, typically the caster or owner.filter: final predicate called beforeshape.contains().
AreaShape.circle({ radius, offset? })AreaShape.rect({ width, height, offset?, angle? })AreaShape.line({ length, thickness, direction, offset? })AreaShape.cross({ armLength, thickness, offset? })AreaShape.composite([shapeA, shapeB])AreaShape.custom({ bounds, contains, distance?, maxDistance? })
target, id, kind, x, y, bounds, distance,
distanceRatio, and falloff.
distanceRatio is clamped between 0 and 1. falloff.linear() returns
strong values near the center and weaker values near the edge, which is useful
for explosions and other radial effects.
- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
options:MapAreaQueryOptions<TCustom>
Examples
queryHitbox
Query players and events whose physics bodies overlap a rectangular hitbox. UnlikecreateMovingHitbox(), this is an immediate deterministic query. It
is intended for melee attacks, AoE checks, and other server-authoritative
gameplay that needs to hit entities already inside the area.
- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
rect:MapHitboxQueryRectoptions?:MapHitboxQueryOptions
removeEvent
Remove an event from the map Removes the event with the specified ID from the map. The event will be removed from the synchronized events signal, causing it to disappear on all clients.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
eventId:string
Examples
removeFromWorldMaps
Remove this map from the world Remove this map from the world- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap - Since:
3.0.0-beta.8
Signature
Returns
True if removed, false if not found, undefined if no world attachedExamples
removeInDatabase
Remove data from the map’s database This method delegates to BaseRoom’s implementation to avoid code duplication.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:string
Returns
true if data was removed, false if ID didn’t existExamples
removeShape
Delete a shape from the map Removes a shape by its name and cleans up the associated static hitbox entity. If the shape doesn’t exist, the method does nothing.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
name:string
Returns
voidExamples
setAutoTick
Enable or disable automatic tick processing When disabled, the input processing loop will not run automatically. This is useful for unit tests where you want manual control over when inputs are processed.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
enabled:boolean
Examples
setBodyPosition
Set body position- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
id:stringx:numbery:numbermode?:"center" | "top-left"
Returns
True if position was set successfullysetDay
Apply the default daytime lighting preset.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
options?:LightingSetOptions
setInWorldMaps
Assign the map to a world Assign the map to a world- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap - Since:
3.0.0-beta.8
Signature
Parameters
worldMap:RpgWorldMaps
Examples
setLighting
Set the full lighting state for this map. Whensync is true (default), all connected clients receive the new lighting.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
next:LightingState | nulloptions?:LightingSetOptions
setNight
Apply the default nighttime lighting preset.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
options?:LightingSetOptions
setSync
Configure runtime synchronized properties on the map This method allows you to dynamically add synchronized properties to the map that will be automatically synced with clients. The schema follows the same structure as module properties with$initial, $syncWithClient, and $permanent options.
Architecture
- Reads a schema object shaped like module props
- Creates typed sync signals with
-
Source:
packages/server/src/rooms/map.ts -
Kind:
method -
Defined in:
RpgMap
Signature
Parameters
schema:Record<string, any>
Examples
setWeather
Set the full weather state for this map. Whensync is true (default), all connected clients receive the new weather.
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
next:WeatherState | nulloptions?:WeatherSetOptions
shakeMap
Shake the map for all players This method triggers a shake animation on the map for all players currently on the map. The shake effect creates a visual feedback that can be used for earthquakes, explosions, impacts, or any dramatic event that should affect the entire map visually.Architecture
Broadcasts a shake event to all clients connected to the map. Each client receives the shake configuration and triggers the shake animation on the map container using Canvas Engine’s shake directive.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
options?:{ intensity?: number; duration?: number; frequency?: number; direction?: 'x' | 'y' | 'both'; }
Examples
showAnimation
Display a spritesheet animation at a specific position on the map This method displays a temporary visual animation using a spritesheet at any location on the map. It’s a convenience method that internally uses showComponentAnimation with the built-in ‘animation’ component. This is useful for spell effects, environmental animations, or any visual feedback that uses predefined spritesheets.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
position:{ x: number, y: number }graphic:stringanimationName?:string
Examples
showComponentAnimation
Display a component animation at a specific position on the map This method broadcasts a component animation to all clients connected to the map, allowing temporary visual effects to be displayed at any location on the map. Component animations are custom Canvas Engine components that can display complex effects with custom logic and parameters.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:stringposition:{ x: number, y: number }params:any
Examples
sounds
Array of sound IDs to play when players join the map These sounds are automatically played for each player when they join the map. Sounds must be defined on the client side.- Source:
packages/server/src/rooms/map.ts - Kind:
property - Defined in:
RpgMap
Signature
Examples
stopSound
Stop a sound for all players on the map This method stops a sound that was previously started withmap.playSound()
for all players on the map by iterating over each player and calling player.stopSound().
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
soundId:string
Examples
tick$
Observable representing the game loop tick This observable emits the current timestamp every 16ms (approximately 60fps). It’s shared using the share() operator, meaning that all subscribers will receive events from a single interval rather than creating multiple intervals.Physics Loop Architecture
The physics simulation is centralized in this game loop:- Input Processing (
processInput): Only updates entity velocities, does NOT step physics - Game Loop (
tick$->runFixedTicks): Executes physics simulation with fixed timestep - Fixed Timestep Pattern: Accumulator-based approach ensures deterministic physics
- Source:
packages/common/src/rooms/Map.ts - Kind:
property - Defined in:
RpgCommonMap
Signature
Examples
transitionLighting
Transition lighting over time by broadcasting intermediate lighting states.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
toLighting:Partial<LightingState>options?:LightingTransitionOptions & LightingSetOptions
updateHitbox
Update hitbox position and size- Source:
packages/common/src/rooms/Map.ts - Kind:
method - Defined in:
RpgCommonMap
Signature
Parameters
id:stringx:numbery:numberwidth?:numberheight?:number
Returns
True if hitbox was updated successfullyupdateMap
Update the map configuration and data This endpoint receives map data from the client and initializes the map. It loads the map configuration, damage formulas, events, and physics.Architecture
- Validates the request body using MapUpdateSchema
- Updates map data, global config, and damage formulas
- Merges events and sounds from map configuration
- Triggers hooks for map loading
- Loads physics engine
- Creates all events on the map
- Completes the dataIsReady$ subject
- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
request:Request
Returns
Promise that resolves when the map is fully loadedExamples
updateWorld
Update (or create) a world configuration and propagate to all maps in that world This endpoint receives world map configuration data (typically from Tiled world import) and creates or updates the world manager. The world ID is extracted from the URL path.Architecture
- Extracts world ID from URL path parameter
- Normalizes input to array of WorldMapConfig
- Ensures all required map properties are present (width, height, tile sizes)
- Creates or updates the world manager
-
{ id: string, maps: WorldMapConfig[] } -
WorldMapConfig[] -
Source:
packages/server/src/rooms/map.ts -
Kind:
method -
Defined in:
RpgMap
Signature
Parameters
request:Request
Returns
Promise resolving to{ ok: true } when complete
Examples
updateWorldMaps
Update world maps by id. Auto-create when missing. Updates the world maps configuration. If the world manager doesn’t exist, it is automatically created. This is useful for dynamically loading world data or updating map positions.- Source:
packages/server/src/rooms/map.ts - Kind:
method - Defined in:
RpgMap
Signature
Parameters
id:stringmaps:WorldMapConfig[]
Returns
Promise that resolves when the update is completeExamples
widthPx
Get the width of the map in pixels- Source:
packages/common/src/rooms/Map.ts - Kind:
getter - Defined in:
RpgCommonMap
Signature
Returns
The width of the map in pixels, or 0 if not loadedExamples
worldX
Get the X position of this map in the world coordinate system This is used when maps are part of a larger world map. The world position indicates where this map is located relative to other maps.- Source:
packages/common/src/rooms/Map.ts - Kind:
getter - Defined in:
RpgCommonMap
Signature
Returns
The X position in world coordinates, or 0 if not in a worldExamples
worldY
Get the Y position of this map in the world coordinate system This is used when maps are part of a larger world map. The world position indicates where this map is located relative to other maps.- Source:
packages/common/src/rooms/Map.ts - Kind:
getter - Defined in:
RpgCommonMap