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

#textures: RenderTexture[] = []

A pool of RenderTexture objects which can be cycled through to save fog exploration progress.

#debouncedSave: Function = ...

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

#pending: any = ...
#revealed: any = ...
#sprite: SpriteMesh = ...
#resolution: any
COMMIT_THRESHOLD: number = 10

Define the number of positions that are explored before a set of fog updates are pushed to the server.

#MAXIMUM_FOW_TEXTURE_SIZE: number = 4096

The maximum allowable fog of war texture size.

Accessors

  • get pending(): Container
  • Vision containers for explored positions which have not yet been committed to the saved texture.

    Returns Container

  • get revealed(): Container
  • The container of previously revealed exploration.

    Returns Container

  • get sprite(): Sprite
  • A sprite containing the saved fog exploration texture.

    Returns Sprite

  • The configured resolution used for the saved fog-of-war texture

    Returns FogResolution

  • 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 Save that staging Sprite as the rendered fog exploration and swap it out for a fresh staging texture Do all this asynchronously, so it doesn't block token movement animation since this takes some extra time

    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<void>
  • Save Fog of War exploration data to a base64 string to the FogExploration document in the database. Assumes that the fog exploration has already been rendered as fog.rendered.texture.

    Returns Promise<void>

  • Update the fog layer when a player token reaches a board position which was not previously explored

    Parameters

    • source: VisionSource

      The vision source for which the fog layer should update

    • force: boolean = false

      Force fog to be updated even if the location is already explored

    Returns boolean

    Whether the source position represents a new fog exploration point

  • _handleReset(): Promise<any>
  • If fog of war data is reset from the server, re-draw the canvas

    internal

    Returns Promise<any>

  • Choose an adaptive fog rendering resolution which downscales the saved fog textures for larger dimension Scenes. It is important that the width and height of the fog texture is evenly divisible by the downscaling resolution.

    Returns FogResolution

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

    Returns void

  • #getTexture(): RenderTexture
  • Get a usable RenderTexture from the textures pool

    Returns RenderTexture