refactor: replace HashMap with fixed-size arrays for textures in DirectionalAnimatedTexture

This commit is contained in:
2025-08-11 11:13:46 -05:00
parent 6702b3723a
commit e0f8443e75
4 changed files with 26 additions and 34 deletions

View File

@@ -29,9 +29,9 @@ impl Direction {
self.into()
}
/// Returns the direction as a u8 (0-3). Constant time.
/// Returns the direction as a usize (0-3). Constant time.
/// This is useful for indexing into arrays.
pub const fn as_u8(self) -> u8 {
pub const fn as_usize(self) -> usize {
match self {
Direction::Up => 0,
Direction::Down => 1,
@@ -51,5 +51,3 @@ impl From<Direction> for IVec2 {
}
}
}
pub const DIRECTIONS: [Direction; 4] = [Direction::Up, Direction::Down, Direction::Left, Direction::Right];