Fix ActionSet
This commit is contained in:
@@ -15,7 +15,7 @@ public class ActionSetTests
|
|||||||
foreach (var i in Enum.GetValues<ActionType>())
|
foreach (var i in Enum.GetValues<ActionType>())
|
||||||
{
|
{
|
||||||
var idx = lut[(byte)i];
|
var idx = lut[(byte)i];
|
||||||
if (idx != 0)
|
if (idx != -1)
|
||||||
Assert.AreEqual(i, actions[idx]);
|
Assert.AreEqual(i, actions[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ public struct ActionSet
|
|||||||
private static int FromAction(ActionType action)
|
private static int FromAction(ActionType action)
|
||||||
{
|
{
|
||||||
var ret = Simulator.AcceptedActionsLUT[(byte)action];
|
var ret = Simulator.AcceptedActionsLUT[(byte)action];
|
||||||
if (ret == 0)
|
if (ret == -1)
|
||||||
throw new ArgumentOutOfRangeException(nameof(action), action, $"Action {action} is unsupported in {nameof(ActionSet)}.");
|
throw new ArgumentOutOfRangeException(nameof(action), action, $"Action {action} is unsupported in {nameof(ActionSet)}.");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ public sealed class Simulator : SimulatorNoRandom
|
|||||||
static Simulator()
|
static Simulator()
|
||||||
{
|
{
|
||||||
AcceptedActionsLUT = new int[Enum.GetValues<ActionType>().Length];
|
AcceptedActionsLUT = new int[Enum.GetValues<ActionType>().Length];
|
||||||
|
for (var i = 0; i < AcceptedActionsLUT.Length; i++)
|
||||||
|
AcceptedActionsLUT[i] = -1;
|
||||||
for (var i = 0; i < AcceptedActions.Length; i++)
|
for (var i = 0; i < AcceptedActions.Length; i++)
|
||||||
AcceptedActionsLUT[(byte)AcceptedActions[i]] = i;
|
AcceptedActionsLUT[(byte)AcceptedActions[i]] = i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user