2025-03-19 00:28:47 -04:00
|
|
|
use binrw::binrw;
|
|
|
|
|
2025-03-29 14:14:03 -04:00
|
|
|
use crate::common::{ObjectTypeId, read_quantized_rotation, write_quantized_rotation};
|
2025-03-29 12:25:22 -04:00
|
|
|
|
2025-03-19 00:28:47 -04:00
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug, Eq, PartialEq, Clone, Default)]
|
|
|
|
#[brw(repr = u8)]
|
|
|
|
pub enum ActionKind {
|
|
|
|
#[default]
|
|
|
|
Nothing = 0x0,
|
|
|
|
Normal = 0x1,
|
2025-05-02 15:36:22 -04:00
|
|
|
Item = 0x2,
|
2025-03-19 00:28:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
|
|
pub struct ActionRequest {
|
|
|
|
pub exec_proc: u8, // what?
|
|
|
|
pub action_kind: ActionKind,
|
2025-05-01 23:20:56 -04:00
|
|
|
#[brw(pad_before = 2)] // padding, i think it's filled with GARBAGE
|
|
|
|
pub action_key: u32, // See Action Excel sheet
|
2025-03-29 14:14:03 -04:00
|
|
|
pub request_id: u16,
|
|
|
|
#[br(map = read_quantized_rotation)]
|
|
|
|
#[bw(map = write_quantized_rotation)]
|
|
|
|
pub rotation: f32,
|
2025-03-19 00:28:47 -04:00
|
|
|
pub dir: u16,
|
|
|
|
pub dir_target: u16,
|
2025-03-29 12:25:22 -04:00
|
|
|
pub target: ObjectTypeId,
|
2025-03-19 00:28:47 -04:00
|
|
|
pub arg: u32,
|
2025-03-27 23:53:15 -04:00
|
|
|
pub padding_prob: u32,
|
2025-03-19 00:28:47 -04:00
|
|
|
}
|
2025-03-29 14:14:03 -04:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use std::{fs::read, io::Cursor, path::PathBuf};
|
|
|
|
|
|
|
|
use binrw::BinRead;
|
|
|
|
|
|
|
|
use crate::common::ObjectId;
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn read_actionrequest() {
|
|
|
|
let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
|
|
d.push("resources/tests/action_request.bin");
|
|
|
|
|
|
|
|
let buffer = read(d).unwrap();
|
|
|
|
let mut buffer = Cursor::new(&buffer);
|
|
|
|
|
|
|
|
let action_request = ActionRequest::read_le(&mut buffer).unwrap();
|
|
|
|
assert_eq!(action_request.target.object_id, ObjectId(0x400097d0));
|
|
|
|
assert_eq!(action_request.request_id, 0x2);
|
|
|
|
assert_eq!(action_request.rotation, 1.9694216);
|
|
|
|
}
|
|
|
|
}
|