Skip to content

Status ​

Overview ​

This section covers methods for querying the current state of a Payload instance.

NOTE

All code examples on this page assume you have an existing instance of Payload retrieved from RoomLoader.Load() and stored in a payload variable.

Methods ​

.IsInView() ​

payload.IsInView([camera], [padding]) ➜ Bool

Returns whether the loaded room overlaps the given camera's view (true) or not (false). Handles any combination of camera and loaded room positioning, scaling, and rotation.

Positive padding expands the view bounds outward, negative padding shrinks them inward.

ParameterTypeDescription
[camera]Id.CameraThe camera to check against [Default: view_camera[0]]
[padding]RealThe padding to apply to the view bounds [Default: 0]
js
// Cleans up the loaded room when it leaves view_camera[0]'s view
if (not payload.IsInView()) { 
    payload.Cleanup();
}

// Cleans up only after the room is 512 pixels outside view_camera[1]'s view
if (not payload.IsInView(view_camera[1], 512)) { 
    payload.Cleanup();
}

.IsPointInside() ​

payload.IsPointInside(x, y) ➜ Bool

Returns whether the given point falls inside the loaded room's bounds (true) or not (false), accounting for any combination of position, origin, scale, and rotation.

ParameterTypeDescription
xRealThe x coordinate of the point to check
yRealThe y coordinate of the point to check
js
// Check if the player is inside the loaded room
if (payload.IsPointInside(player.x, player.y)) { 
    show_debug_message("Player is inside the room!");
}

.IsCleanedUp() ​

payload.IsCleanedUp() ➜ Bool

Returns whether the payload has been cleaned up (true) or not (false).

js
// Logs a warning if trying to use an already cleaned up payload
if (payload.IsCleanedUp()) { 
    show_debug_message("Warning: payload has already been cleaned up!");
}