The Composite: The Fractal Tree
Treat individual nodes and compositions of nodes uniformly through Godot's built-in scene graph.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Composite
ARCANUM SCHOOL: Transmutation // Structuring
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
class_name GameComponent extends Node
func execute_logic() -> void:
push_error("Abstract execute_logic")
# Leaf Node
class_name TerminalNode extends GameComponent
func execute_logic() -> void:
print("Hacking the mainframe: ", self.name)
# Composite Node
class_name ComponentGroup extends GameComponent
func execute_logic() -> void:
print("Executing group: ", self.name)
for child in get_children():
if child is GameComponent:
child.execute_logic()
Godot’s Scene Tree is inherently a Composite pattern. However, explicitly defining shared interfaces allows your arcane systems to broadcast commands across a fractal hierarchy of nodes. Whether commanding a single combat drone or an entire swarm fleet, the invocation remains identical.
Runic Tags:
#godot
#gdscript
#composite
#nodes