The Prototype: Astral Cloning
Duplicate existing node structures and their state, avoiding the high cost of raw initialization.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Illusion // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class_name SpellProjectile extends Area2D
var damage: int = 10
var element: String = "Void"
# The Prototype clone method
func clone() -> SpellProjectile:
var copy = self.duplicate(DUPLICATE_USE_INSTANTIATION | DUPLICATE_SCRIPTS) as SpellProjectile
copy.damage = self.damage
copy.element = self.element
return copy
Within Godot’s node hierarchy, cloning is an ancient trick of the trade. The Prototype pattern embraces the built-in duplicate() method, allowing the swift replication of fully configured prefabs. This bypasses the heavy initialization rituals and copies the precise runtime state of your astral constructs.
Runic Tags:
#godot
#gdscript
#prototype
#clone