← 输入框|github.com|刷新
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rlbot/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def send_msg(
| flat.MatchConfiguration
| flat.PlayerInput
| flat.DesiredGameState
| flat.ConsoleCommand
| flat.RenderGroup
| flat.RemoveRenderGroup
| flat.MatchComm
Expand Down
14 changes: 10 additions & 4 deletions rlbot/managers/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,26 @@ def send_match_comm(
)
)

def set_game_state(
def send_console_command(self, cmd: str | flat.ConsoleCommand):
cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd)
self._game_interface.send_msg(cmd)

def set_game_state(self, game_state: flat.DesiredGameState):
self._game_interface.send_msg(game_state)

def set_game_state_parts(
self,
balls: dict[int, flat.DesiredBallState] = {},
cars: dict[int, flat.DesiredCarState] = {},
match_info: flat.DesiredMatchInfo | None = None,
commands: list[str] = [],
):
"""
Sets the game to the desired state.
Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more.
See wiki for a full break down and examples.
See wiki for a full breakdown and examples.
"""

game_state = fill_desired_game_state(balls, cars, match_info, commands)
game_state = fill_desired_game_state(balls, cars, match_info)
self._game_interface.send_msg(game_state)

def set_loadout(self, loadout: flat.PlayerLoadout, index: int | None = None):
Expand Down
14 changes: 10 additions & 4 deletions rlbot/managers/hivemind.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,26 @@ def send_match_comm(
)
)

def set_game_state(
def send_console_command(self, cmd: str | flat.ConsoleCommand):
cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd)
self._game_interface.send_msg(cmd)

def set_game_state(self, game_state: flat.DesiredGameState):
self._game_interface.send_msg(game_state)

def set_game_state_parts(
self,
balls: dict[int, flat.DesiredBallState] = {},
cars: dict[int, flat.DesiredCarState] = {},
match_info: flat.DesiredMatchInfo | None = None,
commands: list[str] = [],
):
"""
Sets the game to the desired state.
Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more.
See wiki for a full break down and examples.
See wiki for a full breakdown and examples.
"""

game_state = fill_desired_game_state(balls, cars, match_info, commands)
game_state = fill_desired_game_state(balls, cars, match_info)
self._game_interface.send_msg(game_state)

def set_loadout(self, loadout: flat.PlayerLoadout, index: int):
Expand Down
14 changes: 10 additions & 4 deletions rlbot/managers/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,26 @@ def stop_match(self):
self.packet = None
self.rlbot_interface.stop_match()

def set_game_state(
def send_console_command(self, cmd: str | flat.ConsoleCommand):
cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd)
self.rlbot_interface.send_msg(cmd)

def set_game_state(self, game_state: flat.DesiredGameState):
self.rlbot_interface.send_msg(game_state)

def set_game_state_parts(
self,
balls: dict[int, flat.DesiredBallState] = {},
cars: dict[int, flat.DesiredCarState] = {},
match_info: flat.DesiredMatchInfo | None = None,
commands: list[str] = [],
):
"""
Sets the game to the desired state.
Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more.
See wiki for a full break down and examples.
See wiki for a full breakdown and examples.
"""

game_state = fill_desired_game_state(balls, cars, match_info, commands)
game_state = fill_desired_game_state(balls, cars, match_info)
self.rlbot_interface.send_msg(game_state)

def shut_down(self, use_force_if_necessary: bool = True):
Expand Down
14 changes: 10 additions & 4 deletions rlbot/managers/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,26 @@ def send_match_comm(
)
)

def set_game_state(
def send_console_command(self, cmd: str | flat.ConsoleCommand):
cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd)
self._game_interface.send_msg(cmd)

def set_game_state(self, game_state: flat.DesiredGameState):
self._game_interface.send_msg(game_state)

def set_game_state_parts(
self,
balls: dict[int, flat.DesiredBallState] = {},
cars: dict[int, flat.DesiredCarState] = {},
match_info: flat.DesiredMatchInfo | None = None,
commands: list[str] = [],
):
"""
Sets the game to the desired state.
Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more.
See wiki for a full break down and examples.
See wiki for a full breakdown and examples.
"""

game_state = fill_desired_game_state(balls, cars, match_info, commands)
game_state = fill_desired_game_state(balls, cars, match_info)
self._game_interface.send_msg(game_state)

def set_loadout(self, loadout: flat.PlayerLoadout, index: int):
Expand Down
2 changes: 1 addition & 1 deletion rlbot/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.0-beta.56"
__version__ = "2.0.0-beta.57"
2 changes: 1 addition & 1 deletion tests/atba/atba.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState:
def test_state_setting(self, packet: flat.GamePacket):
if packet.match_info.seconds_elapsed > self.next_teleport:
self.next_teleport = packet.match_info.seconds_elapsed + 10
self.set_game_state(
self.set_game_state_parts(
{
0: flat.DesiredBallState(
flat.DesiredPhysics(
Expand Down
2 changes: 1 addition & 1 deletion tests/many_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def handle_match_comm(comm: flat.MatchComm):
match_manager.packet.match_info.match_phase == flat.MatchPhase.Active
and match_manager.packet.match_info.game_time_remaining < 60 * 4 + 55
):
match_manager.set_game_state(commands=["Pause"])
match_manager.send_console_command("Pause")
paused = True
break
sleep(1)
Expand Down
2 changes: 1 addition & 1 deletion tests/run_forever.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

while match_manager.packet.match_info.match_phase != flat.MatchPhase.Ended:
if match_manager.packet.match_info.match_phase == flat.MatchPhase.Countdown:
match_manager.set_game_state(
match_manager.set_game_state_parts(
match_info=flat.DesiredMatchInfo(game_speed=2)
)

Expand Down