|
| 1 | +use std::time::Duration; |
| 2 | + |
1 | 3 | use bevy::prelude::*; |
2 | 4 |
|
3 | | -use linear_algebra::{point, vector, Isometry2}; |
| 5 | +use linear_algebra::{point, vector}; |
4 | 6 | use scenario::scenario; |
5 | | -use spl_network_messages::{GameState, PlayerNumber}; |
| 7 | +use spl_network_messages::{GameState, Penalty, PlayerNumber, Team}; |
6 | 8 |
|
7 | 9 | use bevyhavior_simulator::{ |
8 | 10 | ball::BallResource, |
@@ -40,39 +42,42 @@ fn update( |
40 | 42 | mut ball: ResMut<BallResource>, |
41 | 43 | mut exit: EventWriter<AppExit>, |
42 | 44 | mut robots: Query<&mut Robot>, |
| 45 | + mut game_controller_commands: EventWriter<GameControllerCommand>, |
43 | 46 | ) { |
44 | 47 | if time.ticks() == 4150 { |
45 | | - robots |
46 | | - .iter_mut() |
47 | | - .find(|robot| robot.parameters.player_number == PlayerNumber::Two) |
48 | | - .unwrap() |
49 | | - .database |
50 | | - .main_outputs |
51 | | - .ground_to_field = Some(Isometry2::from_parts(vector![-3.0, 3.0], 0.0)); |
| 48 | + game_controller_commands.send(GameControllerCommand::Penalize( |
| 49 | + PlayerNumber::Two, |
| 50 | + Penalty::Manual { |
| 51 | + remaining: Duration::from_secs(1), |
| 52 | + }, |
| 53 | + Team::Hulks, |
| 54 | + )); |
| 55 | + } |
| 56 | + |
| 57 | + if time.ticks() == 4155 { |
| 58 | + game_controller_commands.send(GameControllerCommand::Unpenalize( |
| 59 | + PlayerNumber::Two, |
| 60 | + Team::Hulks, |
| 61 | + )); |
52 | 62 | } |
| 63 | + |
53 | 64 | if time.ticks() == 4200 { |
54 | 65 | ball.state = None; |
55 | 66 | } |
56 | | - if time.ticks() == 4400 { |
57 | | - if let MotionCommand::Stand { head: _ } = robots |
| 67 | + |
| 68 | + if time.ticks() == 4660 { |
| 69 | + if let MotionCommand::Stand { .. } = robots |
58 | 70 | .iter_mut() |
59 | 71 | .find(|robot| robot.parameters.player_number == PlayerNumber::Two) |
60 | 72 | .unwrap() |
61 | 73 | .database |
62 | 74 | .main_outputs |
63 | 75 | .motion_command |
64 | 76 | { |
65 | | - println!("Standing searcher after penalty"); |
| 77 | + println!("Standing searcher at penalty walk-in"); |
66 | 78 | exit.send(AppExit::from_code(1)); |
67 | 79 | } |
68 | | - if let MotionCommand::Walk { |
69 | | - head: _, |
70 | | - path: _, |
71 | | - left_arm: _, |
72 | | - right_arm: _, |
73 | | - orientation_mode: _, |
74 | | - speed: _, |
75 | | - } = robots |
| 80 | + if let MotionCommand::Walk { .. } = robots |
76 | 81 | .iter_mut() |
77 | 82 | .find(|robot| robot.parameters.player_number == PlayerNumber::Three) |
78 | 83 | .unwrap() |
|
0 commit comments