-
Notifications
You must be signed in to change notification settings - Fork 0
/
combo_prm.rs
55 lines (41 loc) · 1.2 KB
/
combo_prm.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
use binrw::binrw;
use serde::{Serialize, Deserialize};
use super::{NuccBinaryParsed, NuccBinaryType};
// Format reversed by Kuroha Saenoki (https://www.youtube.com/@KurohaSaenoki)
#[binrw]
#[derive(Serialize, Deserialize, Debug)]
pub struct Entry {
pub combo_begin_type: i32,
pub command: i32, // Type of move (neutral = 0x1, up = 0x2 , down = 0x3, throw = 0x4, etc)
pub delay: i32, // Delay before next move
}
#[binrw]
#[derive(Serialize, Deserialize, Debug)]
pub struct ComboPrm {
#[serde(skip)]
#[bw(calc = 1001)]
pub version: u32,
pub entry_count: u32,
#[serde(skip)]
#[bw(calc = 0x8)]
pub entry_ptr: u64,
#[br(count = entry_count)]
pub entries: Vec<Entry>
}
impl NuccBinaryParsed for ComboPrm {
fn binary_type(&self) -> NuccBinaryType {
NuccBinaryType::ComboPrm
}
fn extension(&self) -> String {
String::from(".json")
}
fn serialize(&self) -> Vec<u8> {
serde_json::to_string_pretty(self).unwrap().into()
}
fn deserialize(data: &[u8]) -> Self
where
Self: Sized,
{
serde_json::from_slice(data).unwrap()
}
}