Talos docs

QueryFilter

Since 0.6

Filter for {@link WorldQuery.query}; every given field must match.

Plain text

Signature

export interface QueryFilter {
  tag?: string
  component?: string
  /** Within `radius` metres (default 1) of this point or entity. */
  near?: Target
  radius?: number
  /** Inside the bounds of this trigger volume or entity (by id or handle). */
  inside?: string | EntityHandle
}

Import: import type { QueryFilter } from "@argus/api"

Members

MemberSignatureDescription
tagtag?: string
componentcomponent?: string
nearnear?: TargetWithin radius metres (default 1) of this point or entity.
radiusradius?: number
insideinside?: string | EntityHandleInside the bounds of this trigger volume or entity (by id or handle).

Example

The tested fixture fixtures/host/door.ts.

import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
  update(ctx) {
    const player = ctx.world.find("player")
    const near = player !== null && ctx.entity.distanceTo(player) < 2
    ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
  },
} satisfies Behavior