You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.2 KiB

#[derive(Debug, Copy, Clone, PartialEq)]
pub enum ToolType {
Monomate,
Dimate,
Trimate,
Monofluid,
Difluid,
Trifluid,
ScapeDoll,
}
impl ToolType {
pub fn is_stackable(&self) -> bool {
match self {
ToolType::Monomate => true,
ToolType::Dimate => true,
ToolType::Trimate => true,
ToolType::Monofluid => true,
ToolType::Difluid => true,
ToolType::Trifluid => true,
ToolType::ScapeDoll => false,
}
}
pub fn value(&self) -> [u8; 3] {
match self {
ToolType::Monomate => [0x03, 0x00, 0x00],
ToolType::Monofluid => [0x03, 0x01, 0x00],
_ => panic!()
}
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Tool {
pub tool: ToolType,
pub count: usize,
}
impl Tool {
pub fn new(tool: ToolType, count: usize) -> Tool {
Tool {
tool: tool,
count: count,
}
}
pub fn as_bytes(&self) -> [u8; 16] {
let mut result = [0; 16];
result[0..3].copy_from_slice(&self.tool.value());
result[5] = self.count as u8;
result
}
}