TITANIC: Implemented CHeadPiece and ear classes

This commit is contained in:
Paul Gilbert 2016-08-15 22:31:33 -04:00
parent 7234f076f4
commit 33e4afedde
10 changed files with 155 additions and 10 deletions

View File

@ -24,6 +24,13 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CBowlEar, CEar)
ON_MESSAGE(PETGainedObjectMsg)
ON_MESSAGE(ReplaceBowlAndNutsMsg)
ON_MESSAGE(NutPuzzleMsg)
ON_MESSAGE(MouseDragStartMsg)
END_MESSAGE_MAP()
void CBowlEar::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CEar::save(file, indent);
@ -34,4 +41,28 @@ void CBowlEar::load(SimpleFile *file) {
CEar::load(file);
}
bool CBowlEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
CBowlStateChangeMsg changeMsg(3);
changeMsg.execute("ParrotNutBowlActor");
return CEar::PETGainedObjectMsg(msg);
}
bool CBowlEar::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) {
setVisible(false);
return true;
}
bool CBowlEar::NutPuzzleMsg(CNutPuzzleMsg *msg) {
if (msg->_value == "BowlUnlocked")
_fieldE0 = 1;
return true;
}
bool CBowlEar::MouseDragStartMsg(CMouseDragStartMsg *msg) {
setVisible(true);
return CEar::MouseDragStartMsg(msg);
}
} // End of namespace Titanic

View File

@ -28,6 +28,11 @@
namespace Titanic {
class CBowlEar : public CEar {
DECLARE_MESSAGE_MAP;
bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg);
bool NutPuzzleMsg(CNutPuzzleMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
public:
CLASSDEF;

View File

@ -21,9 +21,15 @@
*/
#include "titanic/carry/ear.h"
#include "titanic/game/head_slot.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CEar, CHeadPiece)
ON_MESSAGE(ActMsg)
ON_MESSAGE(UseWithOtherMsg)
END_MESSAGE_MAP()
CEar::CEar() : CHeadPiece() {
}
@ -37,4 +43,25 @@ void CEar::load(SimpleFile *file) {
CHeadPiece::load(file);
}
bool CEar::ActMsg(CActMsg *msg) {
if (msg->_action == "MusicSolved")
_fieldE0 = true;
return true;
}
bool CEar::UseWithOtherMsg(CUseWithOtherMsg *msg) {
CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other);
if (slot) {
setVisible(false);
petMoveToHiddenRoom();
setPosition(Point(0, 0));
CAddHeadPieceMsg addMsg(getName());
if (addMsg._value != "NULL")
addMsg.execute(addMsg._value == "Ear1" ? "Ear1Slot" : "Ear2Slot");
}
return CCarry::UseWithOtherMsg(msg);
}
} // End of namespace Titanic

View File

@ -28,6 +28,9 @@
namespace Titanic {
class CEar : public CHeadPiece {
DECLARE_MESSAGE_MAP;
bool ActMsg(CActMsg *msg);
bool UseWithOtherMsg(CUseWithOtherMsg *msg);
public:
CLASSDEF;
CEar();

View File

@ -24,13 +24,19 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CHeadPiece, CCarry)
ON_MESSAGE(SenseWorkingMsg)
ON_MESSAGE(PETGainedObjectMsg)
ON_MESSAGE(MouseDragStartMsg)
END_MESSAGE_MAP()
CHeadPiece::CHeadPiece() : CCarry(), _string6("Not Working"),
_field12C(0), _field13C(0) {
_flag(0), _field13C(false) {
}
void CHeadPiece::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_field12C, indent);
file->writeNumberLine(_flag, indent);
file->writeQuotedLine(_string6, indent);
file->writeNumberLine(_field13C, indent);
@ -39,11 +45,49 @@ void CHeadPiece::save(SimpleFile *file, int indent) {
void CHeadPiece::load(SimpleFile *file) {
file->readNumber();
_field12C = file->readNumber();
_flag = file->readNumber();
_string6 = file->readString();
_field13C = file->readNumber();
CCarry::load(file);
}
bool CHeadPiece::SenseWorkingMsg(CSenseWorkingMsg *msg) {
_string6 = msg->_value;
return true;
}
bool CHeadPiece::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
_visibleFrame = 1;
if (!_field13C) {
stateInc38();
_field13C = true;
}
return true;
}
bool CHeadPiece::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (!checkPoint(msg->_mousePos, false, true)) {
return false;
} else if (!_fieldE0) {
return true;
}
if (_flag) {
setVisible(true);
moveToView();
setPosition(Point(msg->_mousePos.x - _bounds.width() / 2,
msg->_mousePos.y - _bounds.height() / 2));
CTakeHeadPieceMsg takeMsg(getName());
if (takeMsg._value != "NULL")
takeMsg.execute("TitaniaControl");
_flag = false;
}
return CCarry::MouseDragStartMsg(msg);
}
} // End of namespace Titanic

