HammeriteBrushFillRegistry
Core: files, names and extension. Inherits RefCounted
Process-wide registry of the fills an air brush can be filled with, and the classes a game wants instantiated over them.
The extension point of the pair: core knows that a room can be full of something and what that does to its surfaces, and knows nothing about what being in water DOES. A game registers the node it wants over every water volume - buoyancy, drowning, the sound of it - and core instantiates it the way it instantiates a brush entity's class. In core rather than the editor, for HammeriteBrushPropertyRegistry's reason: HammeriteBrush.fill is serialized on the brush, so a shipped game with no editor present still has to resolve what a fill means. Register from an addon's runtime facade, not only from its editor plugin. Core ships WATER because the lightmapper already has water in it - caustics, transmission - and had been inferring it from texture names. A game puts its own class over water, and draws water its own way, without registering it again:
HammeriteBrushFillRegistry.set_classname(&"water", &"FuncWater")
HammeriteBrushFillRegistry.set_material(&"water", preload("res://materials/our_water.tres"))A fill of the game's own is register_fill(). Either may be done after a map is built, which draws its filled rooms again; a brush entity holding water takes a new material when it is next rebuilt. The node. A fill's class must be a Node with a constructor that takes no arguments. One is made for each filled air brush and handed, if it has them, set_map_3d(map_3d: HammeriteMap3D) and set_brush(brush: HammeriteBrush), then added under the map. It goes when the brush's fill or tier changes, or the brush does.
Methods
| Returns | Method |
|---|---|
void | register_fill(fill_id: StringName, label: String, classname: StringName = &"", color: Color = Color(0.2, 0.5, 0.7, 1), material: ShaderMaterial = null) static |
void | register(fill: HammeriteBrushFill) static |
void | unregister(fill_id: StringName) static |
void | set_classname(fill_id: StringName, classname: StringName) static |
void | set_material(fill_id: StringName, material: ShaderMaterial) static |
ShaderMaterial | material_of(fill_id: StringName) static |
void | clear() static |
HammeriteBrushFill[] | get_fills() static |
int | revision() static |
HammeriteBrushFill | get_fill(fill_id: StringName) static |
bool | has_fill(fill_id: StringName) static |
Constants
WATER
const WATER = &"water"
The fill core ships. Everything else is registered by whoever wants it.
STOCK_WATER_MATERIAL
const STOCK_WATER_MATERIAL = <Object>
What WATER's surface is drawn with until a game says otherwise: its clarity and how disturbed it is, and nothing more (water.gdshader).
Method descriptions
register_fill()
static func register_fill(fill_id: StringName, label: String, classname: StringName = &"", color: Color = Color(0.2, 0.5, 0.7, 1), material: ShaderMaterial = null) -> void
Register a fill an air brush can be filled with: fill_id is what the brush stores, label what an author picks, classname the node made over each filled brush (empty for none), color how the editor shows it, and material what its surface is drawn with (null for its texture). Replaces a fill already registered under fill_id, where it stood.
register()
static func register(fill: HammeriteBrushFill) -> void
Register fill, replacing any fill already registered under the same id where it stood. A replacement with no HammeriteBrushFill.material keeps the one the fill had, so a game re-registering core's water still draws it as water; set_material() with null draws it as its texture.
unregister()
static func unregister(fill_id: StringName) -> void
Drop the fill registered under fill_id, if any. Brushes filled with it keep the id they were authored with - an unregistered fill is an unknown fill, not a cleared one, so re-registering brings them back rather than leaving the map edited behind the author's back.
set_classname()
static func set_classname(fill_id: StringName, classname: StringName) -> void
Point the fill registered under fill_id at a game's class, leaving the rest of it alone. The common case for a game: core's water, its own water node.
set_material()
static func set_material(fill_id: StringName, material: ShaderMaterial) -> void
Draw the surface of the fill registered under fill_id with material - a copy of it for each surface, with the brush's properties set on the copy: every property declared by a schema whose HammeriteBrushPropertySchema.fill is this fill, each as the uniform named after it (lava/glow as lava_glow). For water, a shader built on hammerite_water.gdshaderinc; null draws the surface as its texture.
material_of()
static func material_of(fill_id: StringName) -> ShaderMaterial
What the surface of fill_id is drawn with, or null for its texture - and for a fill nothing has registered.
clear()
static func clear() -> void
Forget every fill, core's included until something next asks, as HammeriteBrushPropertyRegistry.clear() does. Test-support; production code registers once.
get_fills()
static func get_fills() -> HammeriteBrushFill[]
Every registered fill, in registration order, core's first; a fill registered again keeps its place. A copy.
revision()
static func revision() -> int
Changes whenever a fill is registered, taken away or changed, so a built map can tell its filled rooms are drawn from an old answer.
get_fill()
static func get_fill(fill_id: StringName) -> HammeriteBrushFill
The fill registered under fill_id, or null when nothing is - which is what an air brush carrying a fill from an addon that is not loaded looks like.
has_fill()
static func has_fill(fill_id: StringName) -> bool
Whether fill_id names a fill anything has registered.