use std::convert::AsRef;
use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent};
use crate::techblox::blocks::{DBEntityStruct, PositionEntityStruct, ScalingEntityStruct, RotationEntityStruct,
SkewComponent, GridRotationStruct, SerializedGridConnectionsEntityStruct, SerializedBlockPlacementInfoStruct,
SerializedCubeMaterialStruct, SerializedUniformBlockScaleEntityStruct, SerializedColourParameterEntityStruct,
BlockGroupEntityComponent};
use libfj_parsable_macro_derive::*;
#[derive(Copy, Clone, Parsable)]
pub struct BlockEntity {
pub db_component: DBEntityStruct,
pub pos_component: PositionEntityStruct,
pub scale_component: ScalingEntityStruct,
pub rot_component: RotationEntityStruct,
pub skew_component: SkewComponent,
pub grid_component: GridRotationStruct,
pub grid_conn_component: SerializedGridConnectionsEntityStruct,
pub placement_component: SerializedBlockPlacementInfoStruct,
pub material_component: SerializedCubeMaterialStruct,
pub uscale_component: SerializedUniformBlockScaleEntityStruct,
pub colour_component: SerializedColourParameterEntityStruct,
pub group_component: BlockGroupEntityComponent,
}
impl SerializedEntityDescriptor for BlockEntity {
fn serialized_components() -> u8 {
12
}
fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
vec![&self.db_component,
&self.pos_component,
&self.scale_component,
&self.rot_component,
&self.skew_component,
&self.grid_component,
&self.grid_conn_component,
&self.placement_component,
&self.material_component,
&self.uscale_component,
&self.colour_component,
&self.group_component]
}
fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.db_component,
&mut self.pos_component,
&mut self.scale_component,
&mut self.rot_component,
&mut self.skew_component,
&mut self.grid_component,
&mut self.grid_conn_component,
&mut self.placement_component,
&mut self.material_component,
&mut self.uscale_component,
&mut self.colour_component,
&mut self.group_component]
}
fn hash_name(&self) -> u32 {
Self::hash("StandardBlockEntityDescriptorV4") }
}
impl AsRef<BlockEntity> for BlockEntity {
fn as_ref(&self) -> &Self {
self
}
}
pub trait Block: SerializedEntityDescriptor + AsRef<BlockEntity> {}
impl Block for BlockEntity {}