# Class: GameUnifier (/pixi-vn/index/classes/GameUnifier)



Defined in: [src/core/GameUnifier.ts:14](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L14)

## Constructors [#constructors]

### Constructor [#constructor]

\> **new GameUnifier**(): `GameUnifier`

#### Returns [#returns]

`GameUnifier`

## Properties [#properties]

### onEnd? [#onend]

\> `static` `optional` **onEnd?**: [`StepLabelType`](/pixi-vn/index/type-aliases/StepLabelType)

Defined in: [src/core/GameUnifier.ts:532](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L532)

***

### runningStepsCount [#runningstepscount]

\> `static` **runningStepsCount**: `number` = `0`

Defined in: [src/core/GameUnifier.ts:518](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L518)

Count of currently executing steps.
If a step triggers a narration.continue(), this number is greater than 1.

## Accessors [#accessors]

### addHistoryItem [#addhistoryitem]

#### Get Signature [#get-signature]

\> **get** `static` **addHistoryItem**(): (`historyInfo?`, `opstions?`) => `void` | `Promise`\<`void`>

Defined in: [src/core/GameUnifier.ts:511](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L511)

Add a history step to the history.

##### Returns [#returns-1]

(`historyInfo?`, `opstions?`) => `void` | `Promise`\<`void`>

***

### animate [#animate]

#### Get Signature [#get-signature-1]

\> **get** `static` **animate**(): \<`T`>(`components`, `keyframes`, `options?`, `priority?`) => `string` | `undefined`

Defined in: [src/core/GameUnifier.ts:581](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L581)

This function is called to animate a component.

##### Default [#default]

```ts
UPDATE_PRIORITY.NORMAL
```

##### Returns [#returns-2]

The id of tickers.

\<`T`>(`components`, `keyframes`, `options?`, `priority?`) => `string` | `undefined`

***

### animateFilter [#animatefilter]

#### Get Signature [#get-signature-2]

\> **get** `static` **animateFilter**(): (`components`, `filter`, `keyframes`, `options?`, `priority?`, `apply?`, `cleanup?`) => `string` | `undefined`

Defined in: [src/core/GameUnifier.ts:605](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L605)

