Say in my project I am making a rather complex UI element. The main script at the root node is a class named "Message" and it uses signals to tell the potential children to update themselves accordingly.
In the children's code I implement something like the following:
func _ready():
connect_signals()
func connect_signals():
var root: Message = owner as Message
root.message_new.connect(_set_new_text)
root.next_char.connect(_show_next_char)
root.message_end.connect(_show_entire_message)
However, I could also do it like so:
func _ready():
connect_signals()
func connect_signals():
(owner as Message).message_new.connect(_set_new_text)
(owner as Message).next_char.connect(_show_next_char)
(owner as Message).message_end.connect(_show_entire_message)
Now, I know that in the second case I am casting three times instead of one. But is the first really the best way to do this process in static typed code? Is there a better way to do this?