bool CPetControl::checkNode(const CString &name) { CGameManager *gameManager = getGameManager(); if (!gameManager) return true; if (name == "NULL") return false; CViewItem *view = gameManager->getView(); if (!view) return true; CNodeItem *node = view->findNode(); if (!node) return true; CString viewName = view->getName(); CString nodeName = node->getName(); CRoomItem *room = getGameManager()->getRoom(); if (room) { CString roomName = room->getName(); CString newNode; if (roomName == "1stClassRestaurant") { } else if (nodeName == "Lobby Node") { nodeName = "Node 1"; } else if (nodeName == "Entrance Node") { nodeName = "Node 2"; } else if (nodeName == "MaitreD Node") { nodeName = "Node 3"; } else if (nodeName == "Scraliontis Table Standing Node") { nodeName = "Node 4"; } else if (nodeName == "Pellerator Node") { nodeName = "Node 5"; } else if (nodeName == "SUB Node") { nodeName = "Node 6"; } else if (nodeName == "Phonograph Node") { nodeName = "Node 7"; } else if (nodeName == "Scraliontis Table Seated Node") { nodeName = "Node 8"; } if (roomName == "MusicRoom") { if (nodeName == "Musical Instruments") nodeName = "Node 1"; if (nodeName == "Phonograph Node") nodeName = "Node 2"; } } CString str = CString::format("%s.%s", nodeName.c_str(), viewName.c_str()); str = str.right(5); str.toLowercase(); CString nameLower = name; nameLower.toLowercase(); return nameLower.contains(str); }
/** * Adds an Object to the area. * @param object The Object's pointer. * @see removeObject() */ void Area::addObject(Object* object) { //object->setArea(this); DEBUG_M("Entering function..."); GameManager* gm = getGameManager(); if(object->getGameManager() != gm) { DEBUG_A("Different GameMangers..."); object->setGameManager(gm); if(gm) { DEBUG_A("Registering object with gamemanager..."); gm->registerObject(object); } } RigidBody* rb = dynamic_cast<RigidBody*>(object); if(rb) { rb->addBody(getPhysics()); } Light* pl = dynamic_cast<Light*>(object); if(pl) { lights_.push_back(pl); } addChild(object); }
void GameManager::destroyGameManager() { GameManager *gameManager = &getGameManager(); delete gameManager; GLFWwindow *window = glfwGetCurrentContext(); glfwDestroyWindow(window); glfwTerminate(); }
void GameManager::destroyGameManager() { GameManager *game = &getGameManager(); if(game !=NULL) { delete game; } }
void CProjectItem::postLoad() { CGameManager *gameManager = getGameManager(); if (gameManager) gameManager->postLoad(this); CPetControl *petControl = getPetControl(); if (petControl) petControl->postLoad(); }
void GameManager::destroyGameManager() { GameManager *gameManager = &getGameManager(); delete gameManager; std::cout << "GameManager destroyed" << std::endl; GLFWwindow *window = glfwGetCurrentContext(); glfwDestroyWindow(window); glfwTerminate(); }
void CPetControl::summonBot(const CString &name, int val) { CGameManager *gameManager = getGameManager(); if (gameManager) { CRoomItem *room = gameManager->getRoom(); if (room) { CSummonBotMsg summonMsg(name, val); summonMsg.execute(room); } } }
/** * Remove an Object from the area. * @param object The Object's pointer. * @see addObject() */ void Area::removeObject(Object* object) { removeChild(object); RigidBody* rb = dynamic_cast<RigidBody*>(object); if(rb) { rb->removeBody(getPhysics()); } GameManager* gm = getGameManager(); if(gm) { gm->deregisterObject(object); } #warning ['TODO']: Remove lights... }
void CProjectItem::loadGame(int slotId) { CompressedFile file; // Clear any existing project contents and call preload code preLoad(); clear(); // Open either an existing savegame slot or the new game template if (slotId >= 0) { Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( g_vm->generateSaveName(slotId)); file.open(saveFile); } else { Common::File *newFile = new Common::File(); if (!newFile->open("newgame.st")) error("Could not open newgame.st"); file.open(newFile); } // Load the savegame header in TitanicSavegameHeader header; readSavegameHeader(&file, header); delete header._thumbnail; // Load the contents in CProjectItem *newProject = loadData(&file); file.IsClassStart(); getGameManager()->load(&file); file.close(); // Clear existing project clear(); // Detach each item under the loaded project, and re-attach them // to the existing project instance (this) CTreeItem *item; while ((item = newProject->getFirstChild()) != nullptr) { item->detach(); item->addUnder(this); } // Loaded project instance is no longer needed newProject->destroyAll(); // Post-load processing postLoad(); }
int CPetControl::canSummonBot(const CString &name) { // If player is the very same view as the NPC, then it's already present if (isBotInView(name)) return SUMMON_CAN; // Get the room CGameManager *gameManager = getGameManager(); if (!gameManager) return SUMMON_CANT; CRoomItem *room = gameManager->getRoom(); if (!room) return SUMMON_CANT; // Query current room to see whether the bot can be summoned to it CSummonBotQueryMsg queryMsg(name); return queryMsg.execute(room) ? SUMMON_CAN : SUMMON_CANT; }
void CPetControl::draw(CScreenManager *screenManager) { CGameManager *gameManager = getGameManager(); Rect bounds = _drawBounds; bounds.constrain(gameManager->_bounds); if (!bounds.isEmpty()) { if (_areaChangeType >= 0) { _inventory.changed(_areaChangeType); _areaChangeType = -1; } _frame.drawFrame(screenManager); // Draw the specific area that's currently active _sections[_currentArea]->draw(screenManager); } }
bool CAutoMusicPlayerBase::LoadSuccessMsg(CLoadSuccessMsg *msg) { if (_isEnabled) { // WORKAROUND: A problem was encountered with the EmbLobby music player // not getting turned off when room was left, so was turned on again // when loading a savegame elsewhere. This guards against it CRoomItem *newRoom = getGameManager()->getRoom(); if (findRoom() != newRoom) { _isEnabled = false; return true; } playAmbientSound(_filename, _volumeMode, _initialMute, true, 0, Audio::Mixer::kMusicSoundType); } return true; }
bool CPetControl::isDoorOrBellbotPresent() const { CGameManager *gameManager = getGameManager(); if (!gameManager) return false; CViewItem *view = gameManager->getView(); if (!view) return false; for (CTreeItem *treeItem = view->getFirstChild(); treeItem; treeItem = treeItem->scan(view)) { CString name = treeItem->getName(); if (dynamic_cast<CGameObject *>(treeItem) && (name.contains("Doorbot") || name.contains("BellBot"))) return true; } return false; }
bool CPetControl::isBotInView(const CString &name) const { CGameManager *gameManager = getGameManager(); if (!gameManager) return false; CViewItem *view = gameManager->getView(); if (!view) return false; // Iterate to find NPC for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) { CGameObject *gameObject = dynamic_cast<CGameObject *>(child); if (gameObject) { if (!gameObject->getName().compareToIgnoreCase(name)) return true; } } return false; }
bool CPetControl::dismissBot(const CString &name) { CGameManager *gameManager = getGameManager(); if (!gameManager) return false; CViewItem *view = gameManager->getView(); if (!view) return false; bool result = false; CDismissBotMsg dismissMsg; for (CTreeItem *treeItem = view->getFirstChild(); treeItem; treeItem = treeItem->scan(view)) { if (!treeItem->getName().compareToIgnoreCase(name)) dismissMsg.execute(treeItem); else result = true; } return result; }
void SpaceShip::shootLaser(void) { if (_charlesBronsonStyle > 0 && _invulTime == 0 && getGameManager()->createLaserShot(getPosition(), getRotation(), getVelocity(), getRotation(true))) { _charlesBronsonStyle--; } }
void CTrueTalkNPC::stopAnimTimer(int id) { getGameManager()->stopTimer(id); }
void CPetControl::removeFromInventory(CGameObject *item, bool refreshUI, bool sendMsg) { CViewItem *view = getGameManager()->getView(); removeFromInventory(item, view, refreshUI, sendMsg); }
void CPetControl::enterNode(CNodeItem *node) { getGameManager()->_gameState.enterNode(); }
void CTrueTalkNPC::startTalker(CViewItem *view) { CGameManager *gameManager = getGameManager(); if (gameManager) gameManager->getTalkManager()->start4(this, view); }
void CTrueTalkNPC::setView(CViewItem *view) { CTrueTalkManager *talkManager = getGameManager()->getTalkManager(); if (talkManager) talkManager->start3(this, view); }
void CPetControl::setTimerPersisent(int id, bool flag) { getGameManager()->setTimerPersisent(id, flag); }
void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) { CTrueTalkManager *talkManager = getGameManager()->getTalkManager(); if (talkManager) talkManager->processInput(this, msg, view); }