gdritter repos wenaglia / 166582f
Get rid of unused physics systems Getty Ritter 4 years ago
2 changed file(s) with 0 addition(s) and 41 deletion(s). Collapse all Expand all
1010 itertools = "0.8"
1111 specs = "0.15"
1212 specs-derive = "0.4.0"
13 # sdl2 = "*"
1413 ncollide2d = "0.20"
1514 nalgebra = "0.18"
16 # specs-physics = "*"
1715 winit = "0.19"
1816 mint = "0.5"
5252 }
5353 }
5454
55 struct Intersection;
56
57 impl<'a> specs::System<'a> for Intersection {
58 type SystemData = (
59 specs::Entities<'a>,
60 specs::ReadStorage<'a, Position>,
61 specs::ReadStorage<'a, Velocity>,
62 specs::ReadStorage<'a, Blocking>,
63 specs::WriteStorage<'a, Collision>,
64 );
65
66 fn run(&mut self, (entity, position, velocity, blocking, mut collision): Self::SystemData) {
67 let mut spacemap = std::collections::HashMap::new();
68 for (e, pos, _) in (&entity, &position, &blocking).join() {
69 spacemap.insert(pos.to_grid(), e);
70 }
71
72 for (pos, vel, col) in (&position, &velocity, &mut collision).join() {
73 if let Some(_) = spacemap.get(&pos.moved(vel).to_grid()) {
74 col.has_collision = true;
75 }
76 }
77 }
78 }
79
8055 struct Physics;
8156
8257 impl<'a> specs::System<'a> for Physics {
9671 }
9772 }
9873
99 struct ResetCollision;
100
101 impl<'a> specs::System<'a> for ResetCollision {
102 type SystemData = specs::WriteStorage<'a, Collision>;
103
104 fn run(&mut self, mut collision: Self::SystemData) {
105 for mut e in (&mut collision).join() {
106 e.has_collision = false;
107 }
108 }
109 }
110
11174 pub fn systems(game: &mut MyGame) {
11275 Collide.run_now(&game.world);
113 // Intersection.run_now(&game.world.res);
11476 Physics.run_now(&game.world);
115 // ResetCollision.run_now(&game.world);
11677 }