Beispiel #1
0
        /// <summary>
        /// Parses the given GameTickPacket into the info required for our bot
        /// </summary>
        /// <param name="packet">The next tick packet</param>
        /// <returns>A GameState object containing the parsed values</returns>
        public static GameState ParseFromPacket(rlbot.flat.GameTickPacket packet)
        {
            GameState state = new GameState();

            // Ball information
            state.Ball = Ball.ParseFromGamePacket(packet);
            // Boost pads
            if (state.BoostPadStates == null)
            {
                state.BoostPadStates = new List <BoostPadState>(packet.BoostPadStatesLength);
            }
            for (int i = 0; i < packet.BoostPadStatesLength; i++)
            {
                state.BoostPadStates.Add(packet.BoostPadStates(i).GetValueOrDefault());
            }
            // Players
            if (state.Players == null)
            {
                state.Players = new List <PlayerInfo>(packet.PlayersLength);
            }
            for (int i = 0; i < packet.PlayersLength; i++)
            {
                state.Players.Add(packet.Players(i).GetValueOrDefault());
            }
            return(state);
        }
Beispiel #2
0
 public static Offset <GameTickPacket> CreateGameTickPacket(FlatBufferBuilder builder,
                                                            VectorOffset playersOffset         = default(VectorOffset),
                                                            VectorOffset boostPadStatesOffset  = default(VectorOffset),
                                                            Offset <BallInfo> ballOffset       = default(Offset <BallInfo>),
                                                            Offset <GameInfo> gameInfoOffset   = default(Offset <GameInfo>),
                                                            VectorOffset tileInformationOffset = default(VectorOffset),
                                                            VectorOffset teamsOffset           = default(VectorOffset))
 {
     builder.StartObject(6);
     GameTickPacket.AddTeams(builder, teamsOffset);
     GameTickPacket.AddTileInformation(builder, tileInformationOffset);
     GameTickPacket.AddGameInfo(builder, gameInfoOffset);
     GameTickPacket.AddBall(builder, ballOffset);
     GameTickPacket.AddBoostPadStates(builder, boostPadStatesOffset);
     GameTickPacket.AddPlayers(builder, playersOffset);
     return(GameTickPacket.EndGameTickPacket(builder));
 }
Beispiel #3
0
 public static GameTickPacket GetRootAsGameTickPacket(ByteBuffer _bb, GameTickPacket obj)
 {
     return(obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb));
 }