29 lines
617 B
Dart
29 lines
617 B
Dart
import 'dart:math' as math;
|
|
|
|
enum CardinalDirection {
|
|
east(0.0),
|
|
south(math.pi / 2),
|
|
west(math.pi),
|
|
north(3 * math.pi / 2)
|
|
;
|
|
|
|
final double radians;
|
|
const CardinalDirection(this.radians);
|
|
|
|
/// Helper to decode Wolf3D enemy directional blocks
|
|
static CardinalDirection fromEnemyIndex(int index) {
|
|
switch (index % 4) {
|
|
case 0:
|
|
return CardinalDirection.east;
|
|
case 1:
|
|
return CardinalDirection.north;
|
|
case 2:
|
|
return CardinalDirection.west;
|
|
case 3:
|
|
return CardinalDirection.south;
|
|
default:
|
|
return CardinalDirection.east;
|
|
}
|
|
}
|
|
}
|