use std::convert::AsRef;
use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent,
blocks::{BlockEntity, TweakableJointDampingComponent, Block}};
use libfj_parsable_macro_derive::*;
#[derive(Copy, Clone, Parsable)]
pub struct WheelRigEntity {
pub block: BlockEntity,
pub tweak_component: WheelRigTweakableStruct,
pub joint_component: TweakableJointDampingComponent,
}
impl SerializedEntityDescriptor for WheelRigEntity {
fn serialized_components() -> u8 {
BlockEntity::serialized_components() + 2
}
fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
let mut c = self.block.components();
c.push(&self.tweak_component);
c.push(&self.joint_component);
return c;
}
fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
let mut c = self.block.components_mut();
c.push(&mut self.tweak_component);
c.push(&mut self.joint_component);
return c;
}
fn hash_name(&self) -> u32 {
Self::hash("WheelRigEntityDescriptor") }
}
impl AsRef<BlockEntity> for WheelRigEntity {
fn as_ref(&self) -> &BlockEntity {
&self.block
}
}
impl Block for WheelRigEntity {}
#[derive(Copy, Clone, Parsable)]
pub struct WheelRigSteerableEntity {
pub block: WheelRigEntity,
pub tweak_component: WheelRigSteerableTweakableStruct,
}
impl SerializedEntityDescriptor for WheelRigSteerableEntity {
fn serialized_components() -> u8 {
WheelRigEntity::serialized_components() + 1
}
fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent> {
let mut c = self.block.components();
c.push(&self.tweak_component);
return c;
}
fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
let mut c = self.block.components_mut();
c.push(&mut self.tweak_component);
return c;
}
fn hash_name(&self) -> u32 {
Self::hash("WheelRigSteerableEntityDescriptor") }
}
impl AsRef<BlockEntity> for WheelRigSteerableEntity {
fn as_ref(&self) -> &BlockEntity {
&self.block.as_ref()
}
}
impl Block for WheelRigSteerableEntity {}
#[derive(Copy, Clone, Parsable)]
pub struct WheelRigTweakableStruct {
pub braking_strength: f32,
}
impl SerializedEntityComponent for WheelRigTweakableStruct {}
#[derive(Copy, Clone, Parsable)]
pub struct WheelRigSteerableTweakableStruct {
pub steer_angle: f32,
}
impl SerializedEntityComponent for WheelRigSteerableTweakableStruct {}