.net 8 syntax/perf changes
This commit is contained in:
+29
-4
@@ -151,7 +151,7 @@ dotnet_diagnostic.MA0048.severity = silent
|
|||||||
dotnet_diagnostic.MA0051.severity = silent
|
dotnet_diagnostic.MA0051.severity = silent
|
||||||
dotnet_diagnostic.MA0006.severity = suggestion
|
dotnet_diagnostic.MA0006.severity = suggestion
|
||||||
dotnet_diagnostic.MA0016.severity = suggestion
|
dotnet_diagnostic.MA0016.severity = suggestion
|
||||||
dotnet_diagnostic.MA0008.severity = suggestion
|
dotnet_diagnostic.MA0008.severity = none
|
||||||
dotnet_diagnostic.CA1805.severity = warning
|
dotnet_diagnostic.CA1805.severity = warning
|
||||||
dotnet_diagnostic.CA1825.severity = warning
|
dotnet_diagnostic.CA1825.severity = warning
|
||||||
dotnet_diagnostic.CA1841.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_pattern_matching_over_as_with_null_check = true:suggestion
|
||||||
csharp_style_prefer_not_pattern = true:suggestion
|
csharp_style_prefer_not_pattern = true:suggestion
|
||||||
csharp_style_prefer_extended_property_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.CA1855.severity = warning
|
||||||
dotnet_diagnostic.CA1866.severity = warning
|
dotnet_diagnostic.CA1866.severity = warning
|
||||||
dotnet_diagnostic.CA1865.severity = warning
|
dotnet_diagnostic.CA1865.severity = warning
|
||||||
dotnet_diagnostic.MA0112.severity = none
|
dotnet_diagnostic.MA0112.severity = none
|
||||||
dotnet_diagnostic.MA0038.severity = none
|
dotnet_diagnostic.MA0038.severity = none
|
||||||
dotnet_diagnostic.MA0041.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}]
|
[*.{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
|
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_is_null_check_over_reference_equality_method = true:suggestion
|
||||||
dotnet_style_prefer_auto_properties = true:suggestion
|
dotnet_style_prefer_auto_properties = true:suggestion
|
||||||
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
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_diagnostic.CA1852.severity = warning
|
||||||
dotnet_style_namespace_match_folder = true:suggestion
|
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_simplified_boolean_expressions = true:suggestion
|
||||||
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
|
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
|
||||||
dotnet_style_prefer_conditional_expression_over_return = 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_style_prefer_simplified_interpolation = true:suggestion
|
||||||
dotnet_analyzer_diagnostic.category-performance.severity = warning
|
dotnet_analyzer_diagnostic.category-performance.severity = warning
|
||||||
dotnet_diagnostic.CA1829.severity = error
|
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
@@ -20,7 +20,8 @@ public class Bench
|
|||||||
$"{HashCode.Combine(Data.ToString()!):X8}";
|
$"{HashCode.Combine(Data.ToString()!):X8}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SimulationInput[] Inputs { get; } = new SimulationInput[] {
|
private static SimulationInput[] Inputs { get; } =
|
||||||
|
[
|
||||||
// https://craftingway.app/rotation/loud-namazu-jVe9Y
|
// https://craftingway.app/rotation/loud-namazu-jVe9Y
|
||||||
// Chondrite Saw
|
// Chondrite Saw
|
||||||
new(new()
|
new(new()
|
||||||
@@ -76,7 +77,7 @@ public class Bench
|
|||||||
ProgressModifier = 80,
|
ProgressModifier = 80,
|
||||||
ProgressDivider = 130
|
ProgressDivider = 130
|
||||||
})
|
})
|
||||||
};
|
];
|
||||||
|
|
||||||
public static IEnumerable<HashWrapper<SimulationState>> States => Inputs.Select(i => new HashWrapper<SimulationState>(new(i)));
|
public static IEnumerable<HashWrapper<SimulationState>> States => Inputs.Select(i => new HashWrapper<SimulationState>(new(i)));
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class Macro
|
|||||||
|
|
||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
[JsonProperty(PropertyName = "Actions")]
|
[JsonProperty(PropertyName = "Actions")]
|
||||||
private List<ActionType> actions { get; set; } = new();
|
private List<ActionType> actions { get; set; } = [];
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public IReadOnlyList<ActionType> Actions
|
public IReadOnlyList<ActionType> Actions
|
||||||
{
|
{
|
||||||
@@ -80,7 +80,7 @@ public class Configuration : IPluginConfiguration
|
|||||||
public static event Action? OnMacroListChanged;
|
public static event Action? OnMacroListChanged;
|
||||||
|
|
||||||
[JsonProperty(PropertyName = "Macros")]
|
[JsonProperty(PropertyName = "Macros")]
|
||||||
private List<Macro> macros { get; set; } = new();
|
private List<Macro> macros { get; set; } = [];
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public IReadOnlyList<Macro> Macros => macros;
|
public IReadOnlyList<Macro> Macros => macros;
|
||||||
public int ReliabilitySimulationCount { get; set; } = 500;
|
public int ReliabilitySimulationCount { get; set; } = 500;
|
||||||
|
|||||||
@@ -231,20 +231,12 @@ internal static class ImGuiUtils
|
|||||||
|
|
||||||
public sealed class ViolinData
|
public sealed class ViolinData
|
||||||
{
|
{
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
public struct Point(float x, float y, float y2)
|
||||||
public struct Point
|
|
||||||
{
|
{
|
||||||
public float X, Y, Y2;
|
public float X = x, Y = y, Y2 = y2;
|
||||||
|
|
||||||
public Point(float x, float y, float y2)
|
|
||||||
{
|
|
||||||
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; }
|
private Point[]? DataArray { get; set; }
|
||||||
public readonly float Min;
|
public readonly float Min;
|
||||||
public readonly float Max;
|
public readonly float Max;
|
||||||
@@ -261,7 +253,7 @@ internal static class ImGuiUtils
|
|||||||
.Select(n => Lerp(min, max, n / (float)resolution))
|
.Select(n => Lerp(min, max, n / (float)resolution))
|
||||||
.Select(n => (n, (float)KernelDensity.EstimateGaussian(n, bandwidth, samplesList)))
|
.Select(n => (n, (float)KernelDensity.EstimateGaussian(n, bandwidth, samplesList)))
|
||||||
.Select(n => new Point(n.n, n.Item2, -n.Item2));
|
.Select(n => new Point(n.n, n.Item2, -n.Item2));
|
||||||
DataArray = data.ToArray();
|
DataArray = [.. data];
|
||||||
s.Stop();
|
s.Stop();
|
||||||
Log.Debug($"Violin plot processing took {s.Elapsed.TotalMilliseconds:0.00}ms");
|
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)
|
public SearchableComboData(IEnumerable<T> items, T selectedItem, Func<T, string> getString)
|
||||||
{
|
{
|
||||||
this.items = items.ToImmutableArray();
|
this.items = items.ToImmutableArray();
|
||||||
filteredItems = new() { selectedItem };
|
filteredItems = [selectedItem];
|
||||||
this.selectedItem = selectedItem;
|
this.selectedItem = selectedItem;
|
||||||
this.getString = getString;
|
this.getString = getString;
|
||||||
input = GetString(selectedItem);
|
input = GetString(selectedItem);
|
||||||
@@ -355,7 +347,7 @@ internal static class ImGuiUtils
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(input))
|
if (string.IsNullOrWhiteSpace(input))
|
||||||
{
|
{
|
||||||
filteredItems = items.ToList();
|
filteredItems = [.. items];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var matcher = new FuzzyMatcher(input.ToLowerInvariant(), MatchMode.FuzzyParts);
|
var matcher = new FuzzyMatcher(input.ToLowerInvariant(), MatchMode.FuzzyParts);
|
||||||
@@ -364,10 +356,10 @@ internal static class ImGuiUtils
|
|||||||
.OrderByDescending(t => t.Score)
|
.OrderByDescending(t => t.Score)
|
||||||
.Select(t => t.Item);
|
.Select(t => t.Item);
|
||||||
token.ThrowIfCancellationRequested();
|
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 =>
|
private static SearchableComboData<T> GetComboData<T>(uint comboKey, IEnumerable<T> items, T selectedItem, Func<T, string> getString) where T : class =>
|
||||||
(SearchableComboData<T>)(
|
(SearchableComboData<T>)(
|
||||||
|
|||||||
+8
-22
@@ -8,20 +8,13 @@ namespace Craftimizer.Plugin;
|
|||||||
|
|
||||||
public static class ImRaii2
|
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 bool Disposed { get; private set; } = false;
|
||||||
|
|
||||||
public EndUnconditionally(Action endAction, bool success)
|
|
||||||
{
|
|
||||||
EndAction = endAction;
|
|
||||||
Success = success;
|
|
||||||
Disposed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
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; }
|
private Action EndAction { get; } = endAction;
|
||||||
|
|
||||||
public EndConditionally(Action endAction, bool success)
|
|
||||||
{
|
|
||||||
EndAction = endAction;
|
|
||||||
Success = success;
|
|
||||||
Disposed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public static class Colors
|
|||||||
|
|
||||||
private static Vector4 SolverProgressBg => ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.TableBorderLight));
|
private static Vector4 SolverProgressBg => ImGui.ColorConvertU32ToFloat4(ImGui.GetColorU32(ImGuiCol.TableBorderLight));
|
||||||
private static Vector4 SolverProgressFgBland => ImGuiColors.DalamudWhite2;
|
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.87f, 0.19f, 0.30f, 1f),
|
||||||
new(0.96f, 0.62f, 0.12f, 1f),
|
new(0.96f, 0.62f, 0.12f, 1f),
|
||||||
new(0.97f, 0.84f, 0.00f, 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.21f, 0.30f, 0.98f, 1f),
|
||||||
new(0.26f, 0.62f, 0.94f, 1f),
|
new(0.26f, 0.62f, 0.94f, 1f),
|
||||||
new(0.70f, 0.49f, 0.88f, 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.47f, 0.78f, 0.93f, 1f), // Blue
|
||||||
new(0.99f, 0.79f, 0f, 1f), // Yellow
|
new(0.99f, 0.79f, 0f, 1f), // Yellow
|
||||||
new(0.75f, 1f, 0.75f, 1f), // Green
|
new(0.75f, 1f, 0.75f, 1f), // Green
|
||||||
};
|
];
|
||||||
|
|
||||||
public static (Vector4 Background, Vector4 Foreground) GetSolverProgressColors(int? stageValue) =>
|
public static (Vector4 Background, Vector4 Foreground) GetSolverProgressColors(int? stageValue) =>
|
||||||
stageValue is not { } stage ?
|
stageValue is not { } stage ?
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public sealed class CommunityMacros
|
|||||||
[JsonRequired]
|
[JsonRequired]
|
||||||
public required ValueData Data { get; set; }
|
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;
|
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)
|
public async Task<IReadOnlyList<CommunityMacro>> RetrieveRotations(int rlvl, CancellationToken token)
|
||||||
{
|
{
|
||||||
@@ -403,17 +403,17 @@ public sealed class CommunityMacros
|
|||||||
{
|
{
|
||||||
StructuredQuery = new StructuredQuery
|
StructuredQuery = new StructuredQuery
|
||||||
{
|
{
|
||||||
From = new List<CollectionSelector>
|
From =
|
||||||
{
|
[
|
||||||
new() { CollectionId = "rotations" }
|
new() { CollectionId = "rotations" }
|
||||||
},
|
],
|
||||||
Where = new Filter
|
Where = new Filter
|
||||||
{
|
{
|
||||||
CompositeFilter = new CompositeFilter
|
CompositeFilter = new CompositeFilter
|
||||||
{
|
{
|
||||||
Op = CompositeOperator.AND,
|
Op = CompositeOperator.AND,
|
||||||
Filters = new List<Filter>
|
Filters =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
FieldFilter = new FieldFilter
|
FieldFilter = new FieldFilter
|
||||||
@@ -432,11 +432,11 @@ public sealed class CommunityMacros
|
|||||||
Value = new IntegerValue { Value = rlvl }
|
Value = new IntegerValue { Value = rlvl }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
OrderBy = new List<Order>
|
OrderBy =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Field = new FieldReference { FieldPath = "xivVersion" },
|
Field = new FieldReference { FieldPath = "xivVersion" },
|
||||||
@@ -447,7 +447,7 @@ public sealed class CommunityMacros
|
|||||||
Field = new FieldReference { FieldPath = "__name__" },
|
Field = new FieldReference { FieldPath = "__name__" },
|
||||||
Direction = Direction.DESCENDING
|
Direction = Direction.DESCENDING
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
using Craftimizer.Plugin;
|
using Craftimizer.Plugin;
|
||||||
using Craftimizer.Plugin.Utils;
|
using Craftimizer.Plugin.Utils;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using System.Collections.Frozen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Craftimizer.Utils;
|
namespace Craftimizer.Utils;
|
||||||
|
|
||||||
public static class FoodStatus
|
public static class FoodStatus
|
||||||
{
|
{
|
||||||
private static readonly ReadOnlyDictionary<uint, uint> ItemFoodToItemLUT;
|
private static readonly FrozenDictionary<uint, uint> ItemFoodToItemLUT;
|
||||||
private static readonly ReadOnlyDictionary<uint, Food> FoodItems;
|
private static readonly FrozenDictionary<uint, Food> FoodItems;
|
||||||
private static readonly ReadOnlyDictionary<uint, Food> MedicineItems;
|
private static readonly FrozenDictionary<uint, Food> MedicineItems;
|
||||||
private static readonly ImmutableArray<uint> FoodOrder;
|
private static readonly ImmutableArray<uint> FoodOrder;
|
||||||
private static readonly ImmutableArray<uint> MedicineOrder;
|
private static readonly ImmutableArray<uint> MedicineOrder;
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public static class FoodStatus
|
|||||||
|
|
||||||
lut.TryAdd(itemFood.RowId, item.RowId);
|
lut.TryAdd(itemFood.RowId, item.RowId);
|
||||||
}
|
}
|
||||||
ItemFoodToItemLUT = lut.AsReadOnly();
|
ItemFoodToItemLUT = lut.ToFrozenDictionary();
|
||||||
|
|
||||||
var foods = new Dictionary<uint, Food>();
|
var foods = new Dictionary<uint, Food>();
|
||||||
var medicines = new Dictionary<uint, Food>();
|
var medicines = new Dictionary<uint, Food>();
|
||||||
@@ -87,8 +87,8 @@ public static class FoodStatus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FoodItems = foods.AsReadOnly();
|
FoodItems = foods.ToFrozenDictionary();
|
||||||
MedicineItems = medicines.AsReadOnly();
|
MedicineItems = medicines.ToFrozenDictionary();
|
||||||
|
|
||||||
FoodOrder = FoodItems.OrderByDescending(a => a.Value.Item.LevelItem.Row).Select(a => a.Key).ToImmutableArray();
|
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();
|
MedicineOrder = MedicineItems.OrderByDescending(a => a.Value.Item.LevelItem.Row).Select(a => a.Key).ToImmutableArray();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Craftimizer.Utils;
|
|||||||
internal readonly struct FuzzyMatcher
|
internal readonly struct FuzzyMatcher
|
||||||
{
|
{
|
||||||
private const bool IsBorderMatching = true;
|
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 string needleString = string.Empty;
|
||||||
private readonly int needleFinalPosition = -1;
|
private readonly int needleFinalPosition = -1;
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ namespace Craftimizer.Utils;
|
|||||||
|
|
||||||
public sealed class IconManager : IDisposable
|
public sealed class IconManager : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Dictionary<uint, IDalamudTextureWrap> iconCache = new();
|
private readonly Dictionary<uint, IDalamudTextureWrap> iconCache = [];
|
||||||
private readonly Dictionary<uint, IDalamudTextureWrap> hqIconCache = new();
|
private readonly Dictionary<uint, IDalamudTextureWrap> hqIconCache = [];
|
||||||
private readonly Dictionary<string, IDalamudTextureWrap> textureCache = new();
|
private readonly Dictionary<string, IDalamudTextureWrap> textureCache = [];
|
||||||
private readonly Dictionary<string, IDalamudTextureWrap> assemblyCache = new();
|
private readonly Dictionary<string, IDalamudTextureWrap> assemblyCache = [];
|
||||||
|
|
||||||
public IDalamudTextureWrap GetIcon(uint id)
|
public IDalamudTextureWrap GetIcon(uint id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ internal sealed class SimulatedMacro
|
|||||||
|
|
||||||
public Param()
|
public Param()
|
||||||
{
|
{
|
||||||
DataList = new();
|
DataList = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(int value)
|
public void Add(int value)
|
||||||
@@ -124,7 +124,7 @@ internal sealed class SimulatedMacro
|
|||||||
new(initialState, actionSet, Service.Configuration.ReliabilitySimulationCount, recipeData);
|
new(initialState, actionSet, Service.Configuration.ReliabilitySimulationCount, recipeData);
|
||||||
};
|
};
|
||||||
|
|
||||||
private List<Step> Macro { get; set; } = new();
|
private List<Step> Macro { get; set; } = [];
|
||||||
private SimulationState initialState;
|
private SimulationState initialState;
|
||||||
public SimulationState InitialState
|
public SimulationState InitialState
|
||||||
{
|
{
|
||||||
@@ -139,7 +139,7 @@ internal sealed class SimulatedMacro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private object QueueLock { get; } = new();
|
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;
|
public SimulationState State => Macro.Count > 0 ? Macro[^1].State : InitialState;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Dalamud.Game.Text;
|
using Dalamud.Game.Text;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Frozen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Craftimizer.Utils;
|
namespace Craftimizer.Utils;
|
||||||
@@ -10,7 +10,7 @@ public static class SqText
|
|||||||
{
|
{
|
||||||
public static SeIconChar LevelPrefix => SeIconChar.LevelEn;
|
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,
|
['0'] = SeIconChar.Number0,
|
||||||
['1'] = SeIconChar.Number1,
|
['1'] = SeIconChar.Number1,
|
||||||
@@ -22,7 +22,7 @@ public static class SqText
|
|||||||
['7'] = SeIconChar.Number7,
|
['7'] = SeIconChar.Number7,
|
||||||
['8'] = SeIconChar.Number8,
|
['8'] = SeIconChar.Number8,
|
||||||
['9'] = SeIconChar.Number9,
|
['9'] = SeIconChar.Number9,
|
||||||
});
|
}.ToFrozenDictionary();
|
||||||
|
|
||||||
public static string ToLevelString<T>(T value) where T : IBinaryInteger<T>
|
public static string ToLevelString<T>(T value) where T : IBinaryInteger<T>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -119,8 +119,7 @@ public sealed class MacroEditor : Window, IDisposable
|
|||||||
MacroSetter = setter;
|
MacroSetter = setter;
|
||||||
DefaultActions = actions.ToArray();
|
DefaultActions = actions.ToArray();
|
||||||
|
|
||||||
HQIngredientCounts = new();
|
HQIngredientCounts = [.. Enumerable.Repeat(0, RecipeData.Ingredients.Count)];
|
||||||
HQIngredientCounts.AddRange(Enumerable.Repeat(0, RecipeData.Ingredients.Count));
|
|
||||||
|
|
||||||
RecalculateState();
|
RecalculateState();
|
||||||
foreach (var action in DefaultActions)
|
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) };
|
SizeConstraints = new() { MinimumSize = new(821, 750), MaximumSize = new(float.PositiveInfinity) };
|
||||||
|
|
||||||
TitleBarButtons = new()
|
TitleBarButtons =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Icon = FontAwesomeIcon.Cog,
|
Icon = FontAwesomeIcon.Cog,
|
||||||
@@ -154,7 +153,7 @@ public sealed class MacroEditor : Window, IDisposable
|
|||||||
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
||||||
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
|
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public sealed class MacroList : Window, IDisposable
|
|||||||
public RecipeData? RecipeData { get; private set; }
|
public RecipeData? RecipeData { get; private set; }
|
||||||
|
|
||||||
private IReadOnlyList<Macro> Macros => Service.Configuration.Macros;
|
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)
|
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) };
|
SizeConstraints = new() { MinimumSize = new(465, 520), MaximumSize = new(float.PositiveInfinity) };
|
||||||
|
|
||||||
TitleBarButtons = new()
|
TitleBarButtons =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Icon = FontAwesomeIcon.Cog,
|
Icon = FontAwesomeIcon.Cog,
|
||||||
@@ -46,7 +46,7 @@ public sealed class MacroList : Window, IDisposable
|
|||||||
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
||||||
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
|
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ public sealed class MacroList : Window, IDisposable
|
|||||||
.Where(t => t.Score > 0)
|
.Where(t => t.Score > 0)
|
||||||
.OrderByDescending(t => t.Score)
|
.OrderByDescending(t => t.Score)
|
||||||
.Select(t => t.Item);
|
.Select(t => t.Item);
|
||||||
sortedMacros = query.ToList();
|
sortedMacros = [.. query];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenEditor(Macro? macro)
|
private void OpenEditor(Macro? macro)
|
||||||
|
|||||||
@@ -64,20 +64,14 @@ public sealed unsafe class RecipeNote : Window, IDisposable
|
|||||||
public CharacterStats? CharacterStats { get; private set; }
|
public CharacterStats? CharacterStats { get; private set; }
|
||||||
public CraftableStatus CraftStatus { 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 T? Result { get; private set; }
|
||||||
public Exception? Exception { get; private set; }
|
public Exception? Exception { get; private set; }
|
||||||
public bool Completed { get; private set; }
|
public bool Completed { get; private set; }
|
||||||
|
|
||||||
private CancellationTokenSource TokenSource { get; }
|
private CancellationTokenSource TokenSource { get; } = new();
|
||||||
private Func<CancellationToken, T> Func { get; }
|
private Func<CancellationToken, T> Func { get; } = func;
|
||||||
|
|
||||||
public BackgroundTask(Func<CancellationToken, T> func)
|
|
||||||
{
|
|
||||||
Func = func;
|
|
||||||
TokenSource = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
@@ -142,8 +136,8 @@ public sealed unsafe class RecipeNote : Window, IDisposable
|
|||||||
MaximumSize = new(10000, 10000)
|
MaximumSize = new(10000, 10000)
|
||||||
};
|
};
|
||||||
|
|
||||||
TitleBarButtons = new()
|
TitleBarButtons =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Icon = FontAwesomeIcon.Cog,
|
Icon = FontAwesomeIcon.Cog,
|
||||||
@@ -151,7 +145,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable
|
|||||||
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
||||||
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
|
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -805,7 +805,7 @@ public sealed class Settings : Window, IDisposable
|
|||||||
pool.Add(combo);
|
pool.Add(combo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actionPool = pool.ToArray();
|
actionPool = [.. pool];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
|||||||
MaximumSize = new(494, 10000)
|
MaximumSize = new(494, 10000)
|
||||||
};
|
};
|
||||||
|
|
||||||
TitleBarButtons = new()
|
TitleBarButtons =
|
||||||
{
|
[
|
||||||
new()
|
new()
|
||||||
{
|
{
|
||||||
Icon = FontAwesomeIcon.Cog,
|
Icon = FontAwesomeIcon.Cog,
|
||||||
@@ -101,7 +101,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
|||||||
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
Click = _ => Service.Plugin.OpenSettingsWindow(),
|
||||||
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
ShowTooltip = () => ImGuiUtils.Tooltip("Open Craftimizer Settings")
|
||||||
}
|
}
|
||||||
};
|
];
|
||||||
|
|
||||||
Service.WindowSystem.AddWindow(this);
|
Service.WindowSystem.AddWindow(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using Craftimizer.Simulator.Actions;
|
using Craftimizer.Simulator.Actions;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.Frozen;
|
||||||
|
|
||||||
namespace Craftimizer.Simulator;
|
namespace Craftimizer.Simulator;
|
||||||
|
|
||||||
@@ -16,14 +16,14 @@ public enum ActionCategory
|
|||||||
|
|
||||||
public static class ActionCategoryUtils
|
public static class ActionCategoryUtils
|
||||||
{
|
{
|
||||||
private static readonly ReadOnlyDictionary<ActionCategory, ActionType[]> SortedActions;
|
private static readonly FrozenDictionary<ActionCategory, ActionType[]> SortedActions;
|
||||||
|
|
||||||
static ActionCategoryUtils()
|
static ActionCategoryUtils()
|
||||||
{
|
{
|
||||||
SortedActions = new(
|
SortedActions =
|
||||||
Enum.GetValues<ActionType>()
|
Enum.GetValues<ActionType>()
|
||||||
.GroupBy(a => a.Category())
|
.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)
|
public static IReadOnlyList<ActionType> GetActions(this ActionCategory me)
|
||||||
|
|||||||
+3
-11
@@ -2,24 +2,16 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace Craftimizer.Solver;
|
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 ArenaBuffer<T> Children;
|
||||||
public NodeScoresBuffer ChildScores;
|
public NodeScoresBuffer ChildScores;
|
||||||
public (int arrayIdx, int subIdx) ChildIdx;
|
public (int arrayIdx, int subIdx) ChildIdx;
|
||||||
public readonly ArenaNode<T>? Parent;
|
public readonly ArenaNode<T>? Parent = parent;
|
||||||
|
|
||||||
public NodeScoresBuffer? ParentScores => Parent?.ChildScores;
|
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) =>
|
public ArenaNode<T>? ChildAt((int arrayIdx, int subIdx) at) =>
|
||||||
Children.Data?[at.arrayIdx]?[at.subIdx];
|
Children.Data?[at.arrayIdx]?[at.subIdx];
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,18 @@ using System.Runtime.InteropServices;
|
|||||||
namespace Craftimizer.Solver;
|
namespace Craftimizer.Solver;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Auto)]
|
[StructLayout(LayoutKind.Auto)]
|
||||||
public struct SimulationNode
|
public struct SimulationNode(in SimulationState state, ActionType? action, CompletionState completionState, ActionSet actions)
|
||||||
{
|
{
|
||||||
public readonly SimulationState State;
|
public readonly SimulationState State = state;
|
||||||
public readonly ActionType? Action;
|
public readonly ActionType? Action = action;
|
||||||
public readonly CompletionState SimulationCompletionState;
|
public readonly CompletionState SimulationCompletionState = completionState;
|
||||||
|
|
||||||
public ActionSet AvailableActions;
|
public ActionSet AvailableActions = actions;
|
||||||
|
|
||||||
public readonly CompletionState CompletionState => GetCompletionState(SimulationCompletionState, AvailableActions);
|
public readonly CompletionState CompletionState => GetCompletionState(SimulationCompletionState, AvailableActions);
|
||||||
|
|
||||||
public readonly bool IsComplete => CompletionState != CompletionState.Incomplete;
|
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) =>
|
public static CompletionState GetCompletionState(CompletionState simCompletionState, ActionSet actions) =>
|
||||||
actions.IsEmpty && simCompletionState == CompletionState.Incomplete ?
|
actions.IsEmpty && simCompletionState == CompletionState.Incomplete ?
|
||||||
CompletionState.NoMoreActions :
|
CompletionState.NoMoreActions :
|
||||||
|
|||||||
Reference in New Issue
Block a user