Esempio n. 1
0
        /// <summary>
        /// Sets the bot's controller inputs.
        /// </summary>
        /// <param name="controller">The controller to set the inputs to.</param>
        /// <param name="index">The index of the bot's car.</param>
        public static void SetBotInput(Controller controller, int index)
        {
            FlatBufferBuilder builder = new FlatBufferBuilder(50);

            Offset <ControllerState> controllerStateOffset = ControllerState.CreateControllerState(
                builder,
                controller.Throttle,
                controller.Steer,
                controller.Pitch,
                controller.Yaw,
                controller.Roll,
                controller.Jump,
                controller.Boost,
                controller.Handbrake,
                controller.UseItem);

            Offset <PlayerInput> playerInputOffset = PlayerInput.CreatePlayerInput(
                builder,
                index,
                controllerStateOffset);

            builder.Finish(playerInputOffset.Value);
            byte[] bufferBytes = builder.SizedByteArray();
            int    status      = UpdatePlayerInputFlatbuffer(bufferBytes, bufferBytes.Length);

            if (status > 0)
            {
                throw NewRLBotCoreException((RLBotCoreStatus)status);
            }
        }