Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Runtime classServer APIGenerated

Gate

Defined in: server/api.d.ts:5696

Replicated handle for one of the level’s castle gates.

new Gate(id): Gate

Defined in: server/api.d.ts:5701

Creates a script wrapper for a gate the server already knows; gates are the level’s own and are never spawned.

number

Network entity identifier.

Gate

Entity.constructor

setVirtualWorld(world): void

Defined in: server/api.d.ts:8797

Moves this entity into another virtual world.

number

Virtual-world identifier used to partition replication and visibility.

void

Entity.setVirtualWorld


setVisibleTo(player): void

Defined in: server/api.d.ts:8803

Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.

Entity | null

Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.

void

Entity.setVisibleTo


toggle(open?): GateToggle

Defined in: server/api.d.ts:5749

Starts a cycle. The motion is never streamed: every client plays it out from the server clock it started on, and a gate reversed mid-cycle picks up where it is rather than snapping to the far end.

boolean

true opens, false closes. Omitted heads away from whichever end the gate is at, reversing one already moving.

GateToggle

What happened, and the phrase to explain it with when nothing did.


toString(): string

Defined in: server/api.d.ts:5742

Formats this gate handle for logging and debugging.

string

The gate ID, its level GUID, what kind it is and where it is in its cycle.

Entity.toString


static all(): Gate[]

Defined in: server/api.d.ts:5755

Lists every gate the level places, all of which exist from boot in the global world. In another virtual world a gate is built the first time anything there reaches it, so this lists only those.

Gate[]

One handle per gate, in no particular order.


static find(guid, virtualWorld?): Gate | null

Defined in: server/api.d.ts:5770

Looks a gate up by the level’s own identity for it, which survives a restart and is the same on every machine. A gate the level places is always found, in any virtual world.

string

The gate’s level EntityGuid as hex, with or without an 0x prefix, as gate.guid prints it.

number

Optional virtual world to look in; omitted looks in the global one, where every body starts.

Gate | null

The gate’s handle, or null when the level places no such gate.


static getById(id): Gate | null

Defined in: server/api.d.ts:5762

Looks a gate up by its network entity ID.

number

Network entity identifier.

Gate | null

The gate’s handle, or null when no live gate has that ID.


static nearest(position, radius, virtualWorld?): Gate | null

Defined in: server/api.d.ts:5779

Finds the gate nearest a point. Gate positions come from the level’s own data, so unlike a door this needs no round trip to anybody’s client.

Vector3 | Partial<Vector3>

World-space point to measure from.

number

How far to look, in metres. Castle architecture is visible from a long way off, so this is tens of metres rather than a couple.

number

Optional virtual world to look in; omitted looks in the global one.

Gate | null

The nearest gate within the radius, or null when there is none.

readonly closeDuration: number

Defined in: server/api.d.ts:5736

How long closing takes, in seconds, from the asset’s animation database.


readonly cycle: string

Defined in: server/api.d.ts:5716

Where the gate is in its cycle: closed, opening, open or closing. Open always means passable – a portcullis raised, a drawbridge lowered. Named cycle because every entity already has a state, which is its state bag.


readonly guid: string

Defined in: server/api.d.ts:5706

The level’s own EntityGuid, as sixteen lowercase hex digits. The same on every machine, so it is the identity to store a gate under; Gate.find takes it back. A gate has no entity of its own, so its key is the GUID of the layer that draws it shut.


readonly id: number

Defined in: server/api.d.ts:8765

Immutable network entity identifier.

Entity.id


readonly kind: string

Defined in: server/api.d.ts:5711

What piece of architecture this is: drawbridge or portcullis, which animate, or gate, a pair of leaves the level swaps between drawn open and drawn shut – the Ratborsch and Nebakov fortress gates and the Ruthard palace gate. A gate opens and closes at once.


readonly moving: boolean

Defined in: server/api.d.ts:5726

Whether a cycle is running. toggle reverses a moving gate from where it has got to rather than refusing it.


readonly openDuration: number

Defined in: server/api.d.ts:5731

How long opening takes, in seconds, from the key range the asset’s animation database stores. A gate with no opening clip runs its closing one backwards, so this is that clip’s length. 0 for a gate.


readonly openness: number

Defined in: server/api.d.ts:5721

How far open the gate is, from 0 shut to 1 fully open, read off the pose curve mined from the asset’s own animation at the point the server clock says the motion has reached. It follows the bars, not the clock: a portcullis reads 0 within the first fifth of its close, and holds there while the clip finishes.


position: Vector3

Defined in: server/api.d.ts:8775

Authoritative world-space position; assignment forces replicated state.

Entity.position


rotation: Vector3 | Quaternion

Defined in: server/api.d.ts:8780

Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.

Entity.rotation


readonly state: StateBag

Defined in: server/api.d.ts:8785

Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.

Entity.state


readonly virtualWorld: number

Defined in: server/api.d.ts:8770

Current virtual-world identifier.

Entity.virtualWorld