wolfrpg_map_parser/command/
effect_command.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::command::effect_command::base::Base;
4use crate::command::effect_command::change_color::ChangeColor;
5use crate::command::effect_command::map_shake::MapShake;
6use crate::command::effect_command::scroll_screen::ScrollScreen;
7
8pub mod base;
9pub mod map_shake;
10pub mod scroll_screen;
11pub mod change_color;
12
13#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
14#[derive(PartialEq, Clone)]
15pub enum EffectCommand {
16 Base(Base),
17 MapShake(MapShake),
18 ScrollScreen(ScrollScreen),
19 ChangeColor(ChangeColor)
20}
21
22impl EffectCommand {
23 pub(crate) fn parse_base(bytes: &[u8]) -> (usize, Self) {
24 let (bytes_read, command): (usize, Base) = Base::parse(bytes);
25
26 (bytes_read, Self::Base(command))
27 }
28
29 pub(crate) fn parse_map_shake(bytes: &[u8]) -> (usize, Self) {
30 let (bytes_read, command): (usize, MapShake) = MapShake::parse(bytes);
31
32 (bytes_read, Self::MapShake(command))
33 }
34
35 pub(crate) fn parse_scroll_screen(bytes: &[u8]) -> (usize, Self) {
36 let (bytes_read, command): (usize, ScrollScreen) = ScrollScreen::parse(bytes);
37
38 (bytes_read, Self::ScrollScreen(command))
39 }
40
41 pub(crate) fn parse_change_color(bytes: &[u8]) -> (usize, Self) {
42 let (bytes_read, command): (usize, ChangeColor) = ChangeColor::parse(bytes);
43
44 (bytes_read, Self::ChangeColor(command))
45 }
46}