int WalkTree(Module module, Dictionary <Module, ModuleData> map, int depth = 0) { int maxChildSources = 0; int childDepth = 0; foreach (var source in module.SourceModules) { int d = WalkTree(source, map, depth + 1); if (d > childDepth) { childDepth = d; } maxChildSources += map[source].MaxSources; } var nc = new NoiseControl() { Module = module, }; map[module] = new ModuleData() { MaxSources = Math.Max(maxChildSources, 1), Depth = depth, Control = nc, }; m_controls.Add(nc); return(childDepth + 1); }
int WalkTree(Module module, Dictionary<Module, ModuleData> map, int depth = 0) { int maxChildSources = 0; int childDepth = 0; foreach (var source in module.SourceModules) { int d = WalkTree(source, map, depth + 1); if (d > childDepth) childDepth = d; maxChildSources += map[source].MaxSources; } var nc = new NoiseControl() { Module = module, }; map[module] = new ModuleData() { MaxSources = Math.Max(maxChildSources, 1), Depth = depth, Control = nc, }; m_controls.Add(nc); return childDepth + 1; }