wolfrpg_map_parser/command/set_variable_command/
calculation.rs

1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5#[derive(PartialEq, Clone)]
6pub enum Calculation {
7    Plus        = 0x00,
8    Minus       = 0x01,
9    Times       = 0x02,
10    Divides     = 0x03,
11    Remainder   = 0x04,
12    BitwiseAnd  = 0x05,
13    Random      = 0x06,
14    /// Used only for angle calculations, means the left and right side of the calculation
15    /// should not be used to calculate the complexive right side before assignment
16    Nothing     = 0x0F,
17    Unknown
18}
19
20impl Calculation {
21    pub const fn from_u8(calculation: u8) -> Self {
22        match calculation {
23            0x00 => Calculation::Plus,
24            0x01 => Calculation::Minus,
25            0x02 => Calculation::Times,
26            0x03 => Calculation::Divides,
27            0x04 => Calculation::Remainder,
28            0x05 => Calculation::BitwiseAnd,
29            0x06 => Calculation::Random,
30            0x0F => Calculation::Nothing,
31            _ => Calculation::Unknown
32        }
33    }
34}