HammeriteReferences
Core: files, names and extension. Inherits RefCounted
What a map names that lives outside it - a texture, a model, a sound, a scene somebody plays out - and who provided each one when the map was saved (#86).
A property says it names a thing of some KIND (declare_entity_property() and its face twin; a brush property says so on its def, HammeriteBrushPropertyDef.set_reference()). Hammerite knows a few kinds of its own and nothing of what the rest mean: the game answers who provides a name through set_resolver(). A kind nobody answers for counts as the game's own (BASE), and is warned of once. record() writes the answers into HammeriteMap.references whenever the map is saved - HammeriteDataFile.write() does it - and check() asks again after it is loaded. What changed in between is reported, never acted on: whether a missing sound is a warning or a reason to refuse the map is the game's call.
Methods
| Returns | Method |
|---|---|
void | declare_entity_property(entity_type: StringName, property: StringName, kind: StringName, list: bool = false) static |
void | undeclare_entity_property(entity_type: StringName, property: StringName) static |
void | declare_brush_property(key: StringName, kind: StringName, list: bool = false) static |
void | undeclare_brush_property(key: StringName) static |
void | declare_face_property(key: StringName, kind: StringName, list: bool = false) static |
void | undeclare_face_property(key: StringName) static |
void | set_resolver(kind: StringName, resolver: Callable) static |
void | reset_resolvers() static |
Dictionary | provided_by(provider: String, version: String = "") static |
Dictionary | provided_if(present: bool) static |
Dictionary | resolve(kind: StringName, name: String) static |
Dictionary[StringName, PackedStringArray] | collect(map: HammeriteMap) static |
void | record(map: HammeriteMap) static |
HammeriteReferenceChange[] | check(map: HammeriteMap) static |
Constants
TEXTURE
const TEXTURE = &"texture"
A face's texture, by HammeriteTextureLibrary name. Every face's texture is collected without being declared.
DECAL
const DECAL = &"decal"
A decal texture, looked up in HammeriteTextureLibrary.DECALS.
MODEL
const MODEL = &"model"
A model, by HammeriteModelLibrary name.
ENTITY_CLASS
const ENTITY_CLASS = &"entity_class"
The script an entity is made as: its classname.
BASE
const BASE = "base"
Who provides whatever the game itself ships.
Method descriptions
declare_entity_property()
static func declare_entity_property(entity_type: StringName, property: StringName, kind: StringName, list: bool = false) -> void
Say that property of an entity of entity_type - every type, when empty - names a thing of kind. A list holds several names, separated by commas or spaces.
undeclare_entity_property()
static func undeclare_entity_property(entity_type: StringName, property: StringName) -> void
Take back what declare_entity_property() said, as a mod being unloaded does.
declare_brush_property()
static func declare_brush_property(key: StringName, kind: StringName, list: bool = false) -> void
Say that brush property key names a thing of kind on every brush. For a property whose def is not the declaring addon's to change; its own says it with HammeriteBrushPropertyDef.set_reference(). list as in declare_entity_property().
undeclare_brush_property()
static func undeclare_brush_property(key: StringName) -> void
Take back what declare_brush_property() said.
declare_face_property()
static func declare_face_property(key: StringName, kind: StringName, list: bool = false) -> void
Say that key in HammeriteFace.properties names a thing of kind on every face. list as in declare_entity_property().
undeclare_face_property()
static func undeclare_face_property(key: StringName) -> void
Take back what declare_face_property() said.
set_resolver()
static func set_resolver(kind: StringName, resolver: Callable) -> void
Who provides a name of kind: resolver takes the name and returns a Dictionary - provided_by() someone, provided_if() the game has it, or empty when nothing does. Replaces Hammerite's own answer for its kinds, which only knows whether the game has the thing at all.
reset_resolvers()
static func reset_resolvers() -> void
Forget every resolver the game set, leaving Hammerite's own.
provided_by()
static func provided_by(provider: String, version: String = "") -> Dictionary
What a resolver answers for a name provider provides, at version.
provided_if()
static func provided_if(present: bool) -> Dictionary
What a resolver answers for a name the game itself provides when present, and for a missing one otherwise.
resolve()
static func resolve(kind: StringName, name: String) -> Dictionary
Who provides name now, as {"provider", "version"}, or empty when nothing does.
collect()
static func collect(map: HammeriteMap) -> Dictionary[StringName, PackedStringArray]
Every name map uses, by kind, each once and in order.
record()
static func record(map: HammeriteMap) -> void
Write down who provides everything map uses, as it is now, into HammeriteMap.references. Done by every save (HammeriteDataFile.write()), on the thread that asks for it: the resolvers are the game's, and written for the main thread.
check()
static func check(map: HammeriteMap) -> HammeriteReferenceChange[]
What is different about what map uses since it was saved: a name nothing provides any more, one someone else provides now, or one whose provider has a new version. Every name it uses now is checked, and every one recorded when it was saved, so a name added since, or a map never recorded, is still checked for what is missing.