.net 8 syntax/perf changes

This commit is contained in:
Asriel Camora
2024-03-15 01:28:58 -07:00
parent 836e983eb2
commit 94ea1f84de
20 changed files with 117 additions and 136 deletions
+29 -4
View File
@@ -151,7 +151,7 @@ dotnet_diagnostic.MA0048.severity = silent
dotnet_diagnostic.MA0051.severity = silent
dotnet_diagnostic.MA0006.severity = suggestion
dotnet_diagnostic.MA0016.severity = suggestion
dotnet_diagnostic.MA0008.severity = suggestion
dotnet_diagnostic.MA0008.severity = none
dotnet_diagnostic.CA1805.severity = warning
dotnet_diagnostic.CA1825.severity = warning
dotnet_diagnostic.CA1841.severity = warning
@@ -166,13 +166,34 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_prefer_primary_constructors = true:warning
dotnet_diagnostic.CA1855.severity = warning
dotnet_diagnostic.CA1866.severity = warning
dotnet_diagnostic.CA1865.severity = warning
dotnet_diagnostic.MA0112.severity = none
dotnet_diagnostic.MA0038.severity = none
dotnet_diagnostic.MA0041.severity = none
csharp_style_throw_expression = true:suggestion
csharp_style_prefer_null_check_over_type_check = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
csharp_prefer_static_local_function = true:suggestion
csharp_style_prefer_readonly_struct = true:suggestion
csharp_style_prefer_readonly_struct_member = true:suggestion
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
dotnet_diagnostic.MA0003.severity = none
[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,c,c++,cc,cginc,compute,config,cp,cpp,cs,cshtml,csproj,css,cu,cuh,cxx,dbml,discomap,dtd,h,hh,hlsl,hlsli,hlslinc,hpp,htm,html,hxx,inc,inl,ino,ipp,js,json,jsproj,jsx,lsproj,master,mpp,mq4,mq5,mqh,njsproj,nuspec,paml,proj,props,proto,razor,resjson,resw,resx,skin,StyleCop,targets,tasks,tpp,ts,tsx,usf,ush,vb,vbproj,xaml,xamlx,xml,xoml,xsd}]
indent_style = space
@@ -184,10 +205,10 @@ dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_collection_initializer = true:suggestion
dotnet_style_collection_initializer = true:warning
dotnet_diagnostic.CA1852.severity = warning
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_prefer_collection_expression = true:suggestion
dotnet_style_prefer_collection_expression = true:warning
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
@@ -198,3 +219,7 @@ dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_analyzer_diagnostic.category-performance.severity = warning
dotnet_diagnostic.CA1829.severity = error
dotnet_style_readonly_field = true:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
+3 -2
View File
@@ -20,7 +20,8 @@ public class Bench
$"{HashCode.Combine(Data.ToString()!):X8}";
}
private static SimulationInput[] Inputs { get; } = new SimulationInput[] {
private static SimulationInput[] Inputs { get; } =
[
// https://craftingway.app/rotation/loud-namazu-jVe9Y
// Chondrite Saw
new(new()
@@ -76,7 +77,7 @@ public class Bench
ProgressModifier = 80,
ProgressDivider = 130
})
};
];
public static IEnumerable<HashWrapper<SimulationState>> States => Inputs.Select(i => new HashWrapper<SimulationState>(new(i)));
+2 -2
View File
@@ -15,7 +15,7 @@ public class Macro
public string Name { get; set; } = string.Empty;
[JsonProperty(PropertyName = "Actions")]
private List<ActionType> actions { get; set; } = new();
private List<ActionType> actions { get; set; } = [];
[JsonIgnore]
public IReadOnlyList<ActionType> Actions
{
@@ -80,7 +80,7 @@ public class Configuration : IPluginConfiguration
public static event Action? OnMacroListChanged;
[JsonProperty(PropertyName = "Macros")]
private List<Macro> macros { get; set; } = new();
private List<Macro> macros { get; set; } = [];
[JsonIgnore]
public IReadOnlyList<Macro> Macros => macros;
public int ReliabilitySimulationCount { get; set; } = 500;
+8 -16
View File
@@ -231,20 +231,12 @@ internal static class ImGuiUtils
public sealed class ViolinData
{
[StructLayout(LayoutKind.Sequential)]
public struct Point
public struct Point(float x, float y, float y2)
{
public float X, Y, Y2;
public Point(float x, float y, float y2)
{
X = x;
Y = y;
Y2 = y2;
}
public float X = x, Y = y, Y2 = y2;
}
public ReadOnlySpan<Point> Data => (DataArray ?? Array.Empty<Point>()).AsSpan();
public ReadOnlySpan<Point> Data => (DataArray ?? []).AsSpan();
private Point[]? DataArray { get; set; }
public readonly float Min;
public readonly float Max;
@@ -261,7 +253,7 @@ internal static class ImGuiUtils
.Select(n => Lerp(min, max, n / (float)resolution))
.Select(n => (n, (float)KernelDensity.EstimateGaussian(n, bandwidth, samplesList)))
.Select(n => new Point(n.n, n.Item2, -n.Item2));
DataArray = data.ToArray();
DataArray = [.. data];
s.Stop();
Log.Debug($"Violin plot processing took {s.Elapsed.TotalMilliseconds:0.00}ms");
});
@@ -311,7 +303,7 @@ internal static class ImGuiUtils
public SearchableComboData(IEnumerable<T> items, T selectedItem, Func<T, string> getString)
{
this.items = items.ToImmutableArray();
filteredItems = new() { selectedItem };
filteredItems = [selectedItem];
this.selectedItem = selectedItem;
this.getString = getString;
input = GetString(selectedItem);
@@ -355,7 +347,7 @@ internal static class ImGuiUtils
{
if (string.IsNullOrWhiteSpace(input))
{
filteredItems = items.ToList();
filteredItems = [.. items];
return;
}
var matcher = new FuzzyMatcher(input.ToLowerInvariant(), MatchMode.FuzzyParts);
@@ -364,10 +356,10 @@ internal static class ImGuiUtils
.OrderByDescending(t => t.Score)
.Select(t => t.Item);
token.ThrowIfCancellationRequested();
filteredItems = query.ToList();
filteredItems = [.. query];
}
}
private static readonly Dictionary<uint, object> ComboData = new();
private static readonly Dictionary<uint, object> ComboData = [];
private static SearchableComboData<T> GetComboData<T>(uint comboKey, IEnumerable<T> items, T selectedItem, Func<T, string> getString) where T : class =>
(SearchableComboData<T>)(
+8 -22
View File
@@ -8,20 +8,13 @@ namespace Craftimizer.Plugin;
public static class ImRaii2
{
private struct EndUnconditionally : ImRaii.IEndObject, IDisposable
private struct EndUnconditionally(Action endAction, bool success) : ImRaii.IEndObject, IDisposable
{
private Action EndAction { get; }
private Action EndAction { get; } = endAction;
public bool Success { get; }
public bool Success { get; } = success;
public bool Disposed { get; private set; }
public EndUnconditionally(Action endAction, bool success)
{
EndAction = endAction;
Success = success;
Disposed = false;
}
public bool Disposed { get; private set; } = false;
public void Dispose()
{
@@ -33,20 +26,13 @@ public static class ImRaii2
}
}
private struct EndConditionally : ImRaii.IEndObject, IDisposable
private struct EndConditionally(Action endAction, bool success) : ImRaii.IEndObject, IDisposable
{
public bool Success { get; }
public bool Success { get; } = success;
public bool Disposed { get; private set; }
public bool Disposed { get; private set; } = false;
private Action EndAction { get; }
public EndConditionally(Action endAction, bool success)
{
EndAction = endAction;
Success = success;
Disposed = false;
}
private Action EndAction { get; } = endAction;
public void Dispose()
{
+6 -6
View File
@@ -15,8 +15,8 @@ public static class Colors
private static Vector4 SolverProgressBg => ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.TableBorderLight));
private static Vector4 SolverProgressFgBland => ImGuiColors.DalamudWhite2;
private static readonly Vector4[] SolverProgressFg = new Vector4[]
{
private static readonly Vector4[] SolverProgressFg =
[
new(0.87f, 0.19f, 0.30f, 1f),
new(0.96f, 0.62f, 0.12f, 1f),
new(0.97f, 0.84f, 0.00f, 1f),
@@ -24,14 +24,14 @@ public static class Colors
new(0.21f, 0.30f, 0.98f, 1f),
new(0.26f, 0.62f, 0.94f, 1f),
new(0.70f, 0.49f, 0.88f, 1f),
};
];
public static readonly Vector4[] CollectabilityThreshold = new Vector4[]
{
public static readonly Vector4[] CollectabilityThreshold =
[
new(0.47f, 0.78f, 0.93f, 1f), // Blue
new(0.99f, 0.79f, 0f, 1f), // Yellow
new(0.75f, 1f, 0.75f, 1f), // Green
};
];
public static (Vector4 Background, Vector4 Foreground) GetSolverProgressColors(int? stageValue) =>
stageValue is not { } stage ?
+11 -11
View File
@@ -73,7 +73,7 @@ public sealed class CommunityMacros
[JsonRequired]
public required ValueData Data { get; set; }
public T[] Value => Data.Values ?? Array.Empty<T>();
public T[] Value => Data.Values ?? [];
public static implicit operator T[](ArrayValue<T> v) => v.Value;
}
@@ -373,7 +373,7 @@ public sealed class CommunityMacros
}
}
private Dictionary<int, List<CommunityMacro>> CachedRotations { get; } = new();
private Dictionary<int, List<CommunityMacro>> CachedRotations { get; } = [];
public async Task<IReadOnlyList<CommunityMacro>> RetrieveRotations(int rlvl, CancellationToken token)
{
@@ -403,17 +403,17 @@ public sealed class CommunityMacros
{
StructuredQuery = new StructuredQuery
{
From = new List<CollectionSelector>
{
From =
[
new() { CollectionId = "rotations" }
},
],
Where = new Filter
{
CompositeFilter = new CompositeFilter
{
Op = CompositeOperator.AND,
Filters = new List<Filter>
{
Filters =
[
new()
{
FieldFilter = new FieldFilter
@@ -432,11 +432,11 @@ public sealed class CommunityMacros
Value = new IntegerValue { Value = rlvl }
}
}
}
]
},
},
OrderBy = new List<Order>
{
OrderBy =
[
new()
{
Field = new FieldReference { FieldPath = "xivVersion" },
@@ -447,7 +447,7 @@ public sealed class CommunityMacros
Field = new FieldReference { FieldPath = "__name__" },
Direction = Direction.DESCENDING
}
}
]
},
};
+7 -7
View File
@@ -1,18 +1,18 @@
using Craftimizer.Plugin;
using Craftimizer.Plugin.Utils;
using Lumina.Excel.GeneratedSheets;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
using System.Linq;
namespace Craftimizer.Utils;
public static class FoodStatus
{
private static readonly ReadOnlyDictionary<uint, uint> ItemFoodToItemLUT;
private static readonly ReadOnlyDictionary<uint, Food> FoodItems;
private static readonly ReadOnlyDictionary<uint, Food> MedicineItems;
private static readonly FrozenDictionary<uint, uint> ItemFoodToItemLUT;
private static readonly FrozenDictionary<uint, Food> FoodItems;
private static readonly FrozenDictionary<uint, Food> MedicineItems;
private static readonly ImmutableArray<uint> FoodOrder;
private static readonly ImmutableArray<uint> MedicineOrder;
@@ -41,7 +41,7 @@ public static class FoodStatus
lut.TryAdd(itemFood.RowId, item.RowId);
}
ItemFoodToItemLUT = lut.AsReadOnly();
ItemFoodToItemLUT = lut.ToFrozenDictionary();
var foods = new Dictionary<uint, Food>();
var medicines = new Dictionary<uint, Food>();
@@ -87,8 +87,8 @@ public static class FoodStatus
}
}
FoodItems = foods.AsReadOnly();
MedicineItems = medicines.AsReadOnly();
FoodItems = foods.ToFrozenDictionary();
MedicineItems = medicines.ToFrozenDictionary();
FoodOrder = FoodItems.OrderByDescending(a => a.Value.Item.LevelItem.Row).Select(a => a.Key).ToImmutableArray();
MedicineOrder = MedicineItems.OrderByDescending(a => a.Value.Item.LevelItem.Row).Select(a => a.Key).ToImmutableArray();
+1 -1
View File
@@ -7,7 +7,7 @@ namespace Craftimizer.Utils;
internal readonly struct FuzzyMatcher
{
private const bool IsBorderMatching = true;
private static readonly (int, int)[] EmptySegArray = Array.Empty<(int, int)>();
private static readonly (int, int)[] EmptySegArray = [];
private readonly string needleString = string.Empty;
private readonly int needleFinalPosition = -1;
+4 -4
View File
@@ -10,10 +10,10 @@ namespace Craftimizer.Utils;
public sealed class IconManager : IDisposable
{
private readonly Dictionary<uint, IDalamudTextureWrap> iconCache = new();
private readonly Dictionary<uint, IDalamudTextureWrap> hqIconCache = new();
private readonly Dictionary<string, IDalamudTextureWrap> textureCache = new();
private readonly Dictionary<string, IDalamudTextureWrap> assemblyCache = new();
private readonly Dictionary<uint, IDalamudTextureWrap> iconCache = [];
private readonly Dictionary<uint, IDalamudTextureWrap> hqIconCache = [];
private readonly Dictionary<string, IDalamudTextureWrap> textureCache = [];
private readonly Dictionary<string, IDalamudTextureWrap> assemblyCache = [];
public IDalamudTextureWrap GetIcon(uint id)
{
+3 -3
View File
@@ -25,7 +25,7 @@ internal sealed class SimulatedMacro
public Param()
{
DataList = new();
DataList = [];
}
public void Add(int value)
@@ -124,7 +124,7 @@ internal sealed class SimulatedMacro
new(initialState, actionSet, Service.Configuration.ReliabilitySimulationCount, recipeData);
};
private List<Step> Macro { get; set; } = new();
private List<Step> Macro { get; set; } = [];
private SimulationState initialState;
public SimulationState InitialState
{
@@ -139,7 +139,7 @@ internal sealed class SimulatedMacro
}
}
private object QueueLock { get; } = new();
private List<Step> QueuedSteps { get; set; } = new();
private List<Step> QueuedSteps { get; set; } = [];
public SimulationState State => Macro.Count > 0 ? Macro[^1].State : InitialState;
+3 -3
View File
@@ -1,7 +1,7 @@
using Dalamud.Game.Text;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Numerics;
namespace Craftimizer.Utils;
@@ -10,7 +10,7 @@ public static class SqText
{
public static SeIconChar LevelPrefix => SeIconChar.LevelEn;
public static readonly ReadOnlyDictionary<char, SeIconChar> LevelNumReplacements = new(new Dictionary<char, SeIconChar>
public static readonly FrozenDictionary<char, SeIconChar> LevelNumReplacements = new Dictionary<char, SeIconChar>
{
['0'] = SeIconChar.Number0,
['1'] = SeIconChar.Number1,
@@ -22,7 +22,7 @@ public static class SqText
['7'] = SeIconChar.Number7,
['8'] = SeIconChar.Number8,
['9'] = SeIconChar.Number9,
});
}.ToFrozenDictionary();
public static string ToLevelString<T>(T value) where T : IBinaryInteger<T>
{
+4 -5
View File
@@ -119,8 +119,7 @@ public sealed class MacroEditor : Window, IDisposable
MacroSetter = setter;
DefaultActions = actions.ToArray();
HQIngredientCounts = new();
HQIngredientCounts.AddRange(Enumerable.Repeat(0, RecipeData.Ingredients.Count));
HQIngredientCounts = [.. Enumerable.Repeat(0, RecipeData.Ingredients.Count)];
RecalculateState();
foreach (var action in DefaultActions)
@@ -145,8 +144,8 @@ public sealed class MacroEditor : Window, IDisposable
SizeConstraints = new() { MinimumSize = new(821, 750), MaximumSize = new(float.PositiveInfinity) };
TitleBarButtons = new()
{
TitleBarButtons =
[
new()
{
Icon = FontAwesomeIcon.Cog,
@@ -154,7 +153,7 @@ public sealed class MacroEditor : Window, IDisposable
Click = _ => Service.Plugin.OpenSettingsWindow(),
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
}
};
];
Service.WindowSystem.AddWindow(this);
}
+5 -5
View File
@@ -23,7 +23,7 @@ public sealed class MacroList : Window, IDisposable
public RecipeData? RecipeData { get; private set; }
private IReadOnlyList<Macro> Macros => Service.Configuration.Macros;
private Dictionary<Macro, SimulationState> MacroStateCache { get; } = new();
private Dictionary<Macro, SimulationState> MacroStateCache { get; } = [];
public MacroList() : base("Craftimizer Macro List", WindowFlags, false)
{
@@ -37,8 +37,8 @@ public sealed class MacroList : Window, IDisposable
SizeConstraints = new() { MinimumSize = new(465, 520), MaximumSize = new(float.PositiveInfinity) };
TitleBarButtons = new()
{
TitleBarButtons =
[
new()
{
Icon = FontAwesomeIcon.Cog,
@@ -46,7 +46,7 @@ public sealed class MacroList : Window, IDisposable
Click = _ => Service.Plugin.OpenSettingsWindow(),
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
}
};
];
Service.WindowSystem.AddWindow(this);
}
@@ -345,7 +345,7 @@ public sealed class MacroList : Window, IDisposable
.Where(t => t.Score > 0)
.OrderByDescending(t => t.Score)
.Select(t => t.Item);
sortedMacros = query.ToList();
sortedMacros = [.. query];
}
private void OpenEditor(Macro? macro)
+6 -12
View File
@@ -64,20 +64,14 @@ public sealed unsafe class RecipeNote : Window, IDisposable
public CharacterStats? CharacterStats { get; private set; }
public CraftableStatus CraftStatus { get; private set; }
public sealed class BackgroundTask<T> : IDisposable where T : struct
public sealed class BackgroundTask<T>(Func<CancellationToken, T> func) : IDisposable where T : struct
{
public T? Result { get; private set; }
public Exception? Exception { get; private set; }
public bool Completed { get; private set; }
private CancellationTokenSource TokenSource { get; }
private Func<CancellationToken, T> Func { get; }
public BackgroundTask(Func<CancellationToken, T> func)
{
Func = func;
TokenSource = new();
}
private CancellationTokenSource TokenSource { get; } = new();
private Func<CancellationToken, T> Func { get; } = func;
public void Start()
{
@@ -142,8 +136,8 @@ public sealed unsafe class RecipeNote : Window, IDisposable
MaximumSize = new(10000, 10000)
};
TitleBarButtons = new()
{
TitleBarButtons =
[
new()
{
Icon = FontAwesomeIcon.Cog,
@@ -151,7 +145,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable
Click = _ => Service.Plugin.OpenSettingsWindow(),
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
}
};
];
Service.WindowSystem.AddWindow(this);
}
+1 -1
View File
@@ -805,7 +805,7 @@ public sealed class Settings : Window, IDisposable
pool.Add(combo);
}
}
actionPool = pool.ToArray();
actionPool = [.. pool];
}
}
+3 -3
View File
@@ -92,8 +92,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
MaximumSize = new(494, 10000)
};
TitleBarButtons = new()
{
TitleBarButtons =
[
new()
{
Icon = FontAwesomeIcon.Cog,
@@ -101,7 +101,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
Click = _ => Service.Plugin.OpenSettingsWindow(),
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
}
};
];
Service.WindowSystem.AddWindow(this);
}
+4 -4
View File
@@ -1,5 +1,5 @@
using Craftimizer.Simulator.Actions;
using System.Collections.ObjectModel;
using System.Collections.Frozen;
namespace Craftimizer.Simulator;
@@ -16,14 +16,14 @@ public enum ActionCategory
public static class ActionCategoryUtils
{
private static readonly ReadOnlyDictionary<ActionCategory, ActionType[]> SortedActions;
private static readonly FrozenDictionary<ActionCategory, ActionType[]> SortedActions;
static ActionCategoryUtils()
{
SortedActions = new(
SortedActions =
Enum.GetValues<ActionType>()
.GroupBy(a => a.Category())
.ToDictionary(g => g.Key, g => g.OrderBy(a => a.Level()).ToArray()));
.ToFrozenDictionary(g => g.Key, g => g.OrderBy(a => a.Level()).ToArray());
}
public static IReadOnlyList<ActionType> GetActions(this ActionCategory me)
+3 -11
View File
@@ -2,24 +2,16 @@ using System.Runtime.CompilerServices;
namespace Craftimizer.Solver;
public sealed class ArenaNode<T> where T : struct
public sealed class ArenaNode<T>(in T state, ArenaNode<T>? parent = null) where T : struct
{
public T State;
public T State = state;
public ArenaBuffer<T> Children;
public NodeScoresBuffer ChildScores;
public (int arrayIdx, int subIdx) ChildIdx;
public readonly ArenaNode<T>? Parent;
public readonly ArenaNode<T>? Parent = parent;
public NodeScoresBuffer? ParentScores => Parent?.ChildScores;
public ArenaNode(in T state, ArenaNode<T>? parent = null)
{
State = state;
Children = new();
ChildScores = new();
Parent = parent;
}
public ArenaNode<T>? ChildAt((int arrayIdx, int subIdx) at) =>
Children.Data?[at.arrayIdx]?[at.subIdx];
+5 -13
View File
@@ -7,26 +7,18 @@ using System.Runtime.InteropServices;
namespace Craftimizer.Solver;
[StructLayout(LayoutKind.Auto)]
public struct SimulationNode
public struct SimulationNode(in SimulationState state, ActionType? action, CompletionState completionState, ActionSet actions)
{
public readonly SimulationState State;
public readonly ActionType? Action;
public readonly CompletionState SimulationCompletionState;
public readonly SimulationState State = state;
public readonly ActionType? Action = action;
public readonly CompletionState SimulationCompletionState = completionState;
public ActionSet AvailableActions;
public ActionSet AvailableActions = actions;
public readonly CompletionState CompletionState => GetCompletionState(SimulationCompletionState, AvailableActions);
public readonly bool IsComplete => CompletionState != CompletionState.Incomplete;
public SimulationNode(in SimulationState state, ActionType? action, CompletionState completionState, ActionSet actions)
{
State = state;
Action = action;
SimulationCompletionState = completionState;
AvailableActions = actions;
}
public static CompletionState GetCompletionState(CompletionState simCompletionState, ActionSet actions) =>
actions.IsEmpty && simCompletionState == CompletionState.Incomplete ?
CompletionState.NoMoreActions :