use std::convert::AsRef;
use crate::techblox::{SerializedEntityDescriptor, Parsable, SerializedEntityComponent,
blocks::{BlockEntity, Block}};
use libfj_parsable_macro_derive::*;
#[derive(Copy, Clone, Parsable)]
pub struct DampedAngularSpringEntity {
pub block: BlockEntity,
pub tweak_component: TweakableJointDampingComponent,
pub spring_component: DampedAngularSpringROStruct,
}
impl SerializedEntityDescriptor for DampedAngularSpringEntity {
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.spring_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.spring_component);
return c;
}
fn hash_name(&self) -> u32 {
Self::hash("DampedAngularSpringEntityDescriptorV4") }
}
impl AsRef<BlockEntity> for DampedAngularSpringEntity {
fn as_ref(&self) -> &BlockEntity {
&self.block
}
}
impl Block for DampedAngularSpringEntity {}
#[derive(Copy, Clone, Parsable)]
pub struct DampedSpringEntity {
pub block: BlockEntity,
pub tweak_component: TweakableJointDampingComponent,
pub spring_component: DampedSpringROStruct,
}
impl SerializedEntityDescriptor for DampedSpringEntity {
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.spring_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.spring_component);
return c;
}
fn hash_name(&self) -> u32 {
Self::hash("DampedSpringEntityDescriptorV5") }
}
impl AsRef<BlockEntity> for DampedSpringEntity {
fn as_ref(&self) -> &BlockEntity {
&self.block
}
}
impl Block for DampedSpringEntity {}
#[derive(Copy, Clone, Parsable)]
pub struct TweakableJointDampingComponent {
pub stiffness: f32,
pub damping: f32,
}
impl SerializedEntityComponent for TweakableJointDampingComponent {}
#[derive(Copy, Clone, Parsable)]
pub struct DampedSpringROStruct {
pub max_extension: f32,
}
impl SerializedEntityComponent for DampedSpringROStruct {}
#[derive(Copy, Clone, Parsable)]
pub struct DampedAngularSpringROStruct {
pub joint_min: f32,
pub joint_max: f32,
}
impl SerializedEntityComponent for DampedAngularSpringROStruct {}