miggor-StreamGraph/classes/util.gd
Lera Elvoé f43c5ecafd add utility method to connect to a signal safely (#103)
Reviewed-on: https://codeberg.org/StreamGraph/StreamGraph/pulls/103
Co-authored-by: Lera Elvoé <yagich@poto.cafe>
Co-committed-by: Lera Elvoé <yagich@poto.cafe>
2024-03-14 06:42:02 +00:00

10 lines
391 B
GDScript

# (c) 2023-present Eroax
# (c) 2023-present Yagich
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
class_name Util
## Connects the [param p_func] to [param p_signal] if that connection doesn't already exist.
static func safe_connect(p_signal: Signal, p_func: Callable) -> void:
if not p_signal.is_connected(p_func):
p_signal.connect(p_func)