Minor sim refactors
This commit is contained in:
@@ -22,7 +22,6 @@ public static class ActionCategoryUtils
|
|||||||
{
|
{
|
||||||
SortedActions = new(
|
SortedActions = new(
|
||||||
Enum.GetValues<ActionType>()
|
Enum.GetValues<ActionType>()
|
||||||
.Where(a => a.Category() != ActionCategory.Combo)
|
|
||||||
.GroupBy(a => a.Category())
|
.GroupBy(a => a.Category())
|
||||||
.ToDictionary(g => g.Key, g => g.OrderBy(a => a.Level()).ToArray()));
|
.ToDictionary(g => g.Key, g => g.OrderBy(a => a.Level()).ToArray()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,12 +63,6 @@ public static class ActionUtils
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static BaseAction Base(this ActionType me) => Actions[(int)me];
|
public static BaseAction Base(this ActionType me) => Actions[(int)me];
|
||||||
|
|
||||||
public static IEnumerable<ActionType> AvailableActions(Simulator simulation) =>
|
|
||||||
simulation.IsComplete
|
|
||||||
? Enumerable.Empty<ActionType>()
|
|
||||||
: Enum.GetValues<ActionType>()
|
|
||||||
.Where(a => a.Base().CanUse(simulation));
|
|
||||||
|
|
||||||
public static int Level(this ActionType me) =>
|
public static int Level(this ActionType me) =>
|
||||||
me.Base().Level;
|
me.Base().Level;
|
||||||
|
|
||||||
|
|||||||
+28
-12
@@ -1,22 +1,38 @@
|
|||||||
namespace Craftimizer.Simulator;
|
namespace Craftimizer.Simulator;
|
||||||
|
|
||||||
public enum Condition : ushort
|
public enum Condition : byte
|
||||||
{
|
{
|
||||||
Poor = 0x0008,
|
Normal,
|
||||||
Normal = 0x0001,
|
Good,
|
||||||
Good = 0x0002,
|
Excellent,
|
||||||
Excellent = 0x0004,
|
Poor,
|
||||||
|
|
||||||
Centered = 0x0010,
|
Centered,
|
||||||
Sturdy = 0x0020,
|
Sturdy,
|
||||||
Pliant = 0x0040,
|
Pliant,
|
||||||
Malleable = 0x0080,
|
Malleable,
|
||||||
Primed = 0x0100,
|
Primed,
|
||||||
GoodOmen = 0x0200,
|
GoodOmen,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConditionUtils
|
public static class ConditionUtils
|
||||||
{
|
{
|
||||||
|
[Flags]
|
||||||
|
private enum ConditionMask : ushort
|
||||||
|
{
|
||||||
|
Normal = 1 << 0, // 0x0001
|
||||||
|
Good = 1 << 1, // 0x0002
|
||||||
|
Excellent = 1 << 2, // 0x0004
|
||||||
|
Poor = 1 << 3, // 0x0008
|
||||||
|
|
||||||
|
Centered = 1 << 4, // 0x0010
|
||||||
|
Sturdy = 1 << 5, // 0x0020
|
||||||
|
Pliant = 1 << 6, // 0x0040
|
||||||
|
Malleable = 1 << 7, // 0x0080
|
||||||
|
Primed = 1 << 8, // 0x0100
|
||||||
|
GoodOmen = 1 << 9, // 0x0200
|
||||||
|
}
|
||||||
|
|
||||||
public static Condition[] GetPossibleConditions(ushort conditionsFlag) =>
|
public static Condition[] GetPossibleConditions(ushort conditionsFlag) =>
|
||||||
Enum.GetValues<Condition>().Where(c => ((Condition)conditionsFlag).HasFlag(c)).ToArray();
|
Enum.GetValues<Condition>().Where(c => ((ConditionMask)conditionsFlag).HasFlag((ConditionMask)(1 << (ushort)c))).ToArray();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user