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:
@@ -513,7 +513,7 @@ struct Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual bool activate() {
|
virtual bool activate() {
|
||||||
if (flags.state != TR::Entity::asNone)
|
if (flags.state == TR::Entity::asActive)
|
||||||
return false;
|
return false;
|
||||||
flags.invisible = false;
|
flags.invisible = false;
|
||||||
flags.state = TR::Entity::asActive;
|
flags.state = TR::Entity::asActive;
|
||||||
|
@@ -1813,7 +1813,7 @@ struct Lara : Character {
|
|||||||
case TR::Level::Trigger::SWITCH : {
|
case TR::Level::Trigger::SWITCH : {
|
||||||
Switch *controller = (Switch*)level->entities[info.trigCmd[cmdIndex++].args].controller;
|
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;
|
limit = state == STATE_STOP ? &TR::Limits::SWITCH : &TR::Limits::SWITCH_UNDERWATER;
|
||||||
if (checkInteraction(controller, limit, Input::state[camera->cameraIndex][cAction])) {
|
if (checkInteraction(controller, limit, Input::state[camera->cameraIndex][cAction])) {
|
||||||
actionState = (controller->state == Switch::STATE_DOWN && stand == STAND_GROUND) ? STATE_SWITCH_UP : STATE_SWITCH_DOWN;
|
actionState = (controller->state == Switch::STATE_DOWN && stand == STAND_GROUND) ? STATE_SWITCH_UP : STATE_SWITCH_DOWN;
|
||||||
|
@@ -18,13 +18,18 @@ struct Switch : Controller {
|
|||||||
if (flags.state == TR::Entity::asInactive) {
|
if (flags.state == TR::Entity::asInactive) {
|
||||||
if (state == STATE_DOWN && t > 0.0f) {
|
if (state == STATE_DOWN && t > 0.0f) {
|
||||||
timer = t;
|
timer = t;
|
||||||
flags.state = TR::Entity::asActive;
|
Controller::activate();
|
||||||
} else
|
} else
|
||||||
deactivate(true);
|
Controller::deactivate(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void deactivate(bool removeFromList) {
|
||||||
|
Controller::deactivate(true);
|
||||||
|
flags.state = TR::Entity::asInactive;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool activate() {
|
virtual bool activate() {
|
||||||
if (Controller::activate()) {
|
if (Controller::activate()) {
|
||||||
|
Reference in New Issue
Block a user