SentryComp:

The sentry component.

direction?: Vec2

The direction the sentry is pointing to.

directionAngle?: number

The direction of the sentry as an angle in degrees.

fieldOfView?: number

The field of view of the sentry in degrees.

spotted: GameObj[]

The objects spotted most recently.

onObjectsSpotted(cb: (objects: GameObj[])=>void): KEventController

Attaches an event handler which is called when objects of interest are spotted.

paramcbThe event handler called when objects are spotted.

isWithinFieldOfView(obj: GameObj, direction?: Vec2, fieldOfView?: number): boolean

Returns true if the object is within the field of view.

paramobjThe object to test.

paramdirectionThe direction to look at.

paramfieldOfViewThe field of view in degrees.

hasLineOfSight(obj: GameObj): boolean

Returns true if there is a line of sight to the object.

paramobjThe object to test.

kaplay logo

Misc

Layer