Skip to content

Commit

Permalink
Move to block scope
Browse files Browse the repository at this point in the history
  • Loading branch information
m3taphysics committed Nov 1, 2023
1 parent bfbfed5 commit cf7156a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 50 deletions.
5 changes: 3 additions & 2 deletions Arch.SystemGroups/Descriptors/SystemGroupDescriptor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;

namespace Arch.SystemGroups.Descriptors;

namespace Arch.SystemGroups.Descriptors
{
/// <summary>
/// Descriptor for a SystemGroup
/// </summary>
Expand Down Expand Up @@ -35,3 +35,4 @@ public SystemGroupDescriptor(string name, IReadOnlyList<SystemDescriptor> system
/// </summary>
public IReadOnlyList<SystemGroupDescriptor> Groups { get; }
}
}
97 changes: 49 additions & 48 deletions Arch.SystemGroups/Descriptors/SystemGroupWorldExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,64 +1,65 @@
using System.Collections.Generic;
using JetBrains.Annotations;

namespace Arch.SystemGroups.Descriptors;

/// <summary>
/// Extensions for SystemGroupWorld
/// </summary>
public static class SystemGroupWorldExtensions
namespace Arch.SystemGroups.Descriptors
{
/// <summary>
/// Generate the descriptor for the SystemGroupWorld
/// Extensions for SystemGroupWorld
/// </summary>
/// <param name="world"></param>
[UsedImplicitly]
public static IReadOnlyList<SystemGroupDescriptor> GenerateDescriptors(this SystemGroupWorld world)
public static class SystemGroupWorldExtensions
{
var descriptors = new List<SystemGroupDescriptor>();
// Foreach system group such as initialization, simulation, presentation
foreach (var worldSystemGroup in world.SystemGroups)
/// <summary>
/// Generate the descriptor for the SystemGroupWorld
/// </summary>
/// <param name="world"></param>
[UsedImplicitly]
public static IReadOnlyList<SystemGroupDescriptor> GenerateDescriptors(this SystemGroupWorld world)
{
descriptors.Add(GenerateGroupDescriptor(worldSystemGroup.GetType().Name, worldSystemGroup.Nodes));
}
var descriptors = new List<SystemGroupDescriptor>();
// Foreach system group such as initialization, simulation, presentation
foreach (var worldSystemGroup in world.SystemGroups)
{
descriptors.Add(GenerateGroupDescriptor(worldSystemGroup.GetType().Name, worldSystemGroup.Nodes));
}

return descriptors;
}
return descriptors;
}

/// <summary>
/// Generate the descriptor for the SystemGroup
/// </summary>
/// <param name="name">Name of the system group</param>
/// <param name="nodes">List of nodes within the system group</param>
private static SystemGroupDescriptor GenerateGroupDescriptor(string name, IReadOnlyList<ExecutionNode<float>> nodes)
{
var groupSystems = new List<SystemDescriptor>();
var groupNestedGroups = new List<SystemGroupDescriptor>();
GenerateNestedGroupDescriptors(nodes, groupSystems, groupNestedGroups);
return new SystemGroupDescriptor(name, groupSystems, groupNestedGroups
);
}
/// <summary>
/// Generate the descriptor for the SystemGroup
/// </summary>
/// <param name="name">Name of the system group</param>
/// <param name="nodes">List of nodes within the system group</param>
private static SystemGroupDescriptor GenerateGroupDescriptor(string name, IReadOnlyList<ExecutionNode<float>> nodes)
{
var groupSystems = new List<SystemDescriptor>();
var groupNestedGroups = new List<SystemGroupDescriptor>();
GenerateNestedGroupDescriptors(nodes, groupSystems, groupNestedGroups);
return new SystemGroupDescriptor(name, groupSystems, groupNestedGroups
);
}

/// <summary>
/// Generate the descriptor for the SystemGroupWorld
/// </summary>
/// <param name="nodes"></param>
/// <param name="groupSystems"></param>
/// <param name="groupNestedGroups"></param>
/// <returns></returns>
private static void GenerateNestedGroupDescriptors(IReadOnlyList<ExecutionNode<float>> nodes,
List<SystemDescriptor> groupSystems, List<SystemGroupDescriptor> groupNestedGroups)
{
if(nodes is null) return;
foreach (var node in nodes)
/// <summary>
/// Generate the descriptor for the SystemGroupWorld
/// </summary>
/// <param name="nodes"></param>
/// <param name="groupSystems"></param>
/// <param name="groupNestedGroups"></param>
/// <returns></returns>
private static void GenerateNestedGroupDescriptors(IReadOnlyList<ExecutionNode<float>> nodes,
List<SystemDescriptor> groupSystems, List<SystemGroupDescriptor> groupNestedGroups)
{
if (node.IsGroup)
{
groupNestedGroups.Add(GenerateGroupDescriptor(node.CustomGroup.GetType().Name, node.CustomGroup.Nodes));
}
else
if(nodes is null) return;
foreach (var node in nodes)
{
groupSystems.Add(new SystemDescriptor(node.System.GetType().Name, node.ThrottlingEnabled));
if (node.IsGroup)
{
groupNestedGroups.Add(GenerateGroupDescriptor(node.CustomGroup.GetType().Name, node.CustomGroup.Nodes));
}
else
{
groupSystems.Add(new SystemDescriptor(node.System.GetType().Name, node.ThrottlingEnabled));
}
}
}
}
Expand Down

0 comments on commit cf7156a

Please sign in to comment.