add bool constant and if true nodes

This commit is contained in:
Lera Elvoé 2023-12-05 02:02:02 +03:00
parent 26bf7cf0b3
commit dbdda4614a
No known key found for this signature in database
3 changed files with 53 additions and 1 deletions

View file

@ -0,0 +1,20 @@
extends DeckNode
func _init() -> void:
name = "Bool Constant"
node_type = name.to_snake_case()
category = "general"
add_output_port(
DeckType.Types.BOOL,
"Value",
"checkbox"
)
func _value_request(_from_port: int) -> Variant:
if ports[0].value_callback.get_object():
return ports[0].value_callback.call()
else:
return ports[0].value

View file

@ -0,0 +1,33 @@
extends DeckNode
func _init() -> void:
name = "Pass If True"
node_type = "if_true"
description = "Pass input if and only if the condition input is true."
category = "general"
add_input_port(
DeckType.Types.BOOL,
"Condition",
"checkbox"
)
add_input_port(
DeckType.Types.ANY,
"Input"
)
add_output_port(
DeckType.Types.ANY,
"Output"
)
func _receive(to_input_port: int, data: Variant, extra_data: Array = []) -> void:
if to_input_port != 1:
return
if !request_value(0):
return
send(0, data, extra_data)

View file

@ -178,7 +178,6 @@ func _on_category_collapse_toggled(collapsed: bool, category: String) -> void:
class Category extends VBoxContainer:
const COLLAPSE_ICON := preload("res://graph_node_renderer/textures/collapse-icon.svg")
const COLLAPSE_ICON_COLLAPSED := preload("res://graph_node_renderer/textures/collapse-icon-collapsed.svg")
var collapse_button: Button
## Emitted when a child item has been pressed.