|
123456789101112131415161718192021222324252627282930313233343536 |
- extends Node
-
- signal message(msg)
- signal value_passed(name, v)
-
- const EMIT_RATE = 0.1
-
- var _timer_message : float = 0.0
- var _timer_pass_val : float = 0.0
-
- var _msg_buffer = []
- var _pass_val_buffer = []
-
- func _msgformat(msg : String, args : Array) -> String:
- for i in range(0, args.size()):
- msg = msg.format(args[i], "$" + String(i))
- return msg
-
- func message(msg : String, args : Array = []) -> void:
- if _timer_message <= 0.0:
- emit_signal("message", _msgformat(msg, args))
- _timer_message = EMIT_RATE
- else:
- _msg_buffer.append(_msgformat(msg, args))
-
-
- func pass_value(name : String, val) -> void:
- emit_signal("value_passed", name, val)
-
- func _process(delta : float) -> void:
- if _timer_message > 0.0:
- _timer_message = max(0.0, _timer_message - delta)
- if _timer_message == 0.0 and _msg_buffer.size() > 0:
- emit_signal("message", _msg_buffer)
- _msg_buffer = []
-
|