Skip to content

Class: MockCGameGraph ​

Mock of the X-Ray engine game_graph() singleton.

Implements ​

  • CGameGraph

Constructors ​

Constructor ​

ts
new MockCGameGraph(): MockCGameGraph;

Returns ​

MockCGameGraph

Methods ​

accessible() ​

Call Signature ​

ts
accessible(vertexId: number): boolean;

Check whether a game-graph vertex can be used for AI travel.

Parameters ​
ParameterTypeDescription
vertexIdnumberGame-graph vertex id.
Returns ​

boolean

Whether the vertex is currently accessible.

Remarks ​

This is pathing accessibility, not whether the vertex exists.

Implementation of ​
ts
CGameGraph.accessible

Call Signature ​

ts
accessible(vertexId: number, value: boolean): void;

Mark a game-graph vertex as accessible or blocked.

Parameters ​
ParameterTypeDescription
vertexIdnumberGame-graph vertex id.
valuebooleanNew accessibility state.
Returns ​

void

Remarks ​

Blocking vertices affects AI travel through the game graph. Prefer narrow, reversible changes.

Implementation of ​
ts
CGameGraph.accessible

valid_vertex_id() ​

ts
valid_vertex_id(vertexId: number): boolean;

Check whether a game-graph vertex id exists.

Parameters ​

ParameterTypeDescription
vertexIdnumberGame-graph vertex id.

Returns ​

boolean

Whether the id can be used with graph methods.

Implementation of ​

ts
CGameGraph.valid_vertex_id

vertex_id() ​

ts
vertex_id(vertex: GameGraph__CVertex): number;

Resolve a graph vertex back to its id.

Parameters ​

ParameterTypeDescription
vertexGameGraph__CVertexVertex returned by CGameGraph.vertex.

Returns ​

number

Game-graph vertex id.

Remarks ​

Pass only vertices returned by this graph instance.

Implementation of ​

ts
CGameGraph.vertex_id

create() ​

ts
static create(): MockCGameGraph;

Returns ​

MockCGameGraph


getInstance() ​

ts
static getInstance(): MockCGameGraph;

Returns ​

MockCGameGraph


mock() ​

ts
static mock(): CGameGraph;

Returns ​

CGameGraph

Properties ​

accessibleVertices ​

ts
accessibleVertices: Map<number, boolean>;

levels ​

ts
levels: Mock<() => LuaIterable<cse_abstract, undefined>>;

Iterate over game levels registered in all.spawn.

Remarks ​

Iterates graph-level descriptors, not currently loaded level objects.

Returns ​

Level object on every iteration.

Implementation of ​

ts
CGameGraph.levels

vertex ​

ts
vertex: Mock<(vertexId: number) => MockCVertex>;

Get a game-graph vertex by id.

Remarks ​

Call CGameGraph.valid_vertex_id first. Native code expects a valid id and can fail hard on invalid graph references.

Param ​

vertexId

Game-graph vertex id.

Returns ​

Graph vertex descriptor.

Implementation of ​

ts
CGameGraph.vertex

instance ​

ts
static instance: MockCGameGraph | null = null;

registry ​

ts
static registry: Record<number, MockCVertex> = {};