public override void SimulateController() { // If player is "dead" ignore inputs if (state.Health <= 0) { return; } var cmd = MoveAndShootMoveCommand.Create(); cmd.Direction = _input.Dir; cmd.Yaw = _input.Angle; entity.QueueInput(cmd); if (_input.Fired.HasValue) { var fireCommandInput = MoveAndShootFireCommand.Create(); fireCommandInput.Type = _input.Fired.Value; entity.QueueInput(fireCommandInput); // reset fire input _input.Fired = null; } }
private void HandleMoveCommand(MoveAndShootMoveCommand cmd, bool reset) { if (reset) { SetState(cmd.Result.Position, cmd.Result.Velocity, cmd.Result.Yaw); } else { Vector3 resultPosition; Vector3 resultVelocity; float resultYaw; Move(cmd.Input.Direction, cmd.Input.Yaw, out resultPosition, out resultVelocity, out resultYaw); cmd.Result.Position = resultPosition; cmd.Result.Velocity = resultVelocity; cmd.Result.Yaw = resultYaw; } }