HammeriteEntityTypeRegistry
Core: files, names and extension. Inherits RefCounted
Process-wide registry of entity types: each type's name, whether it is a point or brushwork, and the whole of what its entities carry, with the default of each.
In core rather than in the editor because the defaults are needed where the game runs. An entity holds only what it was given when it was made, so a lamp placed before a property existed has no key for it, and what it reads instead is the type's default - here, applied to its node by the entity base classes, with or without the editor. A game that ships without hammerite-editor registers its types here; with the editor, HammeriteMapEditor.register_point_entity_type() and the rest come here too. Keys beginning _editor_ are the editor's to read - an icon, a tint, what a property is for - and are never copied onto an entity. Core's own types are registered on first use, so they are there before any game or plugin adds to them, and with nothing but core installed: group, trigger, prop_model, decal, and the lights set (HammeriteEntitySets.lights()). Core's other sets are added by asking (add_set(), HammeriteEntitySets).
Methods
| Returns | Method |
|---|---|
bool | add_set(entity_set: HammeriteEntitySet) static |
StringName[] | brush_entity_bases() static |
void | clear() static |
PackedStringArray | entity_classes(brush: bool) static |
void | extend_brush(typename: StringName, props: Dictionary, base: StringName = &"") static |
void | extend_point(typename: StringName, props: Dictionary, base: StringName = &"") static |
Dictionary[StringName, Dictionary] | get_brush_types() static |
Dictionary | get_declared(typename: StringName) static |
Variant | get_default(typename: StringName, key: StringName, fallback = null) static |
Dictionary | get_defaults(typename: StringName) static |
Dictionary[StringName, Dictionary] | get_point_types() static |
HammeriteEntitySet | get_set(id: StringName) static |
HammeriteEntitySet[] | get_sets() static |
bool | has_set(id: StringName) static |
bool | has_type(typename: StringName) static |
bool | is_brush(typename: StringName) static |
bool | is_entity_class(entity_class, brush: bool) static |
bool | is_light(typename: StringName) static |
bool | is_point(typename: StringName) static |
StringName | key_rotation_axes() static |
StringName | light_kind_of(typename: StringName) static |
StringName[] | point_entity_bases() static |
void | register_brush(typename: StringName, props: Dictionary) static |
void | register_point(typename: StringName, props: Dictionary) static |
void | remove_set(id: StringName) static |
void | rename_class(old: StringName, new: StringName) static |
StringName | resolve_classname(classname: StringName) static |
StringName | set_of(typename: StringName) static |
void | unregister(typename: StringName) static |
Method descriptions
add_set()
static func add_set(entity_set: HammeriteEntitySet) -> bool
Add entity_set and declare its types, after any of its HammeriteEntitySet.includes not added yet; false, with the reason reported, when it was not - a set of that id is already added, or one it HammeriteEntitySet.requires is not. A type name already taken is reported and skipped, and the rest of the set is added. Add sets before building a map, so its entities are made with their types; with the editor, add them through HammeriteMapEditor.add_entity_set, which also gives it the set's pickers.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
brush_entity_bases()
static func brush_entity_bases() -> StringName[]
As point_entity_bases(), for a brush entity's class.
clear()
static func clear() -> void
Forget every type, core's included until something next asks. Test-support; a game registers once and leaves it.
entity_classes()
static func entity_classes(brush: bool) -> PackedStringArray
Every classname a point entity, or with brush a brush entity, can be given: the project's named classes and the native classes that is_entity_class() accepts and that can be instanced, sorted. Read from the global class list and the class database, so no script is loaded to answer.
extend_brush()
static func extend_brush(typename: StringName, props: Dictionary, base: StringName = &"") -> void
As extend_point(), for brushwork.
extend_point()
static func extend_point(typename: StringName, props: Dictionary, base: StringName = &"") -> void
Register typename as an existing type plus props - the base's properties, with these overriding the ones they share and adding the ones they do not. This is how a game says what its own lamp IS: Hammerite's light, and a style, and a name for the story to switch it by. base defaults to typename, which refines that type in place; naming a different base builds a new type out of an existing one, so a game can have light_candle that is a point light in every respect but two. A type derived from a light is a light the bake reads, as its base is (is_light()).
get_brush_types()
static func get_brush_types() -> Dictionary[StringName, Dictionary]
Every brush entity type, by name. A copy.
get_declared()
static func get_declared(typename: StringName) -> Dictionary
Everything typename declares, its editor's keys among them; empty for a type nobody registered. A copy.
get_default()
static func get_default(typename: StringName, key: StringName, fallback = null) -> Variant
The default of key that typename declares, or fallback where it declares none - an editor-only key included, which is the type's and never an entity's.
get_defaults()
static func get_defaults(typename: StringName) -> Dictionary
What an entity of typename carries until it is told otherwise: its declaration without the editor's keys.
get_point_types()
static func get_point_types() -> Dictionary[StringName, Dictionary]
Every point entity type, by name. A copy.
get_set()
static func get_set(id: StringName) -> HammeriteEntitySet
The set added as id, or null.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
get_sets()
static func get_sets() -> HammeriteEntitySet[]
Every added set, in the order they were added.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
has_set()
static func has_set(id: StringName) -> bool
Whether a set of id id has been added.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
has_type()
static func has_type(typename: StringName) -> bool
Undocumented.
is_brush()
static func is_brush(typename: StringName) -> bool
Undocumented.
is_entity_class()
static func is_entity_class(entity_class, brush: bool) -> bool
Whether entity_class - a script, or a class's name, a script's or a native one - extends one of the entity bases for a point entity, or with brush a brush entity: what an entity's classname has to name for HammeriteMap3D to build it. A base itself is not one.
is_light()
static func is_light(typename: StringName) -> bool
Whether entities of typename are lights a bake reads: one of HammeriteMap.light_types(), or a type derived from one.
is_point()
static func is_point(typename: StringName) -> bool
Undocumented.
key_rotation_axes()
static func key_rotation_axes() -> StringName
Which axes a type's entities turn about (#77): some of "xyz", or empty for a type that faces the way it was made. A type that declares any carries HammeriteEntity.key_rotation().
light_kind_of()
static func light_kind_of(typename: StringName) -> StringName
Which of HammeriteMap.light_types() typename bakes as - itself, for one of them - or empty for a type that is not a light.
point_entity_bases()
static func point_entity_bases() -> StringName[]
The classes a point entity's class must extend one of: the entity interface, on each kind of node.
register_brush()
static func register_brush(typename: StringName, props: Dictionary) -> void
As register_point(), for brushwork.
register_point()
static func register_point(typename: StringName, props: Dictionary) -> void
Declare a point entity type: props is the whole of what it has, and REPLACES any registration of that name. To change part of one that exists, use extend_point() - a re-registration that forgets one of the base type's properties is a property the entities in a game's maps quietly do not have.
remove_set()
static func remove_set(id: StringName) -> void
Take the set id away with every type it declared. Refused while another added set requires it. A map's entities of its types still load; they are built from their own properties alone.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
rename_class()
static func rename_class(old: StringName, new: StringName) -> void
Say that an entity naming old as its classname is made as new: a class renamed since maps were saved with it, which a map keeps by name and would otherwise build nothing for.
resolve_classname()
static func resolve_classname(classname: StringName) -> StringName
The class an entity naming classname is made as, following every rename_class().
set_of()
static func set_of(typename: StringName) -> StringName
The id of the set that declared typename, or empty for core's types, a game's own, and a name nobody registered.
Experimental: Not part of the supported API (docs/api-stability.md); it may change in any release.
unregister()
static func unregister(typename: StringName) -> void
Forget typename, point or brush. A map's entities of it still load; they are built from their own properties alone.