Skip to content

1681-engine / index / TargetLock

Class: TargetLock<T> ​

Defined in: src/input/TargetLock.ts:87

The lock as state: which body is held, picked by a drag or the nearest, let go when it is gone or too far.

Type Parameters ​

Type ParameterDefault type
T extends LockBodyLockBody

Constructors ​

Constructor ​

ts
new TargetLock<T>(bodies, options?): TargetLock<T>;

Defined in: src/input/TargetLock.ts:93

Parameters ​

ParameterType
bodies() => readonly T[]
optionsTargetLockOptions

Returns ​

TargetLock<T>

Accessors ​

locked ​

Get Signature ​

ts
get locked(): number | null;

Defined in: src/input/TargetLock.ts:103

The id held, without checking it still stands (use current for that).

Returns ​

number | null

Methods ​

clear() ​

ts
clear(): void;

Defined in: src/input/TargetLock.ts:127

Returns ​

void


current() ​

ts
current(from): T | null;

Defined in: src/input/TargetLock.ts:121

The held body if it still holds; a lock that no longer does is dropped.

Parameters ​

ParameterType
fromPoint

Returns ​

T | null


pick() ​

ts
pick(from, dir): number | null;

Defined in: src/input/TargetLock.ts:108

A drag in dir from from: locks what it points at; pointing at nothing keeps the old lock.

Parameters ​

ParameterType
fromPoint
dirPoint

Returns ​

number | null


pickNearest() ​

ts
pickNearest(from): number | null;

Defined in: src/input/TargetLock.ts:115

Locks the nearest body, every call, whatever was held.

Parameters ​

ParameterType
fromPoint

Returns ​

number | null

Released under the MIT License.