public static RSIDirection ToRsiDirection(this Angle angle, RSI.State.DirectionType type) { return(type switch { RSI.State.DirectionType.Dir1 => RSIDirection.South, RSI.State.DirectionType.Dir4 => angle.GetCardinalDir().Convert(type), RSI.State.DirectionType.Dir8 => angle.GetDir().Convert(type), _ => throw new ArgumentOutOfRangeException($"Unknown rsi direction type: {type}.", nameof(type)) });
public StateMetadata(RSI.StateId stateId, RSI.State.DirectionType dirType, float[][] delays) { StateId = stateId; DirType = dirType; Delays = delays; DebugTools.Assert(delays.Length == DirCount); DebugTools.Assert(StateId.IsValid); }
public static RSIDirection Convert(this Direction dir, RSI.State.DirectionType type) { if (type == RSI.State.DirectionType.Dir1) { return(RSIDirection.South); } switch (dir) { case Direction.North: return(RSIDirection.North); case Direction.South: return(RSIDirection.South); case Direction.East: return(RSIDirection.East); case Direction.West: return(RSIDirection.West); } var rsiDir = dir switch { Direction.SouthEast => RSIDirection.SouthEast, Direction.SouthWest => RSIDirection.SouthWest, Direction.NorthEast => RSIDirection.NorthEast, Direction.NorthWest => RSIDirection.NorthWest, _ => throw new ArgumentException($"Unknown dir: {dir}.", nameof(dir)) }; // Round down to a four-way direction if appropriate. if (type == RSI.State.DirectionType.Dir4) { return(RoundToCardinal(rsiDir)); } return(rsiDir); }
public static RSIDirection Convert(this Direction dir, RSI.State.DirectionType type) { // Round down to a four-way direction if appropriate if (type != RSI.State.DirectionType.Dir8) { return(dir.Convert(RSI.State.DirectionType.Dir8).RoundToCardinal()); } switch (dir) { case Direction.North: return(RSIDirection.North); case Direction.South: return(RSIDirection.South); case Direction.East: return(RSIDirection.East); case Direction.West: return(RSIDirection.West); case Direction.SouthEast: return(RSIDirection.SouthEast); case Direction.SouthWest: return(RSIDirection.SouthWest); case Direction.NorthEast: return(RSIDirection.NorthEast); case Direction.NorthWest: return(RSIDirection.NorthWest); } throw new ArgumentException($"Unknown dir: {dir}.", nameof(dir)); }