Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change funcs to delegates #90

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading