❌ HAXE TRANSMUTATION DIFFICULTY: Adept Structural

The Flyweight

Conserving memory through shared planar signatures

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Transmutation // Optimization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// HAXE PATTERN //
class ElementalRune {
    public var element(default, null):String;
    public var color(default, null):String;

    public function new(element:String, color:String) {
        this.element = element;
        this.color = color;
    }

    public function display(x:Int, y:Int):Void {
        trace('Displaying $color $element rune at ($x, $y)');
    }
}

class RuneFactory {
    private var cache:Map<String, ElementalRune>;

    public function new() {
        cache = new Map<String, ElementalRune>();
    }

    public function getRune(element:String, color:String):ElementalRune {
        var key = element + "_" + color;
        if (!cache.exists(key)) {
            cache.set(key, new ElementalRune(element, color));
            trace('Materializing new intrinsic rune: $key');
        }
        return cache.get(key);
    }
}

When a grand ritual demands thousands of floating runes, manifesting each object individually devours system memory. The Flyweight shares intrinsic states (like the element and color) across a unified cache, leaving only extrinsic coordinates to vary. Perfect for low-memory planar projections.

Runic Tags: #transmutation #flyweight #haxe