66 lines
1.6 KiB
Rust
66 lines
1.6 KiB
Rust
//! `Light` type.
|
|
|
|
use crate::{durandal::{bin::OptU16, err::*, fixed::{Angle, Fixed, Unit}},
|
|
marathon::xfer::TransferMode};
|
|
use super::pnts::*;
|
|
|
|
/// Reads a `medi` chunk.
|
|
pub fn read(b: &[u8]) -> ResultS<(Media, usize)>
|
|
{
|
|
read_data! {
|
|
endian: BIG, buf: b, size: 32, start: 0, data {
|
|
let mtype = u16[0] enum MediaType;
|
|
let flags = u16[2];
|
|
let control = u16[4];
|
|
let dir = Angle[6];
|
|
let mag = Unit[8];
|
|
let hei_lo = Unit[10];
|
|
let hei_hi = Unit[12];
|
|
let orig = read_point[14; 4];
|
|
let hei_nrm = Unit[18];
|
|
let min_lt = Fixed[20];
|
|
let texture = OptU16[24];
|
|
let xfer = u16[26] enum TransferMode;
|
|
}
|
|
}
|
|
|
|
let flr_obs = flags != 0;
|
|
|
|
Ok((Media{mtype, flr_obs, control, dir, mag, hei_lo, hei_hi, orig, hei_nrm,
|
|
min_lt, texture, xfer}, 32))
|
|
}
|
|
|
|
/// A media, as in a part of a polygon which goes up the middle of the wall.
|
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
pub struct Media
|
|
{
|
|
pub mtype: MediaType,
|
|
pub flr_obs: bool,
|
|
pub control: u16,
|
|
pub dir: Angle,
|
|
pub mag: Unit,
|
|
pub hei_lo: Unit,
|
|
pub hei_hi: Unit,
|
|
pub orig: Point,
|
|
pub hei_nrm: Unit,
|
|
pub min_lt: Fixed,
|
|
pub texture: OptU16,
|
|
pub xfer: TransferMode,
|
|
}
|
|
|
|
c_enum! {
|
|
/// The liquid type of a `Media`.
|
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
|
#[derive(Debug)]
|
|
pub enum MediaType: u16
|
|
{
|
|
Water = 0,
|
|
Lava = 1,
|
|
Goo = 2,
|
|
Sewage = 3,
|
|
}
|
|
}
|
|
|
|
// EOF
|