use std::io::Read;
use anyhow::Result;
use crate::core::synched_object::SynchedObjectData;
use crate::core::uoid::{Uoid, read_key_uoid};
use crate::material::layer::Color;
use crate::resource::prp::PlasmaRead;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FogType {
Linear = 0,
ExpX = 1,
Exp2X = 2,
}
impl FogType {
pub fn from_u8(v: u8) -> Self {
match v {
1 => Self::ExpX,
2 => Self::Exp2X,
_ => Self::Linear,
}
}
}
#[derive(Debug, Clone)]
pub struct FogEnvironmentData {
pub self_key: Option<Uoid>,
pub synched: SynchedObjectData,
pub fog_type: FogType,
pub start: f32,
pub end: f32,
pub density: f32,
pub color: Color,
}
impl FogEnvironmentData {
pub fn read(reader: &mut impl Read) -> Result<Self> {
let self_key = read_key_uoid(reader)?;
let synched = SynchedObjectData::read(reader)?;
let fog_type = FogType::from_u8(reader.read_u8()?);
let start = reader.read_f32()?;
let end = reader.read_f32()?;
let density = reader.read_f32()?;
let color = Color::read(reader)?;
Ok(Self {
self_key,
synched,
fog_type,
start,
end,
density,
color,
})
}
}