Skip to content

Commit

Permalink
Change funcs to delegates
Browse files Browse the repository at this point in the history
Change funcs to delegates
  • Loading branch information
mpewsey authored Mar 25, 2024
2 parents b5c7756 + cee4c76 commit 90813eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ManiaMap.Tests/Generators/TestLayoutGraphSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void TestFunctionSelector()
{
var seed = new RandomSeed(12345);

var graphs = new List<Func<LayoutGraph>>()
var graphs = new List<LayoutGraphSelector.LayoutGraphDelegate>()
{
() => new LayoutGraph(1, "Graph1"),
() => new LayoutGraph(2, "Graph2"),
Expand Down
9 changes: 7 additions & 2 deletions src/ManiaMap/Generators/LayoutGraphSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace MPewsey.ManiaMap.Generators
/// </summary>
public class LayoutGraphSelector : IPipelineStep
{
/// <summary>
/// A delegate returning a LayoutGraph.
/// </summary>
public delegate LayoutGraph LayoutGraphDelegate();

/// <summary>
/// Draws a random layout graph and adds a copy to the results output dictionary.
///
Expand Down Expand Up @@ -54,7 +59,7 @@ public LayoutGraph DrawSelection(IList<LayoutGraph> graphs, RandomSeed randomSee
/// <param name="functions">A list of functions returning a layout graph.</param>
/// <param name="randomSeed">The random seed.</param>
/// <param name="logger">The logging action. Ignored if null.</param>
public LayoutGraph DrawSelection(IList<Func<LayoutGraph>> functions, RandomSeed randomSeed, Action<string> logger = null)
public LayoutGraph DrawSelection(IList<LayoutGraphDelegate> functions, RandomSeed randomSeed, Action<string> logger = null)
{
logger?.Invoke("[Layout Graph Selector] Applying layout graph delegate list selector...");
var index = randomSeed.Next(0, functions.Count);
Expand All @@ -78,7 +83,7 @@ public LayoutGraph DrawSelection(object graphs, RandomSeed randomSeed, Action<st
{
case IList<LayoutGraph> list:
return DrawSelection(list, randomSeed, logger);
case IList<Func<LayoutGraph>> functions:
case IList<LayoutGraphDelegate> functions:
return DrawSelection(functions, randomSeed, logger);
default:
throw new ArgumentException($"Unhandled type for `graphs`: {graphs.GetType()}.");
Expand Down

0 comments on commit 90813eb

Please sign in to comment.