Class: GameUnifier
Defined in: src/core/GameUnifier.ts:14
Constructors
Constructor
> new GameUnifier(): GameUnifier
Returns
GameUnifier
Properties
onEnd?
> static optional onEnd?: StepLabelType
Defined in: src/core/GameUnifier.ts:485
runningStepsCount
> static runningStepsCount: number = 0
Defined in: src/core/GameUnifier.ts:471
Count of currently executing steps. If a step triggers a narration.continue(), this number is greater than 1.
Accessors
addHistoryItem
Get Signature
> get static addHistoryItem(): (historyInfo?, opstions?) => void
Defined in: src/core/GameUnifier.ts:464
Add a history step to the history.
Returns
(historyInfo?, opstions?) => void
animate
Get Signature
> get static animate(): <T>(components, keyframes, options?, priority?) => string | undefined
Defined in: src/core/GameUnifier.ts:534
This function is called to animate a component.
Default
UPDATE_PRIORITY.NORMAL
Returns
The id of tickers.
<T>(components, keyframes, options?, priority?) => string | undefined
backRequestsCount
Get Signature
> get static backRequestsCount(): number
Defined in: src/core/GameUnifier.ts:317
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
number
continueRequestsCount
Get Signature
> get static continueRequestsCount(): number
Defined in: src/core/GameUnifier.ts:296
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
number
currentGameStepState
Get Signature
> get static currentGameStepState(): GameStepState
Defined in: src/core/GameUnifier.ts:215
Returns the current state of the game step.
Throws
when Game.init() has not been called yet.
Returns
GameStepState
getCharacter
Get Signature
> get static getCharacter(): (id) => CharacterInterface | undefined
Defined in: src/core/GameUnifier.ts:481
This function returns the character by its id.
Returns
The character or undefined if it does not exist.
(id) => CharacterInterface | undefined
getFlag
Get Signature
> get static getFlag(): (name) => boolean
Defined in: src/core/GameUnifier.ts:417
This function returns the value of a flag.
Returns
(name) => boolean
getVariable
Get Signature
> get static getVariable(): <T>(prefix, key) => T | undefined
Defined in: src/core/GameUnifier.ts:373
This function returns the value of a variable.
Returns
The value of the variable.
<T>(prefix, key) => T | undefined
navigate
Get Signature
> get static navigate(): (path) => void | Promise<void>
Defined in: src/core/GameUnifier.ts:170
The navigate function.
Returns
(path) => void | Promise<void>
Set Signature
> set static navigate(value): void
Defined in: src/core/GameUnifier.ts:173
Parameters
value
(path) => void | Promise<void>
Returns
void
onLabelClosing
Get Signature
> get static onLabelClosing(): (openedLabelsNumber) => void
Defined in: src/core/GameUnifier.ts:441
This function is called after the narration.continue() method is executed It can be used to clear old temporary variables.
Returns
(openedLabelsNumber) => void
onPreContinue
Get Signature
> get static onPreContinue(): () => Promise<void>
Defined in: src/core/GameUnifier.ts:277
This function is called immediately before a narration "continue" operation.
Returns
() => Promise<void>
openedLabels
Get Signature
> get static openedLabels(): number
Defined in: src/core/GameUnifier.ts:247
Returns the number of opened labels.
Throws
when Game.init() has not been called yet.
Returns
number
removeVariable
Get Signature
> get static removeVariable(): (prefix, key) => void
Defined in: src/core/GameUnifier.ts:403
This function removes a variable.
Returns
(prefix, key) => void
restoreGameStepState
Get Signature
> get static restoreGameStepState(): (state, navigate) => Promise<void>
Defined in: src/core/GameUnifier.ts:233
Restores the game step state.
Returns
(state, navigate) => Promise<void>
setFlag
Get Signature
> get static setFlag(): (name, value) => void
Defined in: src/core/GameUnifier.ts:432
This function sets the value of a flag.
Returns
(name, value) => void
setVariable
Get Signature
> get static setVariable(): (prefix, key, value) => void
Defined in: src/core/GameUnifier.ts:389
This function sets the value of a variable.
Returns
(prefix, key, value) => void
stepCounter
Get Signature
> get static stepCounter(): number
Defined in: src/core/GameUnifier.ts:194
Returns the current step counter. This counter corresponds to the total number of steps that have been executed so far.
Throws
when Game.init() has not been called yet.
Returns
number
Set Signature
> set static stepCounter(value): void
Defined in: src/core/GameUnifier.ts:201
Returns the current state of the game step.
Throws
when Game.init() has not been called yet.
Parameters
value
number
Returns
void
Methods
addOnError()
> static addOnError(handler): () => void
Defined in: src/core/GameUnifier.ts:491
Parameters
handler
Returns
() => void
addOnPreContinue()
> static addOnPreContinue(handler): void
Defined in: src/core/GameUnifier.ts:256
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
handler
() => void | Promise<void>
Returns
void
clearOnErrorHandlers()
> static clearOnErrorHandlers(): void
Defined in: src/core/GameUnifier.ts:500
Returns
void
clearOnPreContinueHandlers()
> static clearOnPreContinueHandlers(): void
Defined in: src/core/GameUnifier.ts:264
Returns
void
increaseBackRequest()
> static increaseBackRequest(amount?): void
Defined in: src/core/GameUnifier.ts:327
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
amount?
number = 1
The number of steps to increase. Default is 1.
Returns
void
increaseContinueRequest()
> static increaseContinueRequest(amount?): void
Defined in: src/core/GameUnifier.ts:306
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
amount?
number = 1
The number of steps to increase. Default is 1.
Returns
void
init()
> static init(options): void
Defined in: src/core/GameUnifier.ts:15
Parameters
options
animate
<T>(components, keyframes, options?, priority?) => string | undefined
This function is called to animate a component.
Default
UPDATE_PRIORITY.NORMAL
getCharacter
(id) => CharacterInterface | undefined
This function returns the character by its id.
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
(name) => boolean
This function returns the value of a flag.
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
() => 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
<T>(prefix, key) => T | undefined
This function returns the value of a variable.
navigate?
(path) => void | Promise<void>
The navigate function.
onLabelClosing?
(openedLabelsNumber) => void
This function is called after the narration.continue() method is executed.
It can be used to clear old temporary variables.
processNavigationRequests
(navigationRequestsCount, props) => object
This function is called to process the pending navigation requests (continue/back).
removeVariable
(prefix, key) => void
This function removes a variable.
restoreGameStepState
(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
(name, value) => void
This function sets the value of a flag.
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
(prefix, key, value) => void
This function sets the value of a variable.
addHistoryItem
Returns
void
processNavigationRequests()
> static processNavigationRequests(props): Promise<StepLabelResultType>
Defined in: src/core/GameUnifier.ts:347
This function processes the pending navigation requests (continue/back).
Parameters
props
any
Returns
Promise<StepLabelResultType>
Throws
when Game.init() has not been called yet.
removeOnError()
> static removeOnError(handler): void
Defined in: src/core/GameUnifier.ts:496
Parameters
handler
Returns
void
removeOnPreContinue()
> static removeOnPreContinue(handler): void
Defined in: src/core/GameUnifier.ts:259
Parameters
handler
() => void | Promise<void>
Returns
void
runOnError()
> static runOnError(error, props): Promise<void>
Defined in: src/core/GameUnifier.ts:504
Parameters
error
unknown
props
any
Returns
Promise<void>