-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathplayer.rs
More file actions
40 lines (34 loc) · 867 Bytes
/
player.rs
File metadata and controls
40 lines (34 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use anyhow::bail;
use base::EntityKind;
use ecs::{EntityBuilder, SysResult};
use quill_common::{
components::{CreativeFlying, Sneaking, Sprinting},
entities::Player,
};
pub fn build_default(builder: &mut EntityBuilder) {
super::build_default(builder);
builder
.add(Player)
.add(CreativeFlying(false))
.add(Sneaking(false))
.add(Sprinting(false))
.add(EntityKind::Player);
}
/// The hotbar slot a player's cursor is currently on
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct HotbarSlot(usize);
impl HotbarSlot {
pub fn new(id: usize) -> Self {
Self(id)
}
pub fn get(&self) -> usize {
self.0
}
pub fn set(&mut self, id: usize) -> SysResult {
if id > 8 {
bail!("invalid hotbar slot id");
}
self.0 = id;
Ok(())
}
}