class_name PresentationEvent extends RefCounted ## A display-only, immutable translation of one authoritative GameEvent. ## Snapshot data belongs to this class, not an instance, so direct writes cannot ## create mutable instance state. Getter calls return a fresh source snapshot. ## RefCounted teardown cannot safely call script methods, so the static store is ## intentionally process-lifetime; entries contain only frozen presentation data. const FORMER_BACKING_PROPERTIES := [ &"_backing_values", &"_is_initialized", &"_source_event", &"_kind", &"_notification", &"_accent", ] static var _snapshots: Dictionary[int, Dictionary] = {} var source_event: GameEvent: get: return _copy_event(_snapshot()[&"source_event"] as GameEvent) var kind: StringName: get: return _snapshot()[&"kind"] as StringName var notification: String: get: return _snapshot()[&"notification"] as String var accent: Color: get: return _snapshot()[&"accent"] as Color func _init(source: GameEvent, presentation_kind: StringName, text: String = "", color: Color = Color.WHITE) -> void: _snapshots[get_instance_id()] = { &"source_event": _copy_event(source), &"kind": presentation_kind, &"notification": text if not text.is_empty() else source.message, &"accent": color, } ## Former fields are intentionally undeclared. _set absorbs legacy direct writes ## without creating per-instance storage or changing the captured snapshot. func _set(property: StringName, _value: Variant) -> bool: return property in FORMER_BACKING_PROPERTIES func _snapshot() -> Dictionary: return _snapshots.get(get_instance_id(), {}) as Dictionary static func _copy_event(event: GameEvent) -> GameEvent: return GameEvent.new( event.turn, event.floor, event.kind, event.payload, event.message, event.actor_id, event.target_id, event.cell, )