This function is called to animate a `Filter`'s own properties, or a plain numeric "progress"
value when no `filter` is given. See [animate](#animate) for animating a canvas element's properties
instead.

##### Returns [#returns-3]

The id of the ticker.

(`components`, `filter`, `keyframes`, `options?`, `priority?`, `apply?`, `cleanup?`) => `string` | `undefined`

***

### backRequestsCount [#backrequestscount]

#### Get Signature [#get-signature-3]

\> **get** `static` **backRequestsCount**(): `number`

Defined in: [src/core/GameUnifier.ts:364](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L364)

This function is called to get the number of pending back requests.
Returns the negation of navigationRequestsCount:

* Positive value (absolute value of navigationRequestsCount) when navigationRequestsCount is negative (back requests pending)
* Negative value when navigationRequestsCount is positive (continue requests pending)
* Zero when navigationRequestsCount is zero (no requests pending)
  If it is > 0, after the stepsRunning is 0, the previous step will be executed.

##### Returns [#returns-4]

`number`

***

### canvasComponentExists [#canvascomponentexists]

#### Get Signature [#get-signature-4]

\> **get** `static` **canvasComponentExists**(): (`alias`) => `boolean`

Defined in: [src/core/GameUnifier.ts:633](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L633)

Checks whether a canvas component with the given alias currently exists. See the
`canvasComponentExists` option of [init](#init) for why this exists.

##### Returns [#returns-5]

(`alias`) => `boolean`

***

### continueRequestsCount [#continuerequestscount]

#### Get Signature [#get-signature-5]

\> **get** `static` **continueRequestsCount**(): `number`

Defined in: [src/core/GameUnifier.ts:343](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L343)

This function is called to get the number of pending continue requests.
Returns a positive count of pending continue requests when navigationRequestsCount is positive.
If it is > 0, after the stepsRunning is 0, the next step will be executed.

##### Returns [#returns-6]

`number`

***

### currentGameStepState [#currentgamestepstate]

#### Get Signature [#get-signature-6]

\> **get** `static` **currentGameStepState**(): `GameStepState` | `Promise`\<`GameStepState`>

Defined in: [src/core/GameUnifier.ts:262](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L262)

Returns the current state of the game step.

##### Throws [#throws]

when `Game.init()` has not been called yet.

##### Returns [#returns-7]

`GameStepState` | `Promise`\<`GameStepState`>

***

### getCharacter [#getcharacter]

#### Get Signature [#get-signature-7]

\> **get** `static` **getCharacter**(): (`id`) => `CharacterInterface` | `undefined`

Defined in: [src/core/GameUnifier.ts:528](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L528)

This function returns the character by its id.

##### Returns [#returns-8]

The character or undefined if it does not exist.

(`id`) => `CharacterInterface` | `undefined`

***

### getFlag [#getflag]

#### Get Signature [#get-signature-8]

\> **get** `static` **getFlag**(): (`name`) => `boolean`

Defined in: [src/core/GameUnifier.ts:464](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L464)

This function returns the value of a flag.

##### Returns [#returns-9]

(`name`) => `boolean`

***

### getVariable [#getvariable]

#### Get Signature [#get-signature-9]

\> **get** `static` **getVariable**(): \<`T`>(`prefix`, `key`) => `T` | `undefined`

Defined in: [src/core/GameUnifier.ts:420](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L420)

This function returns the value of a variable.

##### Returns [#returns-10]

The value of the variable.

\<`T`>(`prefix`, `key`) => `T` | `undefined`

***

### navigate [#navigate]

#### Get Signature [#get-signature-10]

\> **get** `static` **navigate**(): (`path`) => `void` | `Promise`\<`void`>

Defined in: [src/core/GameUnifier.ts:217](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L217)

The navigate function.

##### Returns [#returns-11]

(`path`) => `void` | `Promise`\<`void`>

#### Set Signature [#set-signature]

\> **set** `static` **navigate**(`value`): `void`

Defined in: [src/core/GameUnifier.ts:220](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L220)

##### Parameters [#parameters]

###### value [#value]

(`path`) => `void` | `Promise`\<`void`>

##### Returns [#returns-12]

`void`

***

### onLabelClosing [#onlabelclosing]

#### Get Signature [#get-signature-11]

\> **get** `static` **onLabelClosing**(): (`openedLabelsNumber`) => `void`

Defined in: [src/core/GameUnifier.ts:488](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L488)

This function is called after the narration.continue() method is executed
It can be used to clear old temporary variables.

##### Returns [#returns-13]

(`openedLabelsNumber`) => `void`

***

### onPreContinue [#onprecontinue]

#### Get Signature [#get-signature-12]

\> **get** `static` **onPreContinue**(): () => `Promise`\<`void`>

Defined in: [src/core/GameUnifier.ts:324](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L324)

This function is called immediately before a narration "continue" operation.

##### Returns [#returns-14]

() => `Promise`\<`void`>

***

### openedLabels [#openedlabels]

#### Get Signature [#get-signature-13]

\> **get** `static` **openedLabels**(): `number`

Defined in: [src/core/GameUnifier.ts:294](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L294)

Returns the number of opened labels.

##### Throws [#throws-1]

when `Game.init()` has not been called yet.

##### Returns [#returns-15]

`number`

***

### removeCanvasComponent [#removecanvascomponent]

#### Get Signature [#get-signature-14]

\> **get** `static` **removeCanvasComponent**(): (`alias`) => `void`

Defined in: [src/core/GameUnifier.ts:619](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L619)

Removes one or more canvas components by alias. See the `removeCanvasComponent` option of
[init](#init) for why this exists.

##### Returns [#returns-16]

(`alias`) => `void`

***

### removeVariable [#removevariable]

#### Get Signature [#get-signature-15]

\> **get** `static` **removeVariable**(): (`prefix`, `key`) => `void`

Defined in: [src/core/GameUnifier.ts:450](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L450)

This function removes a variable.

##### Returns [#returns-17]

(`prefix`, `key`) => `void`

***

### restoreGameStepState [#restoregamestepstate]

#### Get Signature [#get-signature-16]

\> **get** `static` **restoreGameStepState**(): (`state`, `navigate`) => `Promise`\<`void`>

Defined in: [src/core/GameUnifier.ts:280](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L280)

Restores the game step state.

##### Returns [#returns-18]

(`state`, `navigate`) => `Promise`\<`void`>

***

### setFlag [#setflag]

#### Get Signature [#get-signature-17]

\> **get** `static` **setFlag**(): (`name`, `value`) => `void`

Defined in: [src/core/GameUnifier.ts:479](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L479)

This function sets the value of a flag.

##### Returns [#returns-19]

(`name`, `value`) => `void`

***

### setVariable [#setvariable]

#### Get Signature [#get-signature-18]

\> **get** `static` **setVariable**(): (`prefix`, `key`, `value`) => `void`

Defined in: [src/core/GameUnifier.ts:436](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L436)

This function sets the value of a variable.

##### Returns [#returns-20]

(`prefix`, `key`, `value`) => `void`

***

### stepCounter [#stepcounter]

#### Get Signature [#get-signature-19]

\> **get** `static` **stepCounter**(): `number`

Defined in: [src/core/GameUnifier.ts:241](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L241)

Returns the current step counter. This counter corresponds to the total number of steps that have been executed so far.

##### Throws [#throws-2]

when `Game.init()` has not been called yet.

##### Returns [#returns-21]

`number`

#### Set Signature [#set-signature-1]

\> **set** `static` **stepCounter**(`value`): `void`

Defined in: [src/core/GameUnifier.ts:248](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L248)

Returns the current state of the game step.

##### Throws [#throws-3]

when `Game.init()` has not been called yet.

##### Parameters [#parameters-1]

###### value [#value-1]

`number`

##### Returns [#returns-22]

`void`

## Methods [#methods]

### addOnError() [#addonerror]

\> `static` **addOnError**(`handler`): () => `void`

Defined in: [src/core/GameUnifier.ts:538](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L538)

#### Parameters [#parameters-2]

##### handler [#handler]

[`OnErrorHandler`](/pixi-vn/index/type-aliases/OnErrorHandler)

#### Returns [#returns-23]

() => `void`

***

### addOnPreContinue() [#addonprecontinue]

\> `static` **addOnPreContinue**(`handler`): `void`

Defined in: [src/core/GameUnifier.ts:303](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L303)

Register a handler to run immediately before a narration "continue" operation.
Handlers are executed in registration order and may be async. Use
`{@link addOnPreContinue}` / `{@link removeOnPreContinue}` to manage them programmatically.

#### Parameters [#parameters-3]

##### handler [#handler-1]

() => `void` | `Promise`\<`void`>

#### Returns [#returns-24]

`void`

***

### clearOnErrorHandlers() [#clearonerrorhandlers]

\> `static` **clearOnErrorHandlers**(): `void`

Defined in: [src/core/GameUnifier.ts:547](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L547)

#### Returns [#returns-25]

`void`

***

### clearOnPreContinueHandlers() [#clearonprecontinuehandlers]

\> `static` **clearOnPreContinueHandlers**(): `void`

Defined in: [src/core/GameUnifier.ts:311](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L311)

#### Returns [#returns-26]

`void`

***

### increaseBackRequest() [#increasebackrequest]

\> `static` **increaseBackRequest**(`amount?`): `void`

Defined in: [src/core/GameUnifier.ts:374](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L374)

This function is called to increase the number of pending back requests.
Note: While the decrement operation itself is atomic, the overall navigation
processing uses a lock in processNavigationRequests to ensure atomicity of
read-modify-write operations across async boundaries.

#### Parameters [#parameters-4]

##### amount? [#amount]

`number` = `1`

The number of steps to increase. Default is 1.

#### Returns [#returns-27]

`void`

***

### increaseContinueRequest() [#increasecontinuerequest]

\> `static` **increaseContinueRequest**(`amount?`): `void`

Defined in: [src/core/GameUnifier.ts:353](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L353)

This function is called to increase the number of pending continue requests.
Note: While the increment operation itself is atomic, the overall navigation
processing uses a lock in processNavigationRequests to ensure atomicity of
read-modify-write operations across async boundaries.

#### Parameters [#parameters-5]

##### amount? [#amount-1]

`number` = `1`

The number of steps to increase. Default is 1.

#### Returns [#returns-28]

`void`

***

### init() [#init]

\> `static` **init**(`options`): `void`

Defined in: [src/core/GameUnifier.ts:15](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L15)

#### Parameters [#parameters-6]

##### options [#options]

###### animate [#animate-1]

\<`T`>(`components`, `keyframes`, `options?`, `priority?`) => `string` | `undefined`

This function is called to animate a component.

**Default**

```ts
UPDATE_PRIORITY.NORMAL
```

###### animateFilter [#animatefilter-1]

(`components`, `filter`, `keyframes`, `options?`, `priority?`, `apply?`, `cleanup?`) => `string` | `undefined`

This function is called to animate either a `Filter`'s own properties, or a plain numeric
"progress" value with no live target (as opposed to [animate](#animate), which animates a canvas
element's properties). The latter is the generic mechanism behind the mask-based transitions
(wipe/iris/split): they have no canvas element or Filter property to write directly, just a
number and a side effect.

**Default**

```ts
UPDATE_PRIORITY.NORMAL
```

###### canvasComponentExists [#canvascomponentexists-1]

(`alias`) => `boolean`

This function checks whether a canvas component with the given alias currently exists. Used by
the `tickers` module to prune ticker/alias associations for components no longer on the canvas,
without importing `@drincs/pixi-vn/canvas` directly (see [removeCanvasComponent](#removecanvascomponent)).

###### getCharacter [#getcharacter-1]

(`id`) => `CharacterInterface` | `undefined`

This function returns the character by its id.

###### getCurrentGameStepState [#getcurrentgamestepstate]

() => `GameStepState` | `Promise`\<`GameStepState`>

This function returns the current state of the game step.

If your game engine does not have a history of steps, you can return an empty object.

###### getFlag [#getflag-1]

(`name`) => `boolean`

This function returns the value of a flag.

###### getOpenedLabels [#getopenedlabels]

() => `number`

This function returns the number of opened labels.

If your game engine does not have a narration system, you can return 0.

###### getStepCounter [#getstepcounter]

() => `number`

This function returns the current step counter. This counter corresponds to the total number of steps that have been executed so far.

If your game engine does not have a history of steps, you can return 0.

###### getVariable [#getvariable-1]

\<`T`>(`prefix`, `key`) => `T` | `undefined`

This function returns the value of a variable.

###### navigate? [#navigate-1]

(`path`) => `void` | `Promise`\<`void`>

The navigate function.

###### onLabelClosing? [#onlabelclosing-1]

(`openedLabelsNumber`) => `void`

This function is called after the narration.continue() method is executed.

It can be used to clear old temporary variables.

###### processNavigationRequests [#processnavigationrequests]

(`navigationRequestsCount`, `props`) => `object`

This function is called to process the pending navigation requests (continue/back).

###### removeCanvasComponent [#removecanvascomponent-1]

(`alias`) => `void`

This function removes one or more canvas components by alias. Used by the `tickers` module's
`onComplete` to honor `aliasToRemoveAfter` without importing `@drincs/pixi-vn/canvas` directly
(which would close an import cycle, since `canvas` depends on `tickers`).

###### removeVariable [#removevariable-1]

(`prefix`, `key`) => `void`

This function removes a variable.

###### restoreGameStepState [#restoregamestepstate-1]

(`state`, `navigate`) => `Promise`\<`void`>

This function restores the game step state.

If your game engine does not have a history of steps, you can return a resolved promise.

###### setFlag [#setflag-1]

(`name`, `value`) => `void`

This function sets the value of a flag.

###### setStepCounter [#setstepcounter]

(`value`) => `void`

This function sets the current step counter.

If your game engine does not have a history of steps, you can not set the step counter.

###### setVariable [#setvariable-1]

(`prefix`, `key`, `value`) => `void`

This function sets the value of a variable.

###### addHistoryItem [#addhistoryitem-1]

#### Returns [#returns-29]

`void`

***

### processNavigationRequests() [#processnavigationrequests-1]

\> `static` **processNavigationRequests**(`props`): `Promise`\<[`StepLabelResultType`](/pixi-vn/index/type-aliases/StepLabelResultType)>

Defined in: [src/core/GameUnifier.ts:394](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L394)

This function processes the pending navigation requests (continue/back).

#### Parameters [#parameters-7]

##### props [#props]

`any`

#### Returns [#returns-30]

`Promise`\<[`StepLabelResultType`](/pixi-vn/index/type-aliases/StepLabelResultType)>

#### Throws [#throws-4]

when `Game.init()` has not been called yet.

***

### removeOnError() [#removeonerror]

\> `static` **removeOnError**(`handler`): `void`

Defined in: [src/core/GameUnifier.ts:543](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L543)

#### Parameters [#parameters-8]

##### handler [#handler-2]

[`OnErrorHandler`](/pixi-vn/index/type-aliases/OnErrorHandler)

#### Returns [#returns-31]

`void`

***

### removeOnPreContinue() [#removeonprecontinue]

\> `static` **removeOnPreContinue**(`handler`): `void`

Defined in: [src/core/GameUnifier.ts:306](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L306)

#### Parameters [#parameters-9]

##### handler [#handler-3]

() => `void` | `Promise`\<`void`>

#### Returns [#returns-32]

`void`

***

### runOnError() [#runonerror]

\> `static` **runOnError**(`error`, `props`): `Promise`\<`void`>

Defined in: [src/core/GameUnifier.ts:551](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/core/GameUnifier.ts#L551)

#### Parameters [#parameters-10]

##### error [#error]

`unknown`

##### props [#props-1]

`any`

#### Returns [#returns-33]

`Promise`\<`void`>
