| @@ -6,7 +6,7 @@ use glc::{ | |||||
| use rand::random; | use rand::random; | ||||
| use shrev::ReaderId; | use shrev::ReaderId; | ||||
| use specs::{ | use specs::{ | ||||
| hibitset::BitSet, prelude::*, Entities, ParJoin, Read, ReadStorage, System, WriteStorage, | |||||
| hibitset::BitSet, prelude::*, world::Index, ParJoin, Read, ReadStorage, System, WriteStorage, | |||||
| }; | }; | ||||
| use crate::{ | use crate::{ | ||||
| @@ -28,7 +28,6 @@ pub struct Ships { | |||||
| #[derive(SystemData)] | #[derive(SystemData)] | ||||
| pub struct ShipsData<'a> { | pub struct ShipsData<'a> { | ||||
| global: Read<'a, Global>, | global: Read<'a, Global>, | ||||
| entities: Entities<'a>, | |||||
| ships: WriteStorage<'a, Ship>, | ships: WriteStorage<'a, Ship>, | ||||
| velocities: WriteStorage<'a, Velocity>, | velocities: WriteStorage<'a, Velocity>, | ||||
| fleet_owned: ReadStorage<'a, FleetOwned>, | fleet_owned: ReadStorage<'a, FleetOwned>, | ||||
| @@ -86,7 +85,6 @@ impl<'a> System<'a> for Ships { | |||||
| fn run(&mut self, data: Self::SystemData) { | fn run(&mut self, data: Self::SystemData) { | ||||
| let ShipsData { | let ShipsData { | ||||
| global, | global, | ||||
| entities, | |||||
| mut ships, | mut ships, | ||||
| mut velocities, | mut velocities, | ||||
| fleet_owned, | fleet_owned, | ||||
| @@ -104,15 +102,15 @@ impl<'a> System<'a> for Ships { | |||||
| delta: global.delta, | delta: global.delta, | ||||
| }; | }; | ||||
| ( | ( | ||||
| &entities, | |||||
| positions.mask(), | |||||
| &mut ships, | &mut ships, | ||||
| &mut velocities, | &mut velocities, | ||||
| &positions, | &positions, | ||||
| &fleet_owned, | &fleet_owned, | ||||
| ) | ) | ||||
| .par_join() | .par_join() | ||||
| .for_each(|(entity, ship, velocity, position, fleet_owned)| { | |||||
| processor.progress_ship(entity, ship, velocity, position, fleet_owned); | |||||
| .for_each(|(id, ship, velocity, position, fleet_owned)| { | |||||
| processor.progress_ship(id, ship, velocity, position, fleet_owned); | |||||
| }); | }); | ||||
| } | } | ||||
| } | } | ||||
| @@ -120,7 +118,7 @@ impl<'a> System<'a> for Ships { | |||||
| impl Processor<'_> { | impl Processor<'_> { | ||||
| fn progress_ship( | fn progress_ship( | ||||
| &self, | &self, | ||||
| entity: Entity, | |||||
| id: Index, | |||||
| ship: &mut Ship, | ship: &mut Ship, | ||||
| velocity: &mut Velocity, | velocity: &mut Velocity, | ||||
| position: &Position, | position: &Position, | ||||
| @@ -146,7 +144,7 @@ impl Processor<'_> { | |||||
| let target_in_orbit = (r_target <= sqr(fleet.orbit_max)) && (r_target >= sqr(orbit_min)); | let target_in_orbit = (r_target <= sqr(fleet.orbit_max)) && (r_target >= sqr(orbit_min)); | ||||
| let ship_in_orbit = r_ship < sqr(SHIP_ORBIT_DISTANCE_MAX * orbit_max); | let ship_in_orbit = r_ship < sqr(SHIP_ORBIT_DISTANCE_MAX * orbit_max); | ||||
| let need_update = self.need_update.contains(entity.id()); | |||||
| let need_update = self.need_update.contains(id); | |||||
| let has_target = target_dir.length_sqr() != 0.0; | let has_target = target_dir.length_sqr() != 0.0; | ||||
| let passed_target = target_dir * ship_to_target <= 0.0; | let passed_target = target_dir * ship_to_target <= 0.0; | ||||