HammeritePrefab

Core: the map. Inherits Resource

A prefab containing brushes and entities.

Prefabs are reusable templates that can be instantiated in maps. Each instance tracks its source prefab via prefab_id.

Properties

TypeNameDefault
intprefab_id0
Stringprefab_name"Untitled Prefab"
HammeriteBrush[]brushes[]
HammeriteEntity[]entities[]
Texture2Dpreview_texturenull
String[]tags[]
Stringcategory""
AABBaabbAABB(0, 0, 0, 0, 0, 0)

Methods

ReturnsMethod
HammeritePrefabInstanceinstantiate(map: HammeriteMap, at: Transform3D, layer_id: int = 0)
HammeritePrefab.Placementbuild_instance(map: HammeriteMap, at: Transform3D, layer_id: int = 0)
boolis_valid()
boolgenerate_thumbnail(generator: HammeriteThumbnailGenerator)
boolhas_thumbnail()
voidupdate_from_instance(instance: HammeritePrefabInstance, map: HammeriteMap)

Signals

prefab_updated

signal prefab_updated()

Emitted by update_from_instance() once the prefab's content has been replaced.

Property descriptions

prefab_id

var prefab_id: int = 0

Unique identifier for this prefab across prefab sets, nonzero once assigned (the editor draws it from ResourceUID.create_id()). Brushes and entities placed from it carry it as their prefab_id.

prefab_name

var prefab_name: String = "Untitled Prefab"

Display name of the prefab. Must be non-empty for is_valid().

brushes

var brushes: HammeriteBrush[] = []

Brushes contained in this prefab, in prefab-local space (relative to the instance transform).

entities

var entities: HammeriteEntity[] = []

Entities contained in this prefab, their origins in prefab-local space.

preview_texture

var preview_texture: Texture2D = null

Preview texture for the prefab browser, set by generate_thumbnail(). Saved with the prefab.

tags

var tags: String[] = []

Words to find the prefab by: the author's, for a browser or a game to filter on. Nothing in Hammerite reads them.

category

var category: String = ""

Category for organization in the browser.

aabb

var aabb: AABB = AABB(0, 0, 0, 0, 0, 0)

Axis-aligned bounds of the prefab content in prefab-local space. Recomputed by update_from_instance(); otherwise whatever it was saved with.

Method descriptions

instantiate()

func instantiate(map: HammeriteMap, at: Transform3D, layer_id: int = 0) -> HammeritePrefabInstance

Place this prefab in map at at, on layer layer_id: its brushes and entities copied with ids of map's own, carried into map space and added, with the instance that owns them. Null for a prefab that is not is_valid(). What a game calls to put one down at runtime; build_instance() is the same without adding anything.

build_instance()

func build_instance(map: HammeriteMap, at: Transform3D, layer_id: int = 0) -> HammeritePrefab.Placement

instantiate() without adding anything to map: for a caller that adds the placement itself, as the editor does inside one undoable action. Ids are drawn from map all the same.

is_valid()

func is_valid() -> bool

Whether the prefab can be placed: a nonzero prefab_id, a non-empty prefab_name and at least one brush or entity.

generate_thumbnail()

func generate_thumbnail(generator: HammeriteThumbnailGenerator) -> bool

Generate or regenerate the preview thumbnail for this prefab. A coroutine: await it. Returns true if preview_texture was set, false when generator is null.

has_thumbnail()

func has_thumbnail() -> bool

Whether preview_texture is set.

update_from_instance()

func update_from_instance(instance: HammeritePrefabInstance, map: HammeriteMap) -> void

Update the prefab content from a live instance. Copies all brushes and entities from the instance, transforming them to be relative to the prefab origin. instance must be of this prefab (same prefab_id), or nothing changes and an error is printed. Emits prefab_updated. Entities are carried into prefab space with HammeriteEntity.transform_by(): origin and turn.

class Placement

What build_instance() makes: the instance record, and the brushes and entities it owns, ready to add to the map.

Properties

TypeNameDefault
HammeritePrefabInstanceinstancenull
HammeriteBrush[]brushes[]
HammeriteEntity[]entities[]

Property descriptions

instance

var instance: HammeritePrefabInstance = null

The instance record, for HammeriteMap.add_prefab_instance().

brushes

var brushes: HammeriteBrush[] = []

Copies of HammeritePrefab.brushes, placed and owned by instance.

entities

var entities: HammeriteEntity[] = []

Copies of HammeritePrefab.entities, placed and owned by instance.

Hammerite 1.0 · built from a6dd634, 2026-10-10