private string ProcessSingleRequest(RequestItem request)
        {
            // Skip prefix "{\"Cmd\":\"AGENTCOMMAND\",\"Arg\":{\"Cmd\":\""
            var commandName = request.Message.Substring(36, 10);

            Log?.WriteLine($"{nameof(Dispatcher)} command prefix: '{commandName}'.");

            if (commandName.StartsWith("OBSERVE") || commandName.StartsWith("DONOTHING"))              // DONOTHING is obsolete.
            {
                // Just observe.
            }
            else if (commandName.StartsWith("TELEPORT"))  // Teleport
            {
                var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveCommandArgs> > >(request.Message);

                m_controller.Teleport(requestShell.Arg.Arg.MoveIndicator);
            }
            else if (commandName.StartsWith("MOVE_ROTAT"))              // MOVE_ROTATE
            {
                var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveAndRotateArgs> > >(request.Message);

                m_controller.Move(requestShell.Arg.Arg);
            }
            else if (commandName.StartsWith("MOVETOWARD"))              // TODO(PP): Remove.
            {
                var requestShell    = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveCommandArgs> > >(request.Message);
                var moveCommandArgs = requestShell.Arg.Arg;

                Log?.WriteLine($"Move indicator: {moveCommandArgs.MoveIndicator}");
                m_controller.Move(moveCommandArgs.MoveIndicator, Vector2.Zero, 0.0f);
            }
            else if (commandName.StartsWith("INTERACT"))
            {
                var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <InteractionArgs> > >(request.Message);

                m_controller.Interact(requestShell.Arg.Arg);
            }
            else
            {
                throw new NotImplementedException($"Uknown agent command: {commandName}");
            }

            return(m_jsoner.ToJson(m_observer.GetObservation()));
        }
Exemple #2
0
 public void Move(Vector3 dist, float deltaTime = 0)
 {
     _currentState.Move(dist, deltaTime);
 }
Exemple #3
0
        public void HandleCharacterControllerInput(GameTime gametime, ICharacterController controller)
        {
            float timescale = (float)gametime.ElapsedGameTime.TotalSeconds;
            float rotatescale = 1.5f;

            // Avoid moving with keyboard and mouse when the editor is open.
            if (controller.PlayerNumber == 0 && SunBurnEditorClient.Instance.EditorOpen)
                return;

            // Apply player input.
            controller.Move(new Vector2(_InputSources.MoveAmount.X, 0.0f));
            controller.Move(new Vector2(0.0f, _InputSources.MoveAmount.Y));
            controller.Turn(-_InputSources.TurnAmount * rotatescale);

            if (_InputSources.Jump)
                controller.Jump();

            controller.Crouch = _InputSources.Crouch;

            // Apply up / down view.
            _CharacterLookUpDownAngle += _InputSources.LookUpDownAmount * rotatescale * timescale;

            // Clamp the look up / down range.
            _CharacterLookUpDownAngle = MathHelper.Clamp(_CharacterLookUpDownAngle, -1.0f, 1.0f);
        }
Exemple #4
0
 public override void Execute(ICharacterController controller)
 {
     controller.Move(horizontalVal, verticalVal);
 }