ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

global.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/services/global.h"
00024 
00025 #include "engines/stark/resources/item.h"
00026 #include "engines/stark/resources/level.h"
00027 #include "engines/stark/resources/knowledge.h"
00028 #include "engines/stark/resources/knowledgeset.h"
00029 
00030 namespace Stark {
00031 
00032 Global::Global() :
00033         _millisecondsPerGameloop(10),
00034         _april(nullptr),
00035         _root(nullptr),
00036         _level(nullptr),
00037         _current(nullptr),
00038         _fastForward(false),
00039         _inventory(nullptr) {
00040 }
00041 
00042 int32 Global::getCurrentChapter() {
00043     Resources::KnowledgeSet *globalState = _level->findChildWithSubtype<Resources::KnowledgeSet>(Resources::KnowledgeSet::kState);
00044     Resources::Knowledge *chapter = globalState->findChildWithIndex<Resources::Knowledge>(0);
00045     return chapter->getIntegerValue();
00046 }
00047 
00048 void Global::setCurrentChapter(int32 value) {
00049     Resources::KnowledgeSet *globalState = _level->findChildWithSubtype<Resources::KnowledgeSet>(Resources::KnowledgeSet::kState);
00050     Resources::Knowledge *chapter = globalState->findChildWithIndex<Resources::Knowledge>(0);
00051     chapter->setIntegerValue(value);
00052 }
00053 
00054 Common::String Global::getCharacterName(int32 id) {
00055     Resources::KnowledgeSet *characters = _level->findChildWithSubtype<Resources::KnowledgeSet>(Resources::KnowledgeSet::kPersons);
00056     Resources::Knowledge *character = characters->findChildWithIndex<Resources::Knowledge>(id);
00057     return character->getName();
00058 }
00059 
00060 bool Global::hasInventoryItem(const Common::String &itemName) const {
00061     Common::Array<Resources::Item*> inventoryItems = _inventory->listChildren<Resources::Item>(Resources::Item::kItemInventory);
00062 
00063     for (uint i = 0; i < inventoryItems.size(); i++) {
00064         if (inventoryItems[i]->getName() == itemName && inventoryItems[i]->isEnabled()) {
00065             return true;
00066         }
00067     }
00068 
00069     return false;
00070 }
00071 
00072 } // End of namespace Stark


Generated on Sat Feb 16 2019 05:00:51 for ResidualVM by doxygen 1.7.1
curved edge   curved edge