1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-18 16:32:32 +02:00

zero all input when player input is disabled

This commit is contained in:
Daniel Evans 2016-11-16 20:23:05 +00:00
parent 57edc3648b
commit 40f18dabb0

View File

@ -187,18 +187,22 @@ void IngameState::tick(float dt) {
auto player = game->getPlayer();
// Force all input to 0 if player input is disabled
/// @todo verify 0ing input is the correct behaviour
const auto inputEnabled = player->isInputEnabled();
auto input = [&](GameInputState::Control c) {
return world->state->input[0][c];
return inputEnabled ? world->state->input[0][c] : 0.f;
};
auto pressed = [&](GameInputState::Control c) {
return world->state->input[0].pressed(c) &&
return inputEnabled && world->state->input[0].pressed(c) &&
!world->state->input[1].pressed(c);
};
auto held = [&](GameInputState::Control c) {
return world->state->input[0].pressed(c);
return inputEnabled && world->state->input[0].pressed(c);
};
if (player && player->isInputEnabled()) {
if (player) {
float viewDistance = 4.f;
switch (camMode) {
case IngameState::CAMERA_CLOSE:
@ -337,7 +341,6 @@ void IngameState::tick(float dt) {
/// @todo replace with correct sprint behaviour
float speed = held(GameInputState::Sprint) ? 2.f : 1.f;
if (player->isInputEnabled()) {
player->setRunning(!held(GameInputState::Walk));
/// @todo find the correct behaviour for entering & exiting
if (pressed(GameInputState::EnterExitVehicle)) {
@ -376,9 +379,6 @@ void IngameState::tick(float dt) {
}
player->setLookDirection({movementAngle, 0.f});
}
} else {
player->setMoveDirection(glm::vec3(0.f));
}
float len2d = glm::length(glm::vec2(lookdir));
float anglePitch = glm::atan(lookdir.z, len2d);