From fb2bd08ab020892a0409fa6044aac4f297ca2d01 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Sun, 4 Aug 2024 20:04:06 -0400 Subject: [PATCH] Reset assign type on duplicate/paste --- src/script/nodes/variables/local_variable.cpp | 11 +++++++++++ src/script/nodes/variables/local_variable.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/script/nodes/variables/local_variable.cpp b/src/script/nodes/variables/local_variable.cpp index e2446315..808f130b 100644 --- a/src/script/nodes/variables/local_variable.cpp +++ b/src/script/nodes/variables/local_variable.cpp @@ -204,6 +204,17 @@ void OScriptNodeAssignLocalVariable::post_initialize() super::post_initialize(); } +void OScriptNodeAssignLocalVariable::post_placed_new_node() +{ + Ref variable = find_pin("variable"); + if (variable.is_valid() && _type != Variant::NIL && !variable->has_any_connections()) + { + _type = Variant::NIL; + reconstruct_node(); + } + super::post_placed_new_node(); +} + void OScriptNodeAssignLocalVariable::allocate_default_pins() { create_pin(PD_Input, PT_Execution, PropertyUtils::make_exec("ExecIn")); diff --git a/src/script/nodes/variables/local_variable.h b/src/script/nodes/variables/local_variable.h index 0bfc9913..5076a102 100644 --- a/src/script/nodes/variables/local_variable.h +++ b/src/script/nodes/variables/local_variable.h @@ -68,6 +68,7 @@ class OScriptNodeAssignLocalVariable : public OScriptNode public: //~ Begin OScriptNode Interface void post_initialize() override; + void post_placed_new_node() override; void allocate_default_pins() override; String get_node_title() const override; String get_node_title_color_name() const override { return "variable"; }