Browse Source

Remove unneded system data from ships system

master
Bergmann89 3 years ago
parent
commit
5a52cc04c4
1 changed files with 6 additions and 8 deletions
  1. +6
    -8
      space-crush-common/src/systems/ships.rs

+ 6
- 8
space-crush-common/src/systems/ships.rs View File

@@ -6,7 +6,7 @@ use glc::{
use rand::random;
use shrev::ReaderId;
use specs::{
hibitset::BitSet, prelude::*, Entities, ParJoin, Read, ReadStorage, System, WriteStorage,
hibitset::BitSet, prelude::*, world::Index, ParJoin, Read, ReadStorage, System, WriteStorage,
};

use crate::{
@@ -28,7 +28,6 @@ pub struct Ships {
#[derive(SystemData)]
pub struct ShipsData<'a> {
global: Read<'a, Global>,
entities: Entities<'a>,
ships: WriteStorage<'a, Ship>,
velocities: WriteStorage<'a, Velocity>,
fleet_owned: ReadStorage<'a, FleetOwned>,
@@ -86,7 +85,6 @@ impl<'a> System<'a> for Ships {
fn run(&mut self, data: Self::SystemData) {
let ShipsData {
global,
entities,
mut ships,
mut velocities,
fleet_owned,
@@ -104,15 +102,15 @@ impl<'a> System<'a> for Ships {
delta: global.delta,
};
(
&entities,
positions.mask(),
&mut ships,
&mut velocities,
&positions,
&fleet_owned,
)
.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<'_> {
fn progress_ship(
&self,
entity: Entity,
id: Index,
ship: &mut Ship,
velocity: &mut Velocity,
position: &Position,
@@ -146,7 +144,7 @@ impl Processor<'_> {
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 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 passed_target = target_dir * ship_to_target <= 0.0;



Loading…
Cancel
Save