|
@@ -52,31 +52,6 @@ impl<'a> specs::System<'a> for Collide {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct Intersection;
|
|
|
-
|
|
|
-impl<'a> specs::System<'a> for Intersection {
|
|
|
- type SystemData = (
|
|
|
- specs::Entities<'a>,
|
|
|
- specs::ReadStorage<'a, Position>,
|
|
|
- specs::ReadStorage<'a, Velocity>,
|
|
|
- specs::ReadStorage<'a, Blocking>,
|
|
|
- specs::WriteStorage<'a, Collision>,
|
|
|
- );
|
|
|
-
|
|
|
- fn run(&mut self, (entity, position, velocity, blocking, mut collision): Self::SystemData) {
|
|
|
- let mut spacemap = std::collections::HashMap::new();
|
|
|
- for (e, pos, _) in (&entity, &position, &blocking).join() {
|
|
|
- spacemap.insert(pos.to_grid(), e);
|
|
|
- }
|
|
|
-
|
|
|
- for (pos, vel, col) in (&position, &velocity, &mut collision).join() {
|
|
|
- if let Some(_) = spacemap.get(&pos.moved(vel).to_grid()) {
|
|
|
- col.has_collision = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
struct Physics;
|
|
|
|
|
|
impl<'a> specs::System<'a> for Physics {
|
|
@@ -96,21 +71,7 @@ impl<'a> specs::System<'a> for Physics {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct ResetCollision;
|
|
|
-
|
|
|
-impl<'a> specs::System<'a> for ResetCollision {
|
|
|
- type SystemData = specs::WriteStorage<'a, Collision>;
|
|
|
-
|
|
|
- fn run(&mut self, mut collision: Self::SystemData) {
|
|
|
- for mut e in (&mut collision).join() {
|
|
|
- e.has_collision = false;
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
pub fn systems(game: &mut MyGame) {
|
|
|
Collide.run_now(&game.world);
|
|
|
- // Intersection.run_now(&game.world.res);
|
|
|
Physics.run_now(&game.world);
|
|
|
- // ResetCollision.run_now(&game.world);
|
|
|
}
|