diff options
author | Paul Gilbert | 2016-08-21 17:21:43 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-21 17:21:43 -0400 |
commit | 6d8e7e0feb25a1d964c3d676e796375f3c709c01 (patch) | |
tree | 9d0a6def5b5daf19435be25de4a262afe412b66c /engines/titanic/game | |
parent | 06008ae5caf0e086b0952c73bd5047e9c78cd921 (diff) | |
download | scummvm-rg350-6d8e7e0feb25a1d964c3d676e796375f3c709c01.tar.gz scummvm-rg350-6d8e7e0feb25a1d964c3d676e796375f3c709c01.tar.bz2 scummvm-rg350-6d8e7e0feb25a1d964c3d676e796375f3c709c01.zip |
TITANIC: Implemented CFanControl class
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/fan_control.cpp | 141 | ||||
-rw-r--r-- | engines/titanic/game/fan_control.h | 12 |
2 files changed, 144 insertions, 9 deletions
diff --git a/engines/titanic/game/fan_control.cpp b/engines/titanic/game/fan_control.cpp index a42e4dd5c1..56a1e49dec 100644 --- a/engines/titanic/game/fan_control.cpp +++ b/engines/titanic/game/fan_control.cpp @@ -24,14 +24,22 @@ namespace Titanic { -CFanControl::CFanControl() : CGameObject(), _fieldBC(0), - _fieldC0(0), _fieldC4(0), _fieldC8(0), _fieldCC(0) { +BEGIN_MESSAGE_MAP(CFanControl, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(TimerMsg) +END_MESSAGE_MAP() + +CFanControl::CFanControl() : CGameObject(), _state(-1), + _enabled(false), _fieldC4(0), _fieldC8(false), _fieldCC(0) { } void CFanControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_state, indent); + file->writeNumberLine(_enabled, indent); file->writeNumberLine(_fieldC4, indent); file->writeNumberLine(_fieldC8, indent); file->writeNumberLine(_fieldCC, indent); @@ -41,8 +49,8 @@ void CFanControl::save(SimpleFile *file, int indent) { void CFanControl::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); + _state = file->readNumber(); + _enabled = file->readNumber(); _fieldC4 = file->readNumber(); _fieldC8 = file->readNumber(); _fieldCC = file->readNumber(); @@ -50,4 +58,125 @@ void CFanControl::load(SimpleFile *file) { CGameObject::load(file); } +bool CFanControl::ActMsg(CActMsg *msg) { + if (msg->_action == "EnableObject") + _enabled = true; + else if (msg->_action == "DisableObject") + _enabled = false; + else if (msg->_action == "StarlingsDead") { + _fieldC4 = 0; + dec54(); + _fieldCC = 0; + } + + return true; +} + +bool CFanControl::StatusChangeMsg(CStatusChangeMsg *msg) { + if (!_fieldCC) { + playSound("z#42.wav"); + if (_enabled) { + switch (msg->_newStatus) { + case 1: + _fieldC8 = !_fieldC8; + if (_fieldC8) { + playMovie(6, 8, 0); + _state = 0; + } else { + switch (_state) { + case 0: + playMovie(4, 6, 0); + _state = -1; + break; + case 1: + playMovie(0, 6, 0); + break; + case 2: + playMovie(18, 24, 0); + playMovie(0, 6, 0); + break; + default: + break; + } + + _state = -1; + } + break; + + case 2: + if (_fieldC8) { + _state = (_state + 1) % 4; + switch (_state) { + case 0: + playMovie(18, 24, 0); + playMovie(0, 4, 0); + break; + case 1: + playMovie(8, 12, 0); + break; + case 2: + if (_fieldC4) { + inc54(); + _fieldCC = 1; + playMovie(12, 18, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } else { + playMovie(12, 18, 0); + } + break; + default: + break; + } + } + break; + + default: + break; + } + + CStatusChangeMsg statusMsg; + statusMsg._newStatus = _state; + statusMsg.execute("RightFan"); + } else { + petDisplayMessage(1, "Unfortunately this fan controller has blown a fuse."); + } + } + + return true; +} + +bool CFanControl::EnterViewMsg(CEnterViewMsg *msg) { + switch (_state) { + case 0: + loadFrame(6); + break; + case 1: + loadFrame(4); + break; + case 2: + loadFrame(0); + break; + case 3: + loadFrame(18); + break; + default: + break; + } + + return true; +} + +bool CFanControl::MovieEndMsg(CMovieEndMsg *msg) { + addTimer(2000); + return true; +} + +bool CFanControl::TimerMsg(CTimerMsg *msg) { + CStatusChangeMsg statusMsg; + statusMsg._newStatus = 1; + statusMsg.execute("StarlingPuret"); + changeView("PromenadeDeck.Node 3.S"); + changeView("PromenadeDeck.Node 3.E"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/fan_control.h b/engines/titanic/game/fan_control.h index 4d89adb311..1f7402db12 100644 --- a/engines/titanic/game/fan_control.h +++ b/engines/titanic/game/fan_control.h @@ -28,11 +28,17 @@ namespace Titanic { class CFanControl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool TimerMsg(CTimerMsg *msg); public: - int _fieldBC; - int _fieldC0; + int _state; + bool _enabled; int _fieldC4; - int _fieldC8; + bool _fieldC8; int _fieldCC; public: CLASSDEF; |