Options
All
  • Public
  • Public/Protected
  • All
Menu

A fog of war management class which is the singleton canvas.fog instance.

Hierarchy

  • FogManager

Index

Constructors

Properties

exploration: FogExploration = null

The FogExploration document which applies to this canvas view

#initialized: boolean = false

A status flag for whether the layer initialization workflow has succeeded

#updated: boolean = false

Track whether we have pending fog updates which have not yet been saved to the database

#extractor: TextureExtractor

Texture extractor

#refreshCount: number = 0

The fog refresh count. If > to the refresh threshold, the fog texture is saved to database. It is then reinitialized to 0.

#renderTransform: Matrix = ...

Matrix used for fog rendering transformation.

#debouncedSave: Function = ...

A debounced function to save fog of war exploration once a continuous stream of updates has concluded.

#queue: Semaphore = ...

Handling of the concurrency for fog loading, saving and reset.

#explorationSprite: any
COMMIT_THRESHOLD: number = 70

Define the number of fog refresh needed before the fog texture is extracted and pushed to the server.

Accessors

  • The exploration SpriteMesh which holds the fog exploration texture.

    Returns SpriteMesh

  • get textureConfiguration(): FogTextureConfiguration
  • The configured options used for the saved fog-of-war texture.

    Returns FogTextureConfiguration

  • get tokenVision(): boolean
  • Does the currently viewed Scene support Token field of vision?

    Returns boolean

  • get fogExploration(): boolean
  • Does the currently viewed Scene support fog of war exploration?

    Returns boolean

Methods

  • initialize(): Promise<void>
  • Initialize fog of war - resetting it when switching scenes or re-drawing the canvas

    Returns Promise<void>

  • clear(): Promise<void>
  • Clear the fog and reinitialize properties (commit and save in non reset mode)

    Returns Promise<void>

  • commit(): void
  • Once a new Fog of War location is explored, composite the explored container with the current staging sprite. Once the number of refresh is > to the commit threshold, save the fog texture to the database.

    Returns void

  • load(): Promise<any>
  • Load existing fog of war data from local storage and populate the initial exploration sprite

    Returns Promise<any>

  • reset(): Promise<void>
  • Dispatch a request to reset the fog of war exploration status for all users within this Scene. Once the server has deleted existing FogExploration documents, the _onReset handler will re-draw the canvas.

    Returns Promise<void>

  • save(): Promise<any>
  • Request a fog of war save operation. Note: if a save operation is pending, we're waiting for its conclusion.

    Returns Promise<any>

  • _handleReset(): Promise<any>
  • If fog of war data is reset from the server, deactivate the current fog and initialize the exploration.

    internal

    Returns Promise<any>

  • #load(): Promise<any>
  • Load existing fog of war data from local storage and populate the initial exploration sprite

    Returns Promise<any>

  • #save(): Promise<void>
  • Request a fog of war save operation. Note: if a save operation is pending, we're waiting for its conclusion.

    Returns Promise<void>

  • #updateFogExploration(updateData: any): Promise<void>
  • Update the fog exploration document with provided data.

    Parameters

    • updateData: any

    Returns Promise<void>

  • #deactivate(): void
  • Deactivate fog of war. Clear all shared containers by unlinking them from their parent. Destroy all stored textures and graphics.

    Returns void

  • #handleReset(): Promise<any>
  • If fog of war data is reset from the server, deactivate the current fog and initialize the exploration.

    Returns Promise<any>