public override void SimulateController() { IPlayerCommandFPSInput input = PlayerCommandFPS.Create(); input.Forward = m_forward; input.Backward = m_backward; input.Left = m_left; input.Right = m_right; input.Jump = m_jump; input.Dash = m_dash; input.Fire = m_fire; input.Yaw = m_yaw; input.Pitch = m_pitch; entity.QueueInput(input); //apply camera rotation cameraController.UpdateRotation(m_pitch); if (m_tabDown) { GameUI.instance.ShowScoreboard(); } else if (m_tabUp) { GameUI.instance.HideScoreboard(); } //reset one shot inputs m_jump = false; m_dash = false; m_tabDown = false; m_tabUp = false; }
public override void ExecuteCommand(Bolt.Command command, bool resetState) { PlayerCommandFPS cmd = (PlayerCommandFPS)command; if (resetState) { //we got a correction from the server, reset (this only runs on the client) if (m_player.numRespawnTeleportFrames > 0) { m_playerMotor.SetStateTeleport(cmd.Result.Position, cmd.Result.Velocity, cmd.Result.IsGrounded, cmd.Result.IsDoubleJumpAvailable, cmd.Result.DashDurationCountdown, cmd.Result.DashCooldownCountdown); } else { m_playerMotor.SetState(cmd.Result.Position, cmd.Result.Velocity, cmd.Result.IsGrounded, cmd.Result.IsDoubleJumpAvailable, cmd.Result.DashDurationCountdown, cmd.Result.DashCooldownCountdown); } } else { //apply movement (this runs on both server and client) PlayerMotor.MotorState motorState = m_playerMotor.Move(BoltNetwork.FrameDeltaTime, cmd.Input.Forward, cmd.Input.Backward, cmd.Input.Left, cmd.Input.Right, cmd.Input.Jump, cmd.Input.Dash, cmd.Input.Yaw); //copy the motor state to the commands result (this gets sent back to the client) cmd.Result.Position = motorState.position; cmd.Result.Velocity = motorState.velocity; cmd.Result.IsGrounded = motorState.isGrounded; cmd.Result.IsDoubleJumpAvailable = motorState.isDoubleJumpAvailable; cmd.Result.DashDurationCountdown = motorState.dashDurationCountdown; cmd.Result.DashCooldownCountdown = motorState.dashCooldownCountdown; if (cmd.IsFirstExecution) { //check if we're the one controlling this entity if (entity.HasControl) { if (cmd.Input.Fire) { activeWeapon.FireWeapon(entity); } } } } }