rpfm_lib/files/bmd/sound_shape_list/v1.rs
1//---------------------------------------------------------------------------//
2// Copyright (c) 2017-2024 Ismael Gutiérrez González. All rights reserved.
3//
4// This file is part of the Rusted PackFile Manager (RPFM) project,
5// which can be found here: https://github.com/Frodo45127/rpfm.
6//
7// This file is licensed under the MIT license, which can be found here:
8// https://github.com/Frodo45127/rpfm/blob/master/LICENSE.
9//---------------------------------------------------------------------------//
10
11use crate::binary::ReadBytes;
12use crate::error::Result;
13
14use super::*;
15
16//---------------------------------------------------------------------------//
17// Implementation of SoundShapeList
18//---------------------------------------------------------------------------//
19
20impl SoundShapeList {
21
22 pub(crate) fn read_v1<R: ReadBytes>(&mut self, data: &mut R, extra_data: &Option<DecodeableExtraData>) -> Result<()> {
23 for _ in 0..data.read_u32()? {
24 self.sound_shapes.push(SoundShape::decode(data, extra_data)?);
25 }
26
27 Ok(())
28 }
29
30 pub(crate) fn write_v1<W: WriteBytes>(&mut self, buffer: &mut W, extra_data: &Option<EncodeableExtraData>) -> Result<()> {
31 buffer.write_u32(self.sound_shapes.len() as u32)?;
32 for shape in &mut self.sound_shapes {
33 shape.encode(buffer, extra_data)?;
34 }
35
36 Ok(())
37 }
38}