wolfrpg_map_parser/page/
options.rs

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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq)]
pub struct Options {
    idle_animation: bool,
    move_animation: bool,
    fixed_direction: bool,
    slip_through: bool,
    above_hero: bool,
    square_hitbox: bool,
    half_step_up: bool,
}

impl Options {
    pub fn new(options: u8) -> Self {
        Self {
            idle_animation:     options & 0b00000001 != 0,
            move_animation:     options & 0b00000010 != 0,
            fixed_direction:    options & 0b00000100 != 0,
            slip_through:       options & 0b00001000 != 0,
            above_hero:         options & 0b00010000 != 0,
            square_hitbox:      options & 0b00100000 != 0,
            half_step_up:       options & 0b01000000 != 0,
        }
    }

    pub fn idle_animation(&self) -> bool {
        self.idle_animation
    }

    pub fn idle_animation_mut(&mut self) -> &mut bool {
        &mut self.idle_animation
    }

    pub fn move_animation(&self) -> bool {
        self.move_animation
    }

    pub fn move_animation_mut(&mut self) -> &mut bool {
        &mut self.move_animation
    }

    pub fn fixed_direction(&self) -> bool {
        self.fixed_direction
    }

    pub fn fixed_direction_mut(&mut self) -> &mut bool {
        &mut self.fixed_direction
    }

    pub fn slip_through(&self) -> bool {
        self.slip_through
    }

    pub fn slip_through_mut(&mut self) -> &mut bool {
        &mut self.slip_through
    }

    pub fn above_hero(&self) -> bool {
        self.above_hero
    }

    pub fn above_hero_mut(&mut self) -> &mut bool {
        &mut self.above_hero
    }

    pub fn square_hitbox(&self) -> bool {
        self.square_hitbox
    }

    pub fn square_hitbox_mut(&mut self) -> &mut bool {
        &mut self.square_hitbox
    }

    pub fn half_step_up(&self) -> bool {
        self.half_step_up
    }

    pub fn half_step_up_mut(&mut self) -> &mut bool {
        &mut self.half_step_up
    }
}