Browse Source

Add component_mut function to entity descriptor trait

tags/v0.5.1
NGnius (Graham) 2 years ago
parent
commit
970a6eb500
12 changed files with 91 additions and 0 deletions
  1. +5
    -0
      src/techblox/block_group_entity.rs
  2. +15
    -0
      src/techblox/blocks/block_entity.rs
  3. +6
    -0
      src/techblox/blocks/engine.rs
  4. +4
    -0
      src/techblox/blocks/joint.rs
  5. +6
    -0
      src/techblox/blocks/passenger_seat.rs
  6. +6
    -0
      src/techblox/blocks/pilot_seat.rs
  7. +14
    -0
      src/techblox/blocks/spring.rs
  8. +4
    -0
      src/techblox/blocks/tyre.rs
  9. +13
    -0
      src/techblox/blocks/wheel_rig.rs
  10. +8
    -0
      src/techblox/blocks/wire_entity.rs
  11. +8
    -0
      src/techblox/camera.rs
  12. +2
    -0
      src/techblox/entity_traits.rs

+ 5
- 0
src/techblox/block_group_entity.rs View File

@@ -22,6 +22,11 @@ impl SerializedEntityDescriptor for BlockGroupEntity {
&self.block_group_transform]
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.saved_block_group_id,
&mut self.block_group_transform]
}

fn hash_name(&self) -> u32 {
Self::hash("BlockGroupEntityDescriptorV0")
}


+ 15
- 0
src/techblox/blocks/block_entity.rs View File

@@ -56,6 +56,21 @@ impl SerializedEntityDescriptor for BlockEntity {
&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") // 1357220432
}


+ 6
- 0
src/techblox/blocks/engine.rs View File

@@ -22,6 +22,12 @@ impl SerializedEntityDescriptor for EngineBlockEntity {
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("EngineBlockEntityDescriptor") // 1757314505
}


+ 4
- 0
src/techblox/blocks/joint.rs View File

@@ -18,6 +18,10 @@ impl SerializedEntityDescriptor for JointBlockEntity {
self.block.components()
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
self.block.components_mut()
}

fn hash_name(&self) -> u32 {
Self::hash("JointBlockEntityDescriptorV3") // 3586818581
}


+ 6
- 0
src/techblox/blocks/passenger_seat.rs View File

@@ -22,6 +22,12 @@ impl SerializedEntityDescriptor for PassengerSeatEntity {
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.cam_component);
return c;
}

fn hash_name(&self) -> u32 {
Self::hash("PassengerSeatEntityDescriptorV4") // 1360086092
}


+ 6
- 0
src/techblox/blocks/pilot_seat.rs View File

@@ -21,6 +21,12 @@ impl SerializedEntityDescriptor for PilotSeatEntity {
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.cam_component);
return c;
}

fn hash_name(&self) -> u32 {
Self::hash("PilotSeatEntityDescriptorV4") // 2281299333
}


+ 14
- 0
src/techblox/blocks/spring.rs View File

@@ -25,6 +25,13 @@ impl SerializedEntityDescriptor for DampedAngularSpringEntity {
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") // 3789998433
}
@@ -53,6 +60,13 @@ impl SerializedEntityDescriptor for DampedSpringEntity {
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") // 2892049599
}


+ 4
- 0
src/techblox/blocks/tyre.rs View File

@@ -18,6 +18,10 @@ impl SerializedEntityDescriptor for TyreEntity {
self.block.components()
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
self.block.components_mut()
}

fn hash_name(&self) -> u32 {
Self::hash("TyreEntityDescriptorV1") // 1517625162
}


+ 13
- 0
src/techblox/blocks/wheel_rig.rs View File

@@ -25,6 +25,13 @@ impl SerializedEntityDescriptor for WheelRigEntity {
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") // 1156723746
}
@@ -50,6 +57,12 @@ impl SerializedEntityDescriptor for WheelRigSteerableEntity {
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") // 1864425618
}


+ 8
- 0
src/techblox/blocks/wire_entity.rs View File

@@ -18,6 +18,10 @@ impl SerializedEntityDescriptor for SerializedWireEntity {
vec![&self.save_data_component]
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.save_data_component]
}

fn hash_name(&self) -> u32 {
Self::hash("WireEntityDescriptorMock") // 1818308818
}
@@ -54,6 +58,10 @@ impl SerializedEntityDescriptor for SerializedGlobalWireSettingsEntity {
vec![&self.settings_component]
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.settings_component]
}

fn hash_name(&self) -> u32 {
Self::hash("GlobalWireSettingsEntityDescriptor") // 1820064641
}


+ 8
- 0
src/techblox/camera.rs View File

@@ -18,6 +18,10 @@ impl SerializedEntityDescriptor for SerializedFlyCamEntity {
vec![&self.rb_component]
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.rb_component]
}

fn hash_name(&self) -> u32 {
Self::hash("FlyCamEntityDescriptorV0") // 252528354
}
@@ -48,6 +52,10 @@ impl SerializedEntityDescriptor for SerializedPhysicsCameraEntity {
vec![&self.cam_component]
}

fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent> {
vec![&mut self.cam_component]
}

fn hash_name(&self) -> u32 {
Self::hash("CharacterCameraEntityDescriptorV1") // 3850144645
}


+ 2
- 0
src/techblox/entity_traits.rs View File

@@ -14,6 +14,8 @@ pub trait SerializedEntityDescriptor: Parsable {
fn serialized_components() -> u8 where Self: Sized;
/// Components that this entity is comprised of
fn components<'a>(&'a self) -> Vec<&'a dyn SerializedEntityComponent>;
/// Components that this entity is comprised of, for modification
fn components_mut<'a>(&'a mut self) -> Vec<&'a mut dyn SerializedEntityComponent>;
/// Hash of descriptor name
fn hash_name(&self) -> u32;
/// Hash of descriptor name


Loading…
Cancel
Save