| 974 | } |
| 975 | |
| 976 | void VisualScriptExecutor::ProcessGroupFlow(Box* boxBase, Node* node, Value& value) |
| 977 | { |
| 978 | switch (node->TypeID) |
| 979 | { |
| 980 | // If |
| 981 | case 1: |
| 982 | { |
| 983 | const bool condition = (bool)tryGetValue(node->GetBox(1), Value::Zero); |
| 984 | boxBase = node->GetBox(condition ? 2 : 3); |
| 985 | if (boxBase->HasConnection()) |
| 986 | eatBox(node, boxBase->FirstConnection()); |
| 987 | break; |
| 988 | } |
| 989 | // For Loop |
| 990 | case 2: |
| 991 | { |
| 992 | const auto scope = ThreadStacks.Get().Stack->Scope; |
| 993 | int32 iteratorIndex = 0; |
| 994 | for (; iteratorIndex < scope->ReturnedValues.Count(); iteratorIndex++) |
| 995 | { |
| 996 | const auto& e = scope->ReturnedValues[iteratorIndex]; |
| 997 | if (e.NodeId == node->ID) |
| 998 | break; |
| 999 | } |
| 1000 | switch (boxBase->ID) |
| 1001 | { |
| 1002 | // Loop |
| 1003 | case 0: |
| 1004 | { |
| 1005 | if (iteratorIndex == scope->ReturnedValues.Count()) |
| 1006 | scope->ReturnedValues.AddOne(); |
| 1007 | auto& iteratorValue = scope->ReturnedValues[iteratorIndex]; |
| 1008 | iteratorValue.NodeId = node->ID; |
| 1009 | iteratorValue.BoxId = 0; |
| 1010 | iteratorValue.Value = (int32)tryGetValue(node->GetBox(1), 0, Value::Zero); |
| 1011 | const int32 count = (int32)tryGetValue(node->GetBox(2), 1, Value::Zero); |
| 1012 | for (; iteratorValue.Value.AsInt < count; iteratorValue.Value.AsInt++) |
| 1013 | { |
| 1014 | boxBase = node->GetBox(4); |
| 1015 | if (boxBase->HasConnection()) |
| 1016 | eatBox(node, boxBase->FirstConnection()); |
| 1017 | } |
| 1018 | boxBase = node->GetBox(6); |
| 1019 | if (boxBase->HasConnection()) |
| 1020 | eatBox(node, boxBase->FirstConnection()); |
| 1021 | break; |
| 1022 | } |
| 1023 | // Break |
| 1024 | case 3: |
| 1025 | // Reset loop iterator |
| 1026 | if (iteratorIndex != scope->ReturnedValues.Count()) |
| 1027 | scope->ReturnedValues[iteratorIndex].Value.AsInt = MAX_int32 - 1; |
| 1028 | break; |
| 1029 | // Index |
| 1030 | case 5: |
| 1031 | if (iteratorIndex != scope->ReturnedValues.Count()) |
| 1032 | value = scope->ReturnedValues[iteratorIndex].Value; |
| 1033 | break; |
nothing calls this directly
no test coverage detected