Skip to main content

nurtex_protocol/types/
particle_status.rs

1use nurtex_codec::Buffer;
2use nurtex_codec::types::variable::VarI32;
3
4/// Статус видимости партиклов
5#[derive(Debug, Clone, PartialEq, PartialOrd)]
6pub enum ParticleStatus {
7  All,
8  Decreased,
9  Minimal,
10}
11
12impl Buffer for ParticleStatus {
13  fn read_buf(buffer: &mut std::io::Cursor<&[u8]>) -> Option<Self> {
14    let id = i32::read_var(buffer)?;
15
16    Some(match id {
17      0 => Self::All,
18      1 => Self::Decreased,
19      2 => Self::Minimal,
20      _ => return None,
21    })
22  }
23
24  fn write_buf(&self, buffer: &mut impl std::io::Write) -> std::io::Result<()> {
25    let id = match self {
26      Self::All => 0,
27      Self::Decreased => 1,
28      Self::Minimal => 2,
29    };
30
31    id.write_var(buffer)
32  }
33}