| 103 | } |
| 104 | |
| 105 | void VisualScriptExecutor::Invoke(const Guid& scriptId, int32 nodeId, int32 boxId, const Guid& instanceId, Variant& result) const |
| 106 | { |
| 107 | auto script = Content::Load<VisualScript>(scriptId); |
| 108 | if (!script) |
| 109 | return; |
| 110 | const auto node = script->Graph.GetNode(nodeId); |
| 111 | if (!node) |
| 112 | return; |
| 113 | const auto box = node->GetBox(boxId); |
| 114 | if (!box) |
| 115 | return; |
| 116 | auto instance = Scripting::FindObject<ScriptingObject>(instanceId); |
| 117 | |
| 118 | // Add to the calling stack |
| 119 | VisualScripting::ScopeContext scope; |
| 120 | auto& stack = ThreadStacks.Get(); |
| 121 | VisualScripting::StackFrame frame; |
| 122 | frame.Script = script; |
| 123 | frame.Node = node; |
| 124 | frame.Box = box; |
| 125 | frame.Instance = instance; |
| 126 | frame.PreviousFrame = stack.Stack; |
| 127 | frame.Scope = &scope; |
| 128 | stack.Stack = &frame; |
| 129 | stack.StackFramesCount++; |
| 130 | |
| 131 | // Call per group custom processing event |
| 132 | const auto func = VisualScriptingExecutor._perGroupProcessCall[node->GroupID]; |
| 133 | (VisualScriptingExecutor.*func)(box, node, result); |
| 134 | |
| 135 | // Remove from the calling stack |
| 136 | stack.StackFramesCount--; |
| 137 | stack.Stack = frame.PreviousFrame; |
| 138 | } |
| 139 | |
| 140 | void VisualScriptExecutor::OnError(Node* node, Box* box, const StringView& message) |
| 141 | { |