A base type for a Registry, which is an object which handles loading scriptable objects.
Parameters:
T | The type to construct. Must implement |
|---|---|
J | The type of the JSON data used when constructing. |
P | The type of the parameters used for |
Constructor
new(registryId:String, dataFilePath:String, ?versionRule:VersionRule)
Parameters:
registryId | A readable ID for this registry, used when logging. |
|---|---|
dataFilePath | The path (relative to |
Variables
Methods
fetchEntry(id:String, ?params:P):Null<T>
Fetch an entry by its ID.
Parameters:
id | The ID of the entry to fetch. |
|---|
Returns:
The entry, or null if it does not exist.
fetchEntryVersion(id:String):Null<Version>
Retrieve the data for an entry and parse its Semantic Version.
Parameters:
id | The ID of the entry. |
|---|
Returns:
The entry's version, or null if it does not exist or is invalid.
getScriptedEntryClassName(id:String, ?params:P):Null<String>
Return the class name of the scripted entry with the given ID, if it exists.
Parameters:
id | The ID of the entry. |
|---|
Returns:
The class name, or null if it does not exist.
hasEntry(id:String):Bool
Return whether the registry has successfully parsed an entry with the given ID.
Parameters:
id | The ID of the entry. |
|---|
Returns:
true if the entry exists, false otherwise.
isScriptedEntry(id:String, ?params:P):Bool
Return whether the entry ID is known to have an attached script.
Parameters:
id | The ID of the entry. |
|---|
Returns:
true if the entry has an attached script, false otherwise.
listEntryIds():Array<String>
Retrieve a list of all entry IDs in this registry.
Returns:
The list of entry IDs.
parseEntryData(id:String):Null<J>
Read, parse, and validate the JSON data and produce the corresponding data object.
NOTE: Must be implemented on the implementation class.
Parameters:
id | The ID of the entry. |
|---|
Returns:
The created entry.
parseEntryDataRaw(contents:String, ?fileName:String):Null<J>
Parse and validate the JSON data and produce the corresponding data object.
NOTE: Must be implemented on the implementation class.
Parameters:
contents | The JSON as a string. |
|---|---|
fileName | An optional file name for error reporting. |
Returns:
The created entry.
parseEntryDataWithMigration(id:String, version:Null<Version>):Null<J>
Read, parse, and validate the JSON data and produce the corresponding data object, accounting for old versions of the data.
NOTE: Extend this function to handle migration.
Parameters:
id | The ID of the entry. |
|---|---|
version | The entry's version (use |
Returns:
The created entry.