diff --git a/RLBot/Common/GameStateExt.cs b/RLBot/Common/GameStateExt.cs index 771e10c..6f9ac0d 100644 --- a/RLBot/Common/GameStateExt.cs +++ b/RLBot/Common/GameStateExt.cs @@ -7,14 +7,12 @@ static class GameStateExt public static DesiredGameStateT FillDesiredGameState( Dictionary? balls = null, Dictionary? cars = null, - DesiredMatchInfoT? matchInfo = null, - List? commands = null + DesiredMatchInfoT? matchInfo = null ) { var gameState = new DesiredGameStateT { MatchInfo = matchInfo, - ConsoleCommands = commands ?? new List(), }; if (balls != null) diff --git a/RLBot/GameState/DesiredGameStateBuilder.cs b/RLBot/GameState/DesiredGameStateBuilder.cs index 6044225..b411242 100644 --- a/RLBot/GameState/DesiredGameStateBuilder.cs +++ b/RLBot/GameState/DesiredGameStateBuilder.cs @@ -8,7 +8,6 @@ public struct DesiredGameStateBuilder(RLBotInterface rlbotInterface) { BallStates = new(), CarStates = new(), - ConsoleCommands = new(), }; /// @@ -101,15 +100,6 @@ Func build return this; } - /// - /// Add a console command. - /// - public DesiredGameStateBuilder Command(string cmd) - { - _state.ConsoleCommands.Add(new() { Command = cmd }); - return this; - } - public void BuildAndSend() { rlbotInterface.SendGameState(_state); diff --git a/RLBot/RLBot.csproj b/RLBot/RLBot.csproj index de1a730..a5beca0 100644 --- a/RLBot/RLBot.csproj +++ b/RLBot/RLBot.csproj @@ -2,7 +2,7 @@ RLBot.Framework - 3.0.0-alpha2 + 3.0.0-alpha5 RLBot Community RLBot diff --git a/RLBot/RLBotInterface.cs b/RLBot/RLBotInterface.cs index 4214cf5..97715d6 100644 --- a/RLBot/RLBotInterface.cs +++ b/RLBot/RLBotInterface.cs @@ -33,6 +33,7 @@ public class RLBotInterface public event Action OnBallPredictionCallback = delegate { }; public event Action OnControllableTeamInfoCallback = delegate { }; public event Action OnRenderingStatusCallback = delegate { }; + public event Action OnPingResponse = delegate { }; public event Action OnAnyMessageCallback = delegate { }; public RLBotInterface(int connectionTimeout = 120) @@ -79,14 +80,31 @@ public void SendGameState(DesiredGameStateT gameState) public void SendGameState( Dictionary? balls = null, Dictionary? cars = null, - DesiredMatchInfoT? matchInfo = null, - List? commands = null + DesiredMatchInfoT? matchInfo = null ) { - var gameState = GameStateExt.FillDesiredGameState(balls, cars, matchInfo, commands); + var gameState = GameStateExt.FillDesiredGameState(balls, cars, matchInfo); SendGameState(gameState); } + /// + /// Run a console command in Rocket League. + /// Find known console commands at https://wiki.rlbot.org/v5/framework/console-commands/ + /// + public void SendConsoleCommand(ConsoleCommandT command) + { + SendFlatBuffer(InterfaceMessageUnion.FromConsoleCommand(command)); + } + + /// + /// Run a console command in Rocket League. + /// Find known console commands at https://wiki.rlbot.org/v5/framework/console-commands/ + /// + public void SendConsoleCommand(string command) + { + SendConsoleCommand(new ConsoleCommandT { Command = command }); + } + /// /// Modify the current game state using a builder pattern. /// @@ -105,6 +123,16 @@ public void SendRemoveRenderGroup(RemoveRenderGroupT removeRenderGroup) SendFlatBuffer(InterfaceMessageUnion.FromRemoveRenderGroup(removeRenderGroup)); } + /// + /// Send ping request to the RLBotServer. + /// Subscribe to OnPingResponse to listen for response. + /// + public void SendPingRequest(ulong cookie) + { + var request = InterfaceMessageUnion.FromPingRequest(new PingRequestT { Cookie = cookie }); + SendFlatBuffer(request); + } + public void StopMatch(bool shutdownServer = false) { var stopCommand = new StopCommandT { ShutdownServer = shutdownServer }; @@ -360,6 +388,15 @@ private bool HandleMessage(CorePacketT packet) RenderingStatusT renderingStatus = packet.Message.AsRenderingStatus(); OnRenderingStatusCallback(renderingStatus); break; + case CoreMessage.PingRequest: + PingRequestT pingRequest = packet.Message.AsPingRequest(); + var response = new PingResponseT { Cookie = pingRequest.Cookie }; + SendFlatBuffer(InterfaceMessageUnion.FromPingResponse(response)); + break; + case CoreMessage.PingResponse: + PingResponseT pingResponse = packet.Message.AsPingResponse(); + OnPingResponse(pingResponse.Cookie); + break; default: _logger.LogWarning( "Received message of unknown type: {0}", diff --git a/RLBot/logo.png b/RLBot/logo.png index 3bf0e64..5ce3a53 100644 Binary files a/RLBot/logo.png and b/RLBot/logo.png differ diff --git a/Tests/RunMatch/Program.cs b/Tests/RunMatch/Program.cs index de91959..2c87a2c 100644 --- a/Tests/RunMatch/Program.cs +++ b/Tests/RunMatch/Program.cs @@ -10,6 +10,8 @@ rlbot.ConnectAsMatchHost(); rlbot.StartMatch(args[0]); +rlbot.SendConsoleCommand("HUDCycle"); + // Wait Console.WriteLine("\nPress enter to end the match: "); Console.ReadLine(); diff --git a/flatbuffers-schema b/flatbuffers-schema index 70bcb31..e007e44 160000 --- a/flatbuffers-schema +++ b/flatbuffers-schema @@ -1 +1 @@ -Subproject commit 70bcb31eb8e9093ca9200c913f5e1a2d57fdd025 +Subproject commit e007e445c7506f32b2a9b918a006aafae403a47d