TITANIC: Fleshing out of CTrueTalkManager class

This commit is contained in:
Paul Gilbert 2016-05-30 10:18:50 -04:00
parent 9f6a3d36f7
commit 07c1b2b23d
6 changed files with 91 additions and 8 deletions

View File

@ -121,6 +121,7 @@ public:
Common::RandomSource _randomSource;
CScriptHandler *_scriptHandler;
TTscriptBase *_script;
CTrueTalkManager *_trueTalkManager;
CExeResources _exeResources;
CMovieList _activeMovies;
StringArray _itemNames;

View File

@ -32,7 +32,7 @@ namespace Titanic {
int CTrueTalkManager::_v1;
int CTrueTalkManager::_v2;
int CTrueTalkManager::_v3;
int CTrueTalkManager::_passengerClass;
bool CTrueTalkManager::_v4;
bool CTrueTalkManager::_v5;
int CTrueTalkManager::_v6;
@ -50,10 +50,12 @@ CTrueTalkManager::CTrueTalkManager(CGameManager *owner) :
_dialogueFile(nullptr), _dialogueId(0) {
_titleEngine.setup(3, 3);
_currentNPC = nullptr;
g_vm->_trueTalkManager = this;
}
CTrueTalkManager::~CTrueTalkManager() {
clear();
g_vm->_trueTalkManager = nullptr;
}
void CTrueTalkManager::save(SimpleFile *file) const {
@ -100,7 +102,7 @@ void CTrueTalkManager::loadStatics(SimpleFile *file) {
int count = file->readNumber();
_v1 = file->readNumber();
_v2 = file->readNumber();
_v3 = file->readNumber();
_passengerClass = file->readNumber();
_v4 = file->readNumber() != 0;
_v5 = file->readNumber() != 0;
_v6 = file->readNumber();
@ -124,7 +126,7 @@ void CTrueTalkManager::saveStatics(SimpleFile *file) {
file->writeNumber(10);
file->writeNumber(_v1);
file->writeNumber(_v2);
file->writeNumber(_v3);
file->writeNumber(_passengerClass);
file->writeNumber(_v4 ? 1 : 0);
file->writeNumber(_v5 ? 1 : 0);
file->writeNumber(_v6);
@ -148,7 +150,7 @@ void CTrueTalkManager::setFlags(int index, int val) {
switch (index) {
case 1:
if (val >= 1 && val <= 3)
_v3 = val;
_passengerClass = val;
break;
case 2:
@ -233,6 +235,14 @@ void CTrueTalkManager::start(CTrueTalkNPC *npc, uint id, CViewItem *view) {
setDialogue(npc, roomScript, view);
}
void CTrueTalkManager::start3(CTrueTalkNPC *npc, CViewItem *view) {
start(npc, 3, view);
}
void CTrueTalkManager::start4(CTrueTalkNPC *npc, CViewItem *view) {
start(npc, 4, view);
}
TTnpcScript *CTrueTalkManager::getTalker(const CString &name) const {
if (name.contains("Doorbot"))
return _scripts.getNpcScript(104);
@ -285,6 +295,18 @@ TTroomScript *CTrueTalkManager::getRoomScript() const {
return script;
}
TTroomScript *CTrueTalkManager::getRoomScript(int roomId) const {
TTroomScript *script = nullptr;
if (roomId)
script = _scripts.getRoomScript(roomId);
if (!script)
// Fall back on the default Room script
script = _scripts.getRoomScript(110);
return script;
}
void CTrueTalkManager::loadAssets(CTrueTalkNPC *npc, int charId) {
// If assets for the character are already loaded, simply exit
if (_currentCharId == charId)
@ -526,7 +548,7 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV
}
}
int CTrueTalkManager::getStateVal(int stateNum) {
int CTrueTalkManager::getStateValue(int stateNum) {
if (!_currentNPC)
return -1000;
@ -549,4 +571,22 @@ bool CTrueTalkManager::proximityMethod1(int val) {
return false;
}
CGameManager *CTrueTalkManager::getGameManager() const {
return _gameManager;
}
CGameState *CTrueTalkManager::getGameState() const {
return _gameManager ? &_gameManager->_gameState : nullptr;
}
int CTrueTalkManager::getPassengerClass() const {
CGameState *gameState = getGameState();
return gameState ? gameState->_passengerClass : 4;
}
int CTrueTalkManager::getState14() const {
CGameState *gameState = getGameState();
return gameState ? gameState->_field14 : 0;
}
} // End of namespace Titanic

View File

@ -33,6 +33,7 @@
namespace Titanic {
class CGameManager;
class CGameState;
class CTreeItem;
class CViewItem;
class CTrueTalkManager;
@ -107,10 +108,27 @@ private:
void playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot);
static bool proximityMethod1(int val);
/**
* Return the game manager
*/
CGameManager *getGameManager() const;
/**
* Return the game state
*/
CGameState *getGameState() const;
/**
* Get the player's passenger class
*/
int getPassengerClass() const;
int getState14() const;
public:
static int _v1;
static int _v2;
static int _v3;
static int _passengerClass;
static bool _v4;
static bool _v5;
static int _v6;
@ -126,7 +144,7 @@ public:
/**
* Get a specified state value from the currently set NPC
*/
static int getStateVal(int stateNum);
static int getStateValue(int stateNum);
/**
* Trigger an NPC action
@ -188,6 +206,16 @@ public:
*/
void start(CTrueTalkNPC *npc, uint id, CViewItem *view);
/**
* Start a TrueTalk conversation
*/
void start3(CTrueTalkNPC *npc, CViewItem *view);
/**
* Start a TrueTalk conversation
*/
void start4(CTrueTalkNPC *npc, CViewItem *view);
/**
* Return a TrueTalk talker/script
*/
@ -197,6 +225,11 @@ public:
* Process player's input
*/
void processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CViewItem *view);
/**
* Gets the script associated with a specific room
*/
TTroomScript *getRoomScript(int roomId) const;
};
} // End of namespace Titanic

View File

@ -23,6 +23,7 @@
#include "common/textconsole.h"
#include "titanic/true_talk/tt_npc_script.h"
#include "titanic/true_talk/true_talk_manager.h"
#include "titanic/titanic.h"
namespace Titanic {
@ -229,4 +230,10 @@ void TTnpcScript::preLoad() {
}
}
int TTnpcScript::getRoom54(int roomId) {
TTroomScript *room = g_vm->_trueTalkManager->getRoomScript(roomId);
return room ? room->_field54 : 0;
}
} // End of namespace Titanic

View File

@ -75,6 +75,8 @@ protected:
void resetFlags();
void randomizeFlags();
static int getRoom54(int roomId);
public:
TTnpcScript(int charId, const char *charClass, int v2,
const char *charName, int v3, int val2, int v4,

View File

@ -52,7 +52,7 @@ public:
class TTroomScript : public TTroomScriptBase {
private:
public:
int _field54;
public:
TTroomScript(int scriptId);