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



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

Constructors [#constructors]

Constructor [#constructor]

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

Returns [#returns]

`GameUnifier`

Properties [#properties]

onEnd? [#onend]

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

Defined in: [src/core/GameUnifier.ts:485](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L485)

***

runningStepsCount [#runningstepscount]

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

Defined in: [src/core/GameUnifier.ts:471](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L471)

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`

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

Add a history step to the history.

Returns [#returns-1]

(`historyInfo?`, `opstions?`) => `void`

***

animate [#animate]

Get Signature [#get-signature-1]

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

Defined in: [src/core/GameUnifier.ts:534](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L534)

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`

***

backRequestsCount [#backrequestscount]

Get Signature [#get-signature-2]

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

Defined in: [src/core/GameUnifier.ts:317](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L317)

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-3]

`number`

***

continueRequestsCount [#continuerequestscount]

Get Signature [#get-signature-3]

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

Defined in: [src/core/GameUnifier.ts:296](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L296)

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-4]

`number`

***

currentGameStepState [#currentgamestepstate]

Get Signature [#get-signature-4]

\> **get** `static` **currentGameStepState**(): `GameStepState`

Defined in: [src/core/GameUnifier.ts:215](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L215)

Returns the current state of the game step.

Throws [#throws]

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

Returns [#returns-5]

`GameStepState`

***

getCharacter [#getcharacter]

Get Signature [#get-signature-5]

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

Defined in: [src/core/GameUnifier.ts:481](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L481)

This function returns the character by its id.

Returns [#returns-6]

The character or undefined if it does not exist.

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

***

getFlag [#getflag]

Get Signature [#get-signature-6]

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

Defined in: [src/core/GameUnifier.ts:417](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L417)

This function returns the value of a flag.

Returns [#returns-7]

(`name`) => `boolean`

***

getVariable [#getvariable]

Get Signature [#get-signature-7]

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

Defined in: [src/core/GameUnifier.ts:373](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L373)

This function returns the value of a variable.

Returns [#returns-8]

The value of the variable.

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

***

navigate [#navigate]

Get Signature [#get-signature-8]

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

Defined in: [src/core/GameUnifier.ts:170](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L170)

The navigate function.

Returns [#returns-9]

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

Set Signature [#set-signature]

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

Defined in: [src/core/GameUnifier.ts:173](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L173)

Parameters [#parameters]

value [#value]

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

Returns [#returns-10]

`void`

***

onLabelClosing [#onlabelclosing]

Get Signature [#get-signature-9]

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

Defined in: [src/core/GameUnifier.ts:441](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L441)

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

Returns [#returns-11]

(`openedLabelsNumber`) => `void`

***

onPreContinue [#onprecontinue]

Get Signature [#get-signature-10]

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

Defined in: [src/core/GameUnifier.ts:277](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L277)

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

Returns [#returns-12]

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

***

openedLabels [#openedlabels]

Get Signature [#get-signature-11]

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

Defined in: [src/core/GameUnifier.ts:247](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L247)

Returns the number of opened labels.

Throws [#throws-1]

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

Returns [#returns-13]

`number`

***

removeVariable [#removevariable]

Get Signature [#get-signature-12]

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

Defined in: [src/core/GameUnifier.ts:403](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L403)

This function removes a variable.

Returns [#returns-14]

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

***

restoreGameStepState [#restoregamestepstate]

Get Signature [#get-signature-13]

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

Defined in: [src/core/GameUnifier.ts:233](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L233)

Restores the game step state.

Returns [#returns-15]

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

***

setFlag [#setflag]

Get Signature [#get-signature-14]

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

Defined in: [src/core/GameUnifier.ts:432](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L432)

This function sets the value of a flag.

Returns [#returns-16]

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

***

setVariable [#setvariable]

Get Signature [#get-signature-15]

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

Defined in: [src/core/GameUnifier.ts:389](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L389)

This function sets the value of a variable.

Returns [#returns-17]

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

***

stepCounter [#stepcounter]

Get Signature [#get-signature-16]

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

Defined in: [src/core/GameUnifier.ts:194](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L194)

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-18]

`number`

Set Signature [#set-signature-1]

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

Defined in: [src/core/GameUnifier.ts:201](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L201)

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-19]

`void`

Methods [#methods]

addOnError() [#addonerror]

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

Defined in: [src/core/GameUnifier.ts:491](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L491)

Parameters [#parameters-2]

handler [#handler]

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

Returns [#returns-20]

() => `void`

***

addOnPreContinue() [#addonprecontinue]

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

Defined in: [src/core/GameUnifier.ts:256](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L256)

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-21]

`void`

***

clearOnErrorHandlers() [#clearonerrorhandlers]

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

Defined in: [src/core/GameUnifier.ts:500](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L500)

Returns [#returns-22]

`void`

***

clearOnPreContinueHandlers() [#clearonprecontinuehandlers]

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

Defined in: [src/core/GameUnifier.ts:264](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L264)

Returns [#returns-23]

`void`

***

increaseBackRequest() [#increasebackrequest]

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

Defined in: [src/core/GameUnifier.ts:327](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L327)

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-24]

`void`

***

increaseContinueRequest() [#increasecontinuerequest]

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

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

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-25]

`void`

***

init() [#init]

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

Defined in: [src/core/GameUnifier.ts:15](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/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
```

getCharacter [#getcharacter-1]

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

This function returns the character by its id.

getCurrentGameStepState [#getcurrentgamestepstate]

() => `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).

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-26]

`void`

***

processNavigationRequests() [#processnavigationrequests-1]

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

Defined in: [src/core/GameUnifier.ts:347](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L347)

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

Parameters [#parameters-7]

props [#props]

`any`

Returns [#returns-27]

`Promise`\<[`StepLabelResultType`](/jsdoc/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:496](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L496)

Parameters [#parameters-8]

handler [#handler-2]

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

Returns [#returns-28]

`void`

***

removeOnPreContinue() [#removeonprecontinue]

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

Defined in: [src/core/GameUnifier.ts:259](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L259)

Parameters [#parameters-9]

handler [#handler-3]

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

Returns [#returns-29]

`void`

***

runOnError() [#runonerror]

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

Defined in: [src/core/GameUnifier.ts:504](https://github.com/DRincs-Productions/pixi-vn/blob/998c1a75c5978f24c0dc137af5f42b90b2803967/src/core/GameUnifier.ts#L504)

Parameters [#parameters-10]

error [#error]

`unknown`

props [#props-1]

`any`

Returns [#returns-30]

`Promise`\<`void`>
