/// <summary> /// Returns the game's FieldInfo. /// </summary> /// <returns>The game's FieldInfo.</returns> public static FieldInfo GetFieldInfo() { ByteBufferStruct byteBuffer = UpdateFieldInfoFlatbuffer(); if (byteBuffer.size < 4) throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); return FieldInfo.GetRootAsFieldInfo(new ByteBuffer(bufferBytes)); }
/// <summary> /// Returns the current frame's GameTickPacket. /// </summary> /// <returns>The current frame's GameTickPacket.</returns> public static GameTickPacket GetGameTickPacket() { ByteBufferStruct byteBuffer = UpdateLiveDataPacketFlatbuffer(); if (byteBuffer.size < 4) throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); return GameTickPacket.GetRootAsGameTickPacket(new ByteBuffer(bufferBytes)); }
/// <summary> /// Returns the current frame's RigidBodyTick. /// </summary> /// <returns>The current frame's RigidBodyTick.</returns> public static RigidBodyTick GetRigidBodyTick() { ByteBufferStruct byteBuffer = UpdateRigidBodyTickFlatbuffer(); if (byteBuffer.size < 4) { throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); } byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); Free(byteBuffer.ptr); return(RigidBodyTick.GetRootAsRigidBodyTick(new ByteBuffer(bufferBytes))); }
/// <summary> /// Returns the match settings that were most recently sent to RLBot. /// Useful for determining the game mode, what map we're playing on, mutators, etc. /// </summary> /// <returns>The MatchSettings object, as defined in the flatbuffer spec.</returns> public static MatchSettings GetMatchSettingsData() { ByteBufferStruct byteBuffer = GetMatchSettings(); if (byteBuffer.size < 4) { throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match settings are probably not available!"); } byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); Free(byteBuffer.ptr); return(MatchSettings.GetRootAsMatchSettings(new ByteBuffer(bufferBytes))); }
/// <summary> /// Gets a list of chat messages. /// </summary> /// <param name="botIndex">Index of the receiving bot.</param> /// <param name="teamIndex">Team index of the receiving bot.</param> /// <param name="lastMessageIndex">Message index of the last received message.</param> /// <returns>List of new messages.</returns> public static QuickChatMessages ReceiveQuickChat(int botIndex, int teamIndex, int lastMessageIndex) { ByteBufferStruct byteBuffer = ReceiveChat(botIndex, teamIndex, lastMessageIndex); if (byteBuffer.size < 4) { throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); } byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); Free(byteBuffer.ptr); return(QuickChatMessages.GetRootAsQuickChatMessages(new ByteBuffer(bufferBytes)));; }
/// <summary> /// Returns 6 seconds of the ball physics prediction. /// </summary> /// <returns>6 seconds of the ball physics prediction.</returns> public static BallPrediction GetBallPredictionData() { ByteBufferStruct byteBuffer = GetBallPrediction(); if (byteBuffer.size < 4) { throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); } byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); Free(byteBuffer.ptr); return(BallPrediction.GetRootAsBallPrediction(new ByteBuffer(bufferBytes))); }
public static GameTickPacket WaitForFreshPacket(int timeoutMillis, int key) { ByteBufferStruct byteBuffer = FreshLiveDataPacketFlatbuffer(timeoutMillis, key); if (byteBuffer.size < 4) { throw new FlatbuffersPacketException("Flatbuffers packet is too small. Match is probably not running!"); } byte[] bufferBytes = new byte[byteBuffer.size]; Marshal.Copy(byteBuffer.ptr, bufferBytes, 0, byteBuffer.size); Free(byteBuffer.ptr); return(GameTickPacket.GetRootAsGameTickPacket(new ByteBuffer(bufferBytes))); }