The source data object for this DataModel instance. Once constructed, the source object is sealed such that no keys may be added nor removed.
An immutable reverse-reference to a parent DataModel to which this model belongs.
Static
_detectionAn optional filter to apply on the target when it is detected with this mode.
Static
LOCALIZATION_A set of localization prefix paths which are used by this DataModel.
Define the data schema for this document instance.
Is the current state of this DataModel invalid? The model is invalid if there is any unresolved failure.
An array of validation failure instances which may have occurred when this instance was last validated.
Static
schemaThe Data Schema for all instances of this DataModel.
Test visibility of a target object or array of points for a specific vision source.
The vision source being tested
The detection mode configuration
The visibility test configuration
Is the test target visible?
Clone a model, creating a new data model by combining current data with provided overrides.
Optional
data: Object = {}Additional data which overrides current document data at the time of creation
Optional
context: object = {}Context options passed to the data model constructor
The cloned Document instance
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
Optional parameters which customize how validation occurs.
A specific set of proposed changes to validate, rather than the full source data of the model.
If changes are provided, attempt to clean the changes before validating them?
Allow replacement of invalid values with valid defaults?
If true, invalid embedded documents will emit a warning and be placed in the invalidDocuments collection rather than causing the parent to be considered invalid.
Throw if an invalid value is encountered, otherwise log a warning?
Perform validation on individual fields?
Perform joint validation on the full data model? Joint validation will be performed by default if no changes are passed. Joint validation will be disabled by default if changes are passed. Joint validation can be performed on a complete set of changes (for example testing a complete data model) by explicitly passing true.
An indicator for whether the document contains valid data
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.
New values which should be applied to the data model
Optional
options: object = {}Options which determine how the new data is merged
An object containing the changed keys and values
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.
Optional
source: boolean = trueDraw values from the underlying data source rather than transformed values
The extracted primitive object
Protected
_testProtected
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.
The vision source being tested
The detection mode configuration
The target object being tested
The test case being evaluated
Protected
_testLOSProtected
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.
The vision source being tested
The detection mode configuration
The target object being tested
The test case being evaluated
Is the LOS requirement satisfied for this test?
Protected
_testProtected
Test whether the target is within the vision angle.
The vision source being tested
The detection mode configuration
The target object being tested
The test case being evaluated
Is the point within the vision angle?
Protected
_testProtected
Verify that a target is in range of a source.
The vision source being tested
The detection mode configuration
The target object being tested
The test case being evaluated
Is the target within range?
Protected
_configureProtected
_initializeProtected
Initialize the source data for a new DataModel instance. One-time migrations and initial cleaning operations are applied to the source data.
The candidate source data from which the model will be constructed
Optional
options: object = {}Options provided to the model constructor
Migrated and cleaned source data which will be stored to the model instance
Protected
_initializeProtected
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.
Optional
options: object = {}Options provided to the model constructor
Static
getStatic
defineDefine the data schema for documents of this type. The schema is populated the first time it is accessed and cached for future reuse.
Static
cleanStatic
validateEvaluate joint validation rules which apply validation conditions across multiple fields of the model. Field-specific validation rules should be defined as part of the DataSchema for the model. This method allows for testing aggregate rules which impose requirements on the overall model.
Candidate data for the model
An error if a validation failure is detected
Static
fromCreate a new instance of this DataModel from a source record. The source is presumed to be trustworthy and is not strictly validated.
Initial document data which comes from a trusted source.
Optional
context: any = {}Model construction context
Static
fromJSONStatic
migrateStatic
migrateStatic
shimTake 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.
Data which matches the current schema
Optional
options: { Additional shimming options
Apply shims to embedded models?
Data with added backwards-compatible properties
Static
Protected
_initialization
Detection mode that see creatures in contact with the ground.