1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-31 16:51:50 +02:00

fix switch state management

This commit is contained in:
XProger
2018-06-30 23:57:54 +03:00
parent 35be42b587
commit 73d4915493
3 changed files with 9 additions and 4 deletions

View File

@@ -513,7 +513,7 @@ struct Controller {
}
virtual bool activate() {
if (flags.state != TR::Entity::asNone)
if (flags.state == TR::Entity::asActive)
return false;
flags.invisible = false;
flags.state = TR::Entity::asActive;

View File

@@ -1813,7 +1813,7 @@ struct Lara : Character {
case TR::Level::Trigger::SWITCH : {
Switch *controller = (Switch*)level->entities[info.trigCmd[cmdIndex++].args].controller;
if (controller->flags.state == TR::Entity::asNone) {
if (controller->flags.state != TR::Entity::asActive) {
limit = state == STATE_STOP ? &TR::Limits::SWITCH : &TR::Limits::SWITCH_UNDERWATER;
if (checkInteraction(controller, limit, Input::state[camera->cameraIndex][cAction])) {
actionState = (controller->state == Switch::STATE_DOWN && stand == STAND_GROUND) ? STATE_SWITCH_UP : STATE_SWITCH_DOWN;

View File

@@ -18,14 +18,19 @@ struct Switch : Controller {
if (flags.state == TR::Entity::asInactive) {
if (state == STATE_DOWN && t > 0.0f) {
timer = t;
flags.state = TR::Entity::asActive;
Controller::activate();
} else
deactivate(true);
Controller::deactivate(true);
return true;
}
return false;
}
virtual void deactivate(bool removeFromList) {
Controller::deactivate(true);
flags.state = TR::Entity::asInactive;
}
virtual bool activate() {
if (Controller::activate()) {
animation.setState(state == STATE_UP ? STATE_DOWN : STATE_UP);