View File

@ -24,14 +24,19 @@
#define TITANIC_HEAD_PIECE_H
#include "titanic/carry/carry.h"
#include "titanic/messages/pet_messages.h"
namespace Titanic {
class CHeadPiece : public CCarry {
DECLARE_MESSAGE_MAP;
bool SenseWorkingMsg(CSenseWorkingMsg *msg);
bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
private:
int _field12C;
bool _flag;
CString _string6;
int _field13C;
bool _field13C;
public:
CLASSDEF;
CHeadPiece();

View File

@ -24,6 +24,12 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CPhonographEar, CEar)
ON_MESSAGE(CorrectMusicPlayedMsg)
ON_MESSAGE(PETGainedObjectMsg)
ON_MESSAGE(TimerMsg)
END_MESSAGE_MAP()
void CPhonographEar::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_field140, indent);
@ -36,4 +42,24 @@ void CPhonographEar::load(SimpleFile *file) {
CEar::load(file);
}
bool CPhonographEar::CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg) {
_fieldE0 = true;
return true;
}
bool CPhonographEar::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
if (_field140) {
_field140 = false;
addTimer(1000);
}
return PETGainedObjectMsg(msg);
}
bool CPhonographEar::TimerMsg(CTimerMsg *msg) {
CVisibleMsg visibleMsg;
visibleMsg.execute("Replacement Phonograph Ear");
return true;
}
} // End of namespace Titanic

View File

@ -28,11 +28,15 @@
namespace Titanic {
class CPhonographEar : public CEar {
DECLARE_MESSAGE_MAP;
bool CorrectMusicPlayedMsg(CCorrectMusicPlayedMsg *msg);
bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
bool TimerMsg(CTimerMsg *msg);
private:
int _field140;
bool _field140;
public:
CLASSDEF;
CPhonographEar() : CEar(), _field140(1) {}
CPhonographEar() : CEar(), _field140(true) {}
/**
* Save the data for the class to file

View File

@ -757,7 +757,7 @@ DEFFN(CAutoSoundEvent);
DEFFN(CBilgeAutoSoundEvent);
DEFFN(CBilgeDispensorEvent);
DEFFN(CBodyInBilgeRoomMsg);
DEFFN(CBowlStateChange);
DEFFN(CBowlStateChangeMsg);
DEFFN(CCarryObjectArrivedMsg);
DEFFN(CChangeMusicMsg);
DEFFN(CChangeSeasonMsg);
@ -1344,7 +1344,7 @@ void CSaveableObject::initClassList() {
ADDFN(CBilgeAutoSoundEvent, CAutoSoundEvent);
ADDFN(CBilgeDispensorEvent, CAutoSoundEvent);
ADDFN(CBodyInBilgeRoomMsg, CMessage);
ADDFN(CBowlStateChange, CMessage);
ADDFN(CBowlStateChangeMsg, CMessage);
ADDFN(CCarryObjectArrivedMsg, CMessage);
ADDFN(CChangeMusicMsg, CMessage);
ADDFN(CChangeSeasonMsg, CMessage);

View File

@ -206,7 +206,7 @@ MESSAGE1(CAnimateMaitreDMsg, int, value, 0);
MESSAGE1(CArboretumGateMsg, int, value, 0);
MESSAGE0(CArmPickedUpFromTableMsg);
MESSAGE0(CBodyInBilgeRoomMsg);
MESSAGE1(CBowlStateChange, int, value, 0);
MESSAGE1(CBowlStateChangeMsg, int, value, 0);
MESSAGE2(CCarryObjectArrivedMsg, CString, strValue, "", int, numValue, 0);
MESSAGE2(CChangeMusicMsg, CString, filename, "", int, flags, 0);
MESSAGE1(CChangeSeasonMsg, CString, season, "Summer");