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

Method ProcessGroupTools

Source/Engine/Content/Assets/VisualScript.cpp:256–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256void VisualScriptExecutor::ProcessGroupTools(Box* box, Node* node, Value& value)
257{
258 switch (node->TypeID)
259 {
260 // This Instance
261 case 19:
262 value = ThreadStacks.Get().Stack->Instance;
263 break;
264 // Cast
265 case 25:
266 {
267 if (box->ID == 0)
268 {
269 // Get object and try to cast it
270 auto obj = (ScriptingObject*)tryGetValue(node->GetBox(1), Value::Null);
271 if (obj)
272 {
273 const StringView typeName(node->Values[0]);
274 const StringAsANSI<100> typeNameAnsi(typeName.Get(), typeName.Length());
275 const ScriptingTypeHandle typeHandle = Scripting::FindScriptingType(StringAnsiView(typeNameAnsi.Get(), typeName.Length()));
276 const auto objClass = obj->GetClass();
277 if (!typeHandle || !objClass || !objClass->IsSubClassOf(typeHandle.GetType().ManagedClass))
278 obj = nullptr;
279 }
280
281 // Cache cast object value (only if it's valid)
282 const bool isValid = obj != nullptr;
283 if (isValid)
284 {
285 const auto scope = ThreadStacks.Get().Stack->Scope;
286 int32 returnedIndex = 0;
287 for (; returnedIndex < scope->ReturnedValues.Count(); returnedIndex++)
288 {
289 const auto& e = scope->ReturnedValues[returnedIndex];
290 if (e.NodeId == node->ID && e.BoxId == 4)
291 break;
292 }
293 if (returnedIndex == scope->ReturnedValues.Count())
294 scope->ReturnedValues.AddOne();
295 auto& returnedValue = scope->ReturnedValues[returnedIndex];
296 returnedValue.NodeId = node->ID;
297 returnedValue.BoxId = 4;
298 returnedValue.Value = obj;
299 }
300
301 // Call graph further
302 const auto impulseBox = &node->Boxes[isValid ? 2 : 3];
303 if (impulseBox && impulseBox->HasConnection())
304 eatBox(node, impulseBox->FirstConnection());
305 }
306 else if (box->ID == 4)
307 {
308 // Find returned value inside the current scope
309 const auto scope = ThreadStacks.Get().Stack->Scope;
310 int32 returnedIndex = 0;
311 for (; returnedIndex < scope->ReturnedValues.Count(); returnedIndex++)
312 {
313 const auto& e = scope->ReturnedValues[returnedIndex];

Callers

nothing calls this directly

Calls 15

FindScriptingTypeFunction · 0.85
FindClassFunction · 0.85
AddOneMethod · 0.80
StringAnsiViewClass · 0.50
GetClassFunction · 0.50
GetMethod · 0.45
GetBoxMethod · 0.45
LengthMethod · 0.45
GetClassMethod · 0.45
IsSubClassOfMethod · 0.45
GetTypeMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected