aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/carry/brain.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-14 22:31:33 -0400
committerPaul Gilbert2016-07-10 16:11:09 -0400
commit2dcda26eb1253d884d6a921a3f2ead76021b9bc4 (patch)
tree304f4bf8bf69b3325cc7e06a099a9a6de884448d /engines/titanic/carry/brain.cpp
parent7ddd5d1a8b97bda75e4eece9c91ff3286e3c3eca (diff)
downloadscummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.tar.gz
scummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.tar.bz2
scummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.zip
TITANIC: Implement CBridgePiece message handlers
Diffstat (limited to 'engines/titanic/carry/brain.cpp')
-rw-r--r--engines/titanic/carry/brain.cpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp
index 0d1cdf7518..acc29b3f0e 100644
--- a/engines/titanic/carry/brain.cpp
+++ b/engines/titanic/carry/brain.cpp
@@ -21,9 +21,18 @@
*/
#include "titanic/carry/brain.h"
+#include "titanic/game/brain_slot.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CBrain, CCarry)
+ ON_MESSAGE(UseWithOtherMsg)
+ ON_MESSAGE(VisibleMsg)
+ ON_MESSAGE(MouseDragStartMsg)
+ ON_MESSAGE(PassOnDragStartMsg)
+ ON_MESSAGE(PETGainedObjectMsg)
+END_MESSAGE_MAP()
+
CBrain::CBrain() : CCarry(), _field134(0), _field138(0) {
}
@@ -45,4 +54,81 @@ void CBrain::load(SimpleFile *file) {
CCarry::load(file);
}
+bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ CBrainSlot *slot = static_cast<CBrainSlot *>(msg->_other);
+ if (slot) {
+ if (slot->getName() == "CentralCore") {
+ setVisible(false);
+ moveToHiddenRoom();
+ CAddHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("CentralCoreSlot");
+ }
+ else if (!slot->_value1 && slot->getName() == "CentralCoreSlot") {
+ setVisible(false);
+ moveToHiddenRoom();
+ CAddHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute(msg->_other);
+ playSound("z#116.wav", 100, 0, 0);
+ setPosition(Point(0, 0));
+ setVisible(false);
+ _field134 = 1;
+ }
+
+ return true;
+ }
+ else {
+ return CCarry::UseWithOtherMsg(msg);
+ }
+}
+
+bool CBrain::VisibleMsg(CVisibleMsg *msg) {
+ setVisible(msg->_visible);
+ return true;
+}
+
+bool CBrain::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ if (!checkStartDragging(msg))
+ return false;
+
+ if (_field134) {
+ CTakeHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("TitaniaControl");
+
+ _field134 = 0;
+ setVisible(true);
+ moveToView();
+
+ setPosition(Point(msg->_mousePos.x - _bounds.width() / 2,
+ msg->_mousePos.y - _bounds.height() / 2));
+ }
+
+ return CCarry::MouseDragStartMsg(msg);
+}
+
+bool CBrain::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
+ if (_field134) {
+ CTakeHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("TitaniaControl");
+ _field134 = 0;
+
+ setVisible(true);
+ moveToView();
+ setPosition(Point(msg->_mousePos.x - _bounds.width() / 2,
+ msg->_mousePos.y - _bounds.height() / 2));
+ }
+
+ return CCarry::PassOnDragStartMsg(msg);
+}
+
+bool CBrain::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
+ if (!_field138) {
+ if (getName() == "Perch") {
+ incState38();
+ _field138 = 1;
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Titanic