wolfrpg_map_parser/db_parser/models/common_event/
run_condition.rs1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3use crate::common::compare_operator::CompareOperator;
4use crate::db_parser::common_event::condition_type::ConditionType;
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8#[derive(PartialEq, Clone)]
9pub struct RunCondition {
10 operator: CompareOperator,
11 condition_type: ConditionType,
12 variable: u32,
13 value: u32,
14}
15
16impl RunCondition {
17 pub const fn new(
18 settings: u8,
19 variable: u32,
20 value: u32
21 ) -> Self {
22 Self {
23 operator: CompareOperator::new((settings >> 4) & 0x0f),
24 condition_type: ConditionType::new(settings & 0x0f),
25 variable,
26 value
27 }
28 }
29
30 pub fn operator(&self) -> &CompareOperator {
32 &self.operator
33 }
34
35 pub fn condition_type(&self) -> &ConditionType {
37 &self.condition_type
38 }
39
40 pub fn variable(&self) -> u32 {
42 self.variable
43 }
44
45 pub fn value(&self) -> u32 {
47 self.value
48 }
49}