lcf/formats/raw/lmt/
map.rs1use crate::{
2 helpers::{Array, Chunk, Number, ToChunkID},
3 raw::shared::MusicChunk,
4};
5
6#[binrw::binrw]
7#[derive(Clone, Debug)]
8#[brw(little)]
9#[br(import(id: u32, length: u32))]
10pub enum MapChunk {
11 #[br(pre_assert(id == 1))]
13 Name(#[br(count = length)] Vec<u8>),
14 #[br(pre_assert(id == 2))]
15 Parent(Number),
16 #[br(pre_assert(id == 3))]
17 Indentation(Number),
18 #[br(pre_assert(id == 4))]
19 Type(Number),
20 #[br(pre_assert(id == 5))]
21 HorizontalScrollBar(Number),
22 #[br(pre_assert(id == 6))]
23 VerticalScrollBar(Number),
24 #[br(pre_assert(id == 7))]
26 Expanded(Number),
27 #[br(pre_assert(id == 11))]
31 BGM(Number),
32 #[br(pre_assert(id == 12))]
33 BGMData(Array<Chunk<MusicChunk>>),
34 #[br(pre_assert(id == 21))]
38 Background(Number),
39 #[br(pre_assert(id == 22))]
40 BackgroundFile(#[br(count = length)] Vec<u8>),
41 #[br(pre_assert(id == 31))]
45 Teleport(Number),
46 #[br(pre_assert(id == 32))]
47 Escape(Number),
48 #[br(pre_assert(id == 33))]
49 Save(Number),
50 #[br(pre_assert(id == 41))]
51 EncounterEnemyGroup(#[br(count = length)] Vec<u8>),
52 #[br(pre_assert(id == 44))]
54 EnemyAppearStep(Number),
55 #[br(pre_assert(id == 51))]
57 AreaRange {
58 begin_x: u32,
59 begin_y: u32,
60 end_x: u32,
61 end_y: u32,
62 },
63
64 Unknown {
65 #[br(calc = id)]
66 #[bw(ignore)]
67 id: u32,
68
69 #[br(count = length)]
70 bytes: Vec<u8>,
71 },
72}
73
74impl ToChunkID for MapChunk {
75 fn id(&self) -> u32 {
76 match self {
77 Self::Name(_) => 1,
78 Self::Parent(_) => 2,
79 Self::Indentation(_) => 3,
80 Self::Type(_) => 4,
81 Self::HorizontalScrollBar(_) => 5,
82 Self::VerticalScrollBar(_) => 6,
83 Self::Expanded(_) => 7,
84 Self::BGM(_) => 11,
85 Self::BGMData(_) => 12,
86 Self::Background(_) => 21,
87 Self::BackgroundFile(_) => 22,
88 Self::Teleport(_) => 31,
89 Self::Escape(_) => 32,
90 Self::Save(_) => 33,
91 Self::EncounterEnemyGroup(_) => 41,
92 Self::EnemyAppearStep(_) => 44,
93 Self::AreaRange { .. } => 51,
94 Self::Unknown { id, .. } => *id,
95 }
96 }
97}