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:532
runningStepsCount
> static runningStepsCount: number = 0
Defined in: src/core/GameUnifier.ts:518
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 | Promise<void>
Defined in: src/core/GameUnifier.ts:511
Add a history step to the history.
Returns
(historyInfo?, opstions?) => void | Promise<void>
animate
Get Signature
> get static animate(): <T>(components, keyframes, options?, priority?) => string | undefined
Defined in: src/core/GameUnifier.ts:581
This function is called to animate a component.
Default
UPDATE_PRIORITY.NORMALReturns
The id of tickers.
<T>(components, keyframes, options?, priority?) => string | undefined
animateFilter
Get Signature
> get static animateFilter(): (components, filter, keyframes, options?, priority?, apply?, cleanup?) => string | undefined
Defined in: src/core/GameUnifier.ts:605
This function is called to animate a Filter's own properties, or a plain numeric "progress"
value when no filter is given. See animate for animating a canvas element's properties
instead.
Returns
The id of the ticker.
(components, filter, keyframes, options?, priority?, apply?, cleanup?) => string | undefined
backRequestsCount
Get Signature
> get static backRequestsCount(): number
Defined in: src/core/GameUnifier.ts:364
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
canvasComponentExists
Get Signature
> get static canvasComponentExists(): (alias) => boolean
Defined in: src/core/GameUnifier.ts:633
Checks whether a canvas component with the given alias currently exists. See the
canvasComponentExists option of init for why this exists.
Returns
(alias) => boolean
continueRequestsCount
Get Signature
> get static continueRequestsCount(): number
Defined in: src/core/GameUnifier.ts:343
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 | Promise<GameStepState>
Defined in: src/core/GameUnifier.ts:262
Returns the current state of the game step.
Throws
when Game.init() has not been called yet.
Returns
GameStepState | Promise<GameStepState>
getCharacter
Get Signature
> get static getCharacter(): (id) => CharacterInterface | undefined
Defined in: src/core/GameUnifier.ts:528
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:464
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:420
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:217
The navigate function.
Returns
(path) => void | Promise<void>
Set Signature
> set static navigate(value): void
Defined in: src/core/GameUnifier.ts:220
Parameters
value
(path) => void | Promise<void>
Returns
void
onLabelClosing
Get Signature
> get static onLabelClosing(): (openedLabelsNumber) => void
Defined in: src/core/GameUnifier.ts:488
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:324
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:294
Returns the number of opened labels.
Throws
when Game.init() has not been called yet.
Returns
number
removeCanvasComponent
Get Signature
> get static removeCanvasComponent(): (alias) => void
Defined in: src/core/GameUnifier.ts:619
Removes one or more canvas components by alias. See the removeCanvasComponent option of
init for why this exists.
Returns
(alias) => void
removeVariable
Get Signature
> get static removeVariable(): (prefix, key) => void
Defined in: src/core/GameUnifier.ts:450
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:280
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:479
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:436
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:241
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:248
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:538
Parameters
handler
Returns
() => void
addOnPreContinue()
> static addOnPreContinue(handler): void
Defined in: src/core/GameUnifier.ts:303
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:547
Returns
void
clearOnPreContinueHandlers()
> static clearOnPreContinueHandlers(): void
Defined in: src/core/GameUnifier.ts:311
Returns
void
increaseBackRequest()
> static increaseBackRequest(amount?): void
Defined in: src/core/GameUnifier.ts:374
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:353
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.NORMALanimateFilter
(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, 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
UPDATE_PRIORITY.NORMALcanvasComponentExists
(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).
getCharacter
(id) => CharacterInterface | undefined
This function returns the character by its id.
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
(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).
removeCanvasComponent
(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
(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:394
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:543
Parameters
handler
Returns
void
removeOnPreContinue()
> static removeOnPreContinue(handler): void
Defined in: src/core/GameUnifier.ts:306
Parameters
handler
() => void | Promise<void>
Returns
void
runOnError()
> static runOnError(error, props): Promise<void>
Defined in: src/core/GameUnifier.ts:551
Parameters
error
unknown
props
any
Returns
Promise<void>