wgtk/space/section/
bwal.rs

1use std::io::{Read, Seek};
2
3use super::{Section, SectionId};
4use crate::util::io::WgReadExt;
5
6
7/// AssetList section, defines a list of assets for this space.
8#[derive(Debug)]
9pub struct BWAL {
10    pub assets: Vec<AssetInfo>
11}
12
13impl Section for BWAL {
14
15    const ID: &'static SectionId = b"BWAL";
16
17    fn decode<R: Read + Seek>(read: &mut R) -> std::io::Result<Self> {
18
19        let assets = read.read_vector(|buf| {
20
21            let asset_type = match buf.read_u32()? {
22                1 => AssetType::ParticlesResource,
23                2 => AssetType::WaterReflectionTexture,
24                5 => AssetType::ControlPointRadiusPath,
25                6 => AssetType::ModelResource,
26                _ => panic!("invalid asset type")
27            };
28
29            Ok(AssetInfo {
30                asset_type,
31                string_fnv: buf.read_u32()?
32            })
33
34        })?;
35
36        Ok(BWAL { assets })
37
38    }
39
40}
41
42
43/// An compiled space asset info.
44/// Decoded by [BWAL] section.
45#[derive(Debug)]
46pub struct AssetInfo {
47    pub asset_type: AssetType,
48    pub string_fnv: u32
49}
50
51
52/// An asset type for an [AssetInfo].
53/// Decoded by [BWAL] section.
54#[derive(Debug)]
55pub enum AssetType {
56    ParticlesResource,
57    WaterReflectionTexture,
58    ControlPointRadiusPath,
59    ModelResource
60}