Maraiah/maraiah/map/attk.rs

39 lines
797 B
Rust
Raw Normal View History

2019-04-01 01:38:51 -07:00
//! `Attack` type.
2019-06-13 18:09:07 -07:00
use crate::{bin::OptU16, err::*, fixed::{Angle, Unit}};
2019-04-01 01:38:51 -07:00
/// Reads an `Attack` object.
pub fn read(b: &[u8]) -> ResultS<Attack>
{
2019-07-05 20:21:11 -07:00
read_data! {
endian: BIG, buf: b, size: 16, start: 0, data {
let ptype = OptU16[0];
let rep = u16[2];
let error = Angle[4];
let range = Unit[6];
let shape = u16[8];
let ofs_x = Unit[10];
let ofs_y = Unit[12];
let ofs_z = Unit[14];
}
}
2019-04-01 01:38:51 -07:00
2019-07-05 20:21:11 -07:00
Ok(Attack{ptype, rep, error, range, shape, ofs_x, ofs_y, ofs_z})
2019-04-01 01:38:51 -07:00
}
/// The definition of a monster's attack.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
#[derive(Debug, Eq, PartialEq)]
2019-06-25 03:52:21 -07:00
pub struct Attack {
2019-07-05 20:21:11 -07:00
pub ptype: OptU16,
pub rep: u16,
pub error: Angle,
pub range: Unit,
pub shape: u16,
pub ofs_x: Unit,
pub ofs_y: Unit,
pub ofs_z: Unit,
2019-04-01 01:38:51 -07:00
}
// EOF