Merge remote-tracking branch 'origin/master' into gi

# Conflicts:
#	Source/Editor/Windows/Assets/VisualScriptWindow.cs
This commit is contained in:
Wojciech Figat
2022-05-02 10:38:14 +02:00
42 changed files with 1467 additions and 518 deletions

View File

@@ -222,7 +222,7 @@ void VisualScriptExecutor::ProcessGroupParameters(Box* box, Node* node, Value& v
LOG(Error, "Failed to access Visual Script parameter for {0}.", stack.Stack->Instance->ToString());
PrintStack(LogType::Error);
}
if (node->Boxes[2].HasConnection())
if (box->ID == 0 && node->Boxes[2].HasConnection())
eatBox(node, node->Boxes[2].FirstConnection());
break;
}
@@ -1154,17 +1154,19 @@ void VisualScriptExecutor::ProcessGroupFlow(Box* boxBase, Node* node, Value& val
arrayValue.NodeId = node->ID;
arrayValue.BoxId = 1;
arrayValue.Value = tryGetValue(node->GetBox(1), Value::Null);
if (arrayValue.Value.Type.Type != VariantType::Array)
if (arrayValue.Value.Type.Type == VariantType::Array)
{
const int32 count = arrayValue.Value.AsArray().Count();
for (; iteratorValue.Value.AsInt < count; iteratorValue.Value.AsInt++)
{
boxBase = node->GetBox(3);
if (boxBase->HasConnection())
eatBox(node, boxBase->FirstConnection());
}
}
else if (arrayValue.Value.Type.Type != VariantType::Null)
{
OnError(node, boxBase, String::Format(TEXT("Input value {0} is not an array."), arrayValue.Value));
return;
}
const int32 count = arrayValue.Value.AsArray().Count();
for (; iteratorValue.Value.AsInt < count; iteratorValue.Value.AsInt++)
{
boxBase = node->GetBox(3);
if (boxBase->HasConnection())
eatBox(node, boxBase->FirstConnection());
}
boxBase = node->GetBox(6);
if (boxBase->HasConnection())
@@ -1190,6 +1192,88 @@ void VisualScriptExecutor::ProcessGroupFlow(Box* boxBase, Node* node, Value& val
}
break;
}
// Dictionary For Each
case 8:
{
const auto scope = ThreadStacks.Get().Stack->Scope;
int32 iteratorIndex = 0;
for (; iteratorIndex < scope->ReturnedValues.Count(); iteratorIndex++)
{
const auto& e = scope->ReturnedValues[iteratorIndex];
if (e.NodeId == node->ID && e.BoxId == 0)
break;
}
int32 dictionaryIndex = 0;
for (; iteratorIndex < scope->ReturnedValues.Count(); dictionaryIndex++)
{
const auto& e = scope->ReturnedValues[dictionaryIndex];
if (e.NodeId == node->ID && e.BoxId == 1)
break;
}
switch (boxBase->ID)
{
// Loop
case 0:
{
if (iteratorIndex == scope->ReturnedValues.Count())
{
if (dictionaryIndex == scope->ReturnedValues.Count())
dictionaryIndex++;
scope->ReturnedValues.AddOne();
}
if (dictionaryIndex == scope->ReturnedValues.Count())
scope->ReturnedValues.AddOne();
auto& iteratorValue = scope->ReturnedValues[iteratorIndex];
iteratorValue.NodeId = node->ID;
iteratorValue.BoxId = 0;
auto& dictionaryValue = scope->ReturnedValues[dictionaryIndex];
dictionaryValue.NodeId = node->ID;
dictionaryValue.BoxId = 1;
dictionaryValue.Value = tryGetValue(node->GetBox(4), Value::Null);
if (dictionaryValue.Value.Type.Type == VariantType::Dictionary)
{
auto& dictionary = *dictionaryValue.Value.AsDictionary;
iteratorValue.Value = dictionary.Begin().Index();
int32 end = dictionary.End().Index();
while (iteratorValue.Value.AsInt < end)
{
boxBase = node->GetBox(3);
if (boxBase->HasConnection())
eatBox(node, boxBase->FirstConnection());
Dictionary<Variant, Variant>::Iterator it(dictionary, iteratorValue.Value.AsInt);
++it;
iteratorValue.Value.AsInt = it.Index();
}
}
else if (dictionaryValue.Value.Type.Type != VariantType::Null)
{
OnError(node, boxBase, String::Format(TEXT("Input value {0} is not a dictionary."), dictionaryValue.Value));
return;
}
boxBase = node->GetBox(6);
if (boxBase->HasConnection())
eatBox(node, boxBase->FirstConnection());
break;
}
// Key
case 1:
if (iteratorIndex != scope->ReturnedValues.Count() && dictionaryIndex != scope->ReturnedValues.Count())
value = Dictionary<Variant, Variant>::Iterator(*scope->ReturnedValues[dictionaryIndex].Value.AsDictionary, scope->ReturnedValues[iteratorIndex].Value.AsInt)->Key;
break;
// Value
case 2:
if (iteratorIndex != scope->ReturnedValues.Count() && dictionaryIndex != scope->ReturnedValues.Count())
value = Dictionary<Variant, Variant>::Iterator(*scope->ReturnedValues[dictionaryIndex].Value.AsDictionary, scope->ReturnedValues[iteratorIndex].Value.AsInt)->Value;
break;
// Break
case 5:
// Reset loop iterator
if (iteratorIndex != scope->ReturnedValues.Count())
scope->ReturnedValues[iteratorIndex].Value.AsInt = MAX_int32 - 1;
break;
}
break;
}
}
}