extends Node signal changed var _state_hints : Array = [] # [{action, text}] var _context_hints : Dictionary = {} # clé (objet source) -> {action, text, priority} #---------- hints d'état (appelés par la StateMachine) ---------- func set_state_hints(list : Array) -> void: _state_hints = list changed.emit() #---------- hints de contexte (appelés par monture, PNJ, etc.) ---------- func set_context(source : Object, action : StringName, text : String, priority : int = 0) -> void: var h : Dictionary = {"action": action, "text": text, "priority": priority} if _context_hints.get(source) == h: return _context_hints[source] = h changed.emit() func clear_context(source : Object) -> void: if _context_hints.erase(source): changed.emit() #---------- lecture (par le HUD) ---------- func get_visible() -> Array: #nettoie les sources détruites sans avoir appelé clear_context for key in _context_hints.keys(): if !is_instance_valid(key): _context_hints.erase(key) var ctx : Array = _context_hints.values() ctx.sort_custom(func(a, b): return a.priority > b.priority) #le contexte passe avant l'état ; une même action n'apparaît qu'une fois var result : Array = [] var used : Dictionary = {} for h in ctx + _state_hints: if used.has(h.action): continue used[h.action] = true result.append(h) return result