Exemplo n.º 1
0
        private static VectorOffset CreateCarStateVector(FlatBufferBuilder builder, Dictionary <int, CarState> carStates)
        {
            if (carStates.Count == 0)
            {
                return(DesiredGameState.CreateCarStatesVector(builder, new Offset <DesiredCarState> [0]));
            }

            int numCars = carStates.Keys.Max() + 1;

            Offset <DesiredCarState>[] carStateOffsets = new Offset <DesiredCarState> [numCars];

            for (int i = 0; i < numCars; i++)
            {
                if (carStates.ContainsKey(i) && carStates[i] != null)
                {
                    carStateOffsets[i] = carStates[i].ToFlatBuffer(builder);
                }
                else
                {
                    carStateOffsets[i] = new CarState().ToFlatBuffer(builder);
                }
            }

            return(DesiredGameState.CreateCarStatesVector(builder, carStateOffsets));
        }
Exemplo n.º 2
0
 public void SetCarState(int index, CarState carState)
 {
     if (carStates.ContainsKey(index))
     {
         carStates[index] = carState;
     }
     else
     {
         carStates.Add(index, carState);
     }
 }