A game about forced loneliness, made by TACStudios
1using System.Collections.Generic; 2 3namespace Unity.VisualScripting 4{ 5 public static class XFlowGraph 6 { 7 public static IEnumerable<IUnit> GetUnitsRecursive(this FlowGraph flowGraph, Recursion recursion) 8 { 9 Ensure.That(nameof(flowGraph)).IsNotNull(flowGraph); 10 11 if (!recursion?.TryEnter(flowGraph) ?? false) 12 { 13 yield break; 14 } 15 16 foreach (var unit in flowGraph.units) 17 { 18 yield return unit; 19 20 var nestedGraph = (unit as SubgraphUnit)?.nest.graph; 21 22 if (nestedGraph != null) 23 { 24 foreach (var nestedUnit in GetUnitsRecursive(nestedGraph, recursion)) 25 { 26 yield return nestedUnit; 27 } 28 } 29 } 30 31 recursion?.Exit(flowGraph); 32 } 33 } 34}