summaryrefslogtreecommitdiff
path: root/dungeon/src/entity.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dungeon/src/entity.rs')
-rw-r--r--dungeon/src/entity.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/dungeon/src/entity.rs b/dungeon/src/entity.rs
index e3b8fbd..818328c 100644
--- a/dungeon/src/entity.rs
+++ b/dungeon/src/entity.rs
@@ -46,7 +46,7 @@ pub enum EntityKind {
impl EntityKind {
/// Returns the move speed value for this type of entity in tiles/s
- pub fn move_speed(&self) -> f32 {
+ pub const fn move_speed(&self) -> f32 {
match &self {
Self::Player => 5.,
Self::Zombie(_) => 4.,
@@ -190,6 +190,7 @@ impl Entity {
/// let pos = Pos::new(0, 0).unwrap();
/// let player = Entity::zombie(pos);
/// ```
+ #[must_use]
pub const fn zombie(pos: Pos) -> Self {
let dir = Direction::East;
let kind = EntityKind::Zombie(EnemyMoveState::new_idle());
@@ -252,9 +253,7 @@ impl Entity {
EntityKind::Zombie(EnemyMoveState::new_roam(self.pos, floor, rng));
}
EnemyMoveState::Roam(mut moves) => {
- let p = if let Some(p) = moves.last() {
- p
- } else {
+ let Some(p) = moves.last() else {
self.kind = EntityKind::Zombie(EnemyMoveState::new_idle());
return;
};
@@ -340,7 +339,7 @@ impl Player {
/// let pos = Pos::new(1, 2).unwrap();
/// let player = Player::new(pos);
/// ```
- pub fn new(pos: Pos) -> Self {
+ pub const fn new(pos: Pos) -> Self {
let entity = Entity::player(pos);
let inventory = vec![];
Self {