@@ -209,10 +209,36 @@ def send_match_comm(
209209 )
210210 )
211211
212- def set_game_state (self , game_state : flat .DesiredGameState ):
212+ def set_game_state (
213+ self ,
214+ balls : dict [int , flat .DesiredBallState ] = {},
215+ cars : dict [int , flat .DesiredCarState ] = {},
216+ game_info : Optional [flat .DesiredGameInfoState ] = None ,
217+ commands : list [flat .ConsoleCommand ] = [],
218+ ):
213219 """
214- Sets the game to the given desired state.
220+ Sets the game to the desired state.
215221 """
222+
223+ game_state = flat .DesiredGameState (
224+ game_info_state = game_info , console_commands = commands
225+ )
226+
227+ # convert the dictionaries to lists by
228+ # filling in the blanks with empty states
229+
230+ if balls :
231+ max_entry = max (balls .keys ())
232+ game_state .ball_states = [
233+ balls .get (i , flat .DesiredBallState ()) for i in range (max_entry + 1 )
234+ ]
235+
236+ if cars :
237+ max_entry = max (cars .keys ())
238+ game_state .car_states = [
239+ cars .get (i , flat .DesiredCarState ()) for i in range (max_entry + 1 )
240+ ]
241+
216242 self ._game_interface .send_game_state (game_state )
217243
218244 def set_loadout (self , loadout : flat .PlayerLoadout , spawn_id : int ):
0 commit comments