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.
Methods
| Returns | Method |
|---|---|
void | register_point(typename: StringName, props: Dictionary) static |
void | register_brush(typename: StringName, props: Dictionary) static |
void | extend_point(typename: StringName, props: Dictionary, base: StringName = &"") static |
void | extend_brush(typename: StringName, props: Dictionary, base: StringName = &"") static |
void | unregister(typename: StringName) static |
Dictionary[StringName, Dictionary] | get_point_types() static |
Dictionary[StringName, Dictionary] | get_brush_types() static |
bool | has_type(typename: StringName) static |
bool | is_point(typename: StringName) static |
bool | is_brush(typename: StringName) static |
bool | is_light(typename: StringName) static |
StringName | light_kind_of(typename: StringName) static |
Dictionary | get_declared(typename: StringName) static |
Variant | get_default(typename: StringName, key: StringName, fallback = null) static |
Dictionary | get_defaults(typename: StringName) static |
void | rename_class(old: StringName, new: StringName) static |
StringName | resolve_classname(classname: StringName) static |
bool | is_entity_class(script: Script, brush: bool) static |
PackedStringArray | entity_classes(brush: bool) static |
void | clear() static |
Constants
KEY_ROTATION_AXES
const KEY_ROTATION_AXES = &"_editor_rotation_axes"
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.
POINT_ENTITY_BASES
const POINT_ENTITY_BASES = Array[StringName]([&"HammeritePointEntityNode3D", &"HammeritePointEntityAnimatableBody3D", &"HammeritePointEntityRigidBody3D"])
The classes a point entity's class must extend one of: the entity interface, on each kind of node.
BRUSH_ENTITY_BASES
const BRUSH_ENTITY_BASES = Array[StringName]([&"HammeriteBrushEntityNode3D", &"HammeriteBrushEntityArea3D", &"HammeriteBrushEntityStaticBody3D"])
As POINT_ENTITY_BASES, for a brush entity's class.
Method descriptions
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.
register_brush()
static func register_brush(typename: StringName, props: Dictionary) -> void
As register_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()).
extend_brush()
static func extend_brush(typename: StringName, props: Dictionary, base: StringName = &"") -> void
As extend_point(), for brushwork.
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.
get_point_types()
static func get_point_types() -> Dictionary[StringName, Dictionary]
Every point entity type, by name. A copy.
get_brush_types()
static func get_brush_types() -> Dictionary[StringName, Dictionary]
Every brush entity type, by name. A copy.
has_type()
static func has_type(typename: StringName) -> bool
Undocumented.
is_point()
static func is_point(typename: StringName) -> bool
Undocumented.
is_brush()
static func is_brush(typename: StringName) -> bool
Undocumented.
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.
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.
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.
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().
is_entity_class()
static func is_entity_class(script: Script, brush: bool) -> bool
Whether script 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.
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 that is_entity_class() accepts and that can be instanced, sorted. Read from the global class list, so no script is loaded to answer.
clear()
static func clear() -> void
Forget every type, core's included until something next asks. Test-support; a game registers once and leaves it.