MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ProcessGroupCollections

Method ProcessGroupCollections

Source/Engine/Visject/VisjectGraph.cpp:1357–1528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1355}
1356
1357void VisjectExecutor::ProcessGroupCollections(Box* box, Node* node, Value& value)
1358{
1359 if (node->TypeID < 100)
1360 {
1361 // Array
1362 Variant v = tryGetValue(node->GetBox(0), Value::Null);
1363 if (v.Type.Type == VariantType::Null)
1364 v = Variant(Array<Variant>());
1365 ENSURE(v.Type.Type == VariantType::Array, String::Format(TEXT("Input value {0} is not an array."), v));
1366 auto& array = v.AsArray();
1367 Box* b;
1368 switch (node->TypeID)
1369 {
1370 // Count
1371 case 1:
1372 value = array.Count();
1373 break;
1374 // Contains
1375 case 2:
1376 value = array.Contains(tryGetValue(node->GetBox(1), Value::Null));
1377 break;
1378 // Find
1379 case 3:
1380 b = node->GetBox(1);
1381 ENSURE(b->HasConnection(), TEXT("Missing value to find."));
1382 value = array.Find(eatBox(b->GetParent<Node>(), b->FirstConnection()));
1383 break;
1384 // Find Last
1385 case 4:
1386 b = node->GetBox(1);
1387 ENSURE(b->HasConnection(), TEXT("Missing value to find."));
1388 value = array.FindLast(eatBox(b->GetParent<Node>(), b->FirstConnection()));
1389 break;
1390 // Clear
1391 case 5:
1392 array.Clear();
1393 value = MoveTemp(v);
1394 break;
1395 // Remove
1396 case 6:
1397 b = node->GetBox(1);
1398 ENSURE(b->HasConnection(), TEXT("Missing value to remove."));
1399 array.Remove(eatBox(b->GetParent<Node>(), b->FirstConnection()));
1400 value = MoveTemp(v);
1401 break;
1402 // Remove At
1403 case 7:
1404 {
1405 const int32 index = (int32)tryGetValue(node->GetBox(1), 0, Value::Null);
1406 ENSURE(index >= 0 && index < array.Count(), String::Format(TEXT("Array index {0} is out of range [0;{1}]."), index, array.Count() - 1));
1407 array.RemoveAt(index);
1408 value = MoveTemp(v);
1409 break;
1410 }
1411 // Add
1412 case 8:
1413 b = node->GetBox(1);
1414 ENSURE(b->HasConnection(), TEXT("Missing value to add."));

Callers

nothing calls this directly

Calls 15

AddUniqueMethod · 0.80
VariantFunction · 0.50
FormatFunction · 0.50
QuickSortFunction · 0.50
GetBoxMethod · 0.45
CountMethod · 0.45
ContainsMethod · 0.45
HasConnectionMethod · 0.45
FindMethod · 0.45
FirstConnectionMethod · 0.45
FindLastMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected