Files
DungeonCrawlerWorld/scripts/presentation/presentation_event.gd
T

45 lines
1.0 KiB
GDScript

class_name PresentationEvent
extends RefCounted
## A display-only, immutable translation of one authoritative GameEvent.
## Getter calls return a fresh source snapshot so presentation code cannot mutate
## the source domain event or this adapter's captured event data.
var _source_event: GameEvent
var _kind: StringName
var _notification: String
var _accent: Color
var source_event: GameEvent:
get:
return _copy_event(_source_event)
var kind: StringName:
get:
return _kind
var notification: String:
get:
return _notification
var accent: Color:
get:
return _accent
func _init(source: GameEvent, presentation_kind: StringName, text: String = "", color: Color = Color.WHITE) -> void:
_source_event = _copy_event(source)
_kind = presentation_kind
_notification = text if not text.is_empty() else source.message
_accent = color
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,
)