Options
All
  • Public
  • Public/Protected
  • All
Menu

A Detection Mode which can be associated with any kind of sense/vision/perception. A token could have multiple detection modes.

Hierarchy

Index

Constructors

  • new DetectionMode(data?: {}, __namedParameters?: { parent: any; strict: boolean }): DetectionMode

Methods

  • Test visibility of a target object or array of points for a specific vision source.

    Parameters

    • visionSource: VisionSource

      The vision source being tested

    • mode: TokenDetectionMode

      The detection mode configuration

    • config: CanvasVisibilityTestConfig = {}

      The visibility test configuration

    Returns boolean

    Is the test target visible?

  • reset(): void
  • Reset the state of this data instance back to mirror the contained source data, erasing any changes.

    Returns void

  • clone(data?: any, context?: any): Document | Promise<Document>
  • Clone a model, creating a new data model by combining current data with provided overrides.

    Parameters

    • data: any = {}
    • context: any = {}

    Returns Document | Promise<Document>

    The cloned Document instance

  • validate(options?: { changes: any; clean: boolean; fallback: boolean; strict: boolean; fields: boolean; joint: boolean }): boolean
  • Validate the data contained in the document to check for type and content This function throws an error if data within the document is not valid

    Parameters

    • options: { changes: any; clean: boolean; fallback: boolean; strict: boolean; fields: boolean; joint: boolean } = {}

      Optional parameters which customize how validation occurs.

      • changes: any
      • clean: boolean
      • fallback: boolean
      • strict: boolean
      • fields: boolean
      • joint: boolean

    Returns boolean

    An indicator for whether the document contains valid data

  • updateSource(changes?: any, options?: any): any
  • Update the DataModel locally by applying an object of changes to its source data. The provided changes are cleaned, validated, and stored to the source data object for this model. The source data is then re-initialized to apply those changes to the prepared data. The method returns an object of differential changes which modified the original data.

    Parameters

    • changes: any = {}

      New values which should be applied to the data model

    • options: any = {}

    Returns any

    An object containing the changed keys and values

  • toObject(source?: boolean): any
  • Copy and transform the DataModel into a plain object. Draw the values of the extracted object from the data source (by default) otherwise from its transformed values.

    Parameters

    • source: boolean = true

    Returns any

    The extracted primitive object

  • toJSON(): any
  • Extract the source data for the DataModel into a simple object format that can be serialized.

    Returns any

    The document source data expressed as a plain object

  • Can this VisionSource theoretically detect a certain object based on its properties? This check should not consider the relative positions of either object, only their state.

    Parameters

    Returns boolean

    Can the target object theoretically be detected by this vision source?

  • Evaluate a single test point to confirm whether it is visible. Standard detection rules require that the test point be both within LOS and within range.

    Parameters

    Returns boolean

  • Test whether the line-of-sight requirement for detection is satisfied. Always true if the detection mode bypasses walls, otherwise the test point must be contained by the LOS polygon. The result of is cached for the vision source so that later checks for other detection modes do not repeat it.

    Parameters

    Returns boolean

    Is the LOS requirement satisfied for this test?

  • Verify that a target is in range of a source.

    Parameters

    Returns boolean

    Is the target within range?

  • _configure(options?: {}): void
  • Configure the data model instance before validation and initialization workflows are performed.

    Parameters

    • options: {} = {}

      Returns void

    • _initializeSource(data: any, options?: any): any
    • Initialize the source data for a new DataModel instance. One-time migrations and initial cleaning operations are applied to the source data.

      Parameters

      • data: any

        The candidate source data from which the model will be constructed

      • options: any = {}

      Returns any

      Migrated and cleaned source data which will be stored to the model instance

    • _initialize(options?: any): void
    • Initialize the instance by copying data from the source object to instance attributes. This mirrors the workflow of SchemaField#initialize but with some added functionality.

      Parameters

      • options: any = {}

      Returns void

    • _validateModel(data: any): void
    • Jointly validate the overall data model after each field has been individually validated.

      throws

      An error if a validation failure is detected

      Parameters

      • data: any

        The candidate data object to validate

      Returns void

    • getDetectionFilter(): any
    • Get the detection filter pertaining to this mode.

      Returns any

    • cleanData(source?: any, options?: any): any
    • Clean a data source object to conform to a specific provided schema.

      Parameters

      • source: any = {}
      • options: any = {}

      Returns any

      The cleaned source data

    • formatValidationErrors(errors: any, [options={}]?: { label: string; namespace: string }): string
    • Get an array of validation errors from the provided error structure

      Parameters

      • errors: any
      • [options={}]: { label: string; namespace: string } = {}
        • label: string
        • namespace: string

      Returns string

    • fromSource(source: any, [context]?: { strict: boolean }): DataModel
    • Create a new instance of this DataModel from a source record. The source is presumed to be trustworthy and is not strictly validated.

      Parameters

      • source: any

        Initial document data which comes from a trusted source.

      • [context]: { strict: boolean } = {}

        Model construction context

        • strict: boolean

      Returns DataModel

    • Create a DataModel instance using a provided serialized JSON string.

      Parameters

      • json: string

        Serialized document data in string format

      Returns DataModel

      A constructed data model instance

    • migrateData(source: any): any
    • Migrate candidate source data for this DataModel which may require initial cleaning or transformations.

      Parameters

      • source: any

        The candidate source data from which the model will be constructed

      Returns any

      Migrated source data, if necessary

    • migrateDataSafe(source: any): any
    • Wrap data migration in a try/catch which attempts it safely

      Parameters

      • source: any

        The candidate source data from which the model will be constructed

      Returns any

      Migrated source data, if necessary

    • shimData(data: any, [options={}]?: { embedded: boolean }): any
    • Take data which conforms to the current data schema and add backwards-compatible accessors to it in order to support older code which uses this data.

      Parameters

      • data: any

        Data which matches the current schema

      • [options={}]: { embedded: boolean } = {}

        Additional shimming options

        • embedded: boolean

      Returns any

      Data with added backwards-compatible properties

    Properties

    _source: any

    The source data object for this DataModel instance. Once constructed, the source object is sealed such that no keys may be added nor removed.

    parent: DataModel

    An immutable reverse-reference to a parent DataModel to which this model belongs.

    _detectionFilter: any

    An optional filter to apply on the target when it is detected with this mode.

    DETECTION_TYPES: { SIGHT: number; SOUND: number; MOVE: number; OTHER: number } = ...

    The type of the detection mode. If its sight based, sound based, etc. It is related to wall's WALL_RESTRICTION_TYPES

    see

    CONST.WALL_RESTRICTION_TYPES

    Type declaration

    • SIGHT: number
    • SOUND: number
    • MOVE: number
    • OTHER: number
    BASIC_MODE_ID: string = "basicSight"

    The identifier of the basic sight detection mode.

    Accessors

    • Define the data schema for this document instance.

      Returns SchemaField

    • get invalid(): boolean
    • Is the current state of this DataModel invalid?

      Returns boolean

    • Define the data schema for documents of this type.

      Returns SchemaField