mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
132 lines
4.1 KiB
C++
132 lines
4.1 KiB
C++
/* ScummVM - Graphic Adventure Engine
|
|
*
|
|
* ScummVM is the legal property of its developers, whose names
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
* file distributed with this source distribution.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
*/
|
|
|
|
#include "common/hash-str.h"
|
|
|
|
#include "pink/archive.h"
|
|
#include "pink/pink.h"
|
|
#include "pink/objects/side_effect.h"
|
|
#include "pink/objects/actors/lead_actor.h"
|
|
#include "pink/objects/pages/game_page.h"
|
|
#include "pink/objects/walk/walk_location.h"
|
|
#include "pink/objects/walk/walk_mgr.h"
|
|
|
|
namespace Pink {
|
|
|
|
void SideEffectExit::deserialize(Archive &archive) {
|
|
_nextModule = archive.readString();
|
|
_nextPage = archive.readString();
|
|
}
|
|
|
|
void SideEffectExit::execute(Actor *actor) {
|
|
actor->getPage()->getLeadActor()->setNextExecutors(_nextModule, _nextPage);
|
|
}
|
|
|
|
void SideEffectExit::toConsole() {
|
|
debug("\t\tSideEffectExit: _nextModule=%s, _nextPage=%s", _nextModule.c_str(), _nextPage.c_str());
|
|
}
|
|
|
|
void SideEffectLocation::deserialize(Archive &archive) {
|
|
_location = archive.readString();
|
|
}
|
|
|
|
void SideEffectLocation::execute(Actor *actor) {
|
|
WalkMgr *mgr = actor->getPage()->getWalkMgr();
|
|
WalkLocation *location = mgr->findLocation(_location);
|
|
if (location)
|
|
mgr->setCurrentWayPoint(location);
|
|
}
|
|
|
|
void SideEffectLocation::toConsole() {
|
|
debug("\t\tSideEffectLocation: _location=%s", _location.c_str());
|
|
}
|
|
|
|
void SideEffectInventoryItemOwner::deserialize(Archive &archive) {
|
|
_item = archive.readString();
|
|
_owner = archive.readString();
|
|
}
|
|
|
|
void SideEffectInventoryItemOwner::execute(Actor *actor) {
|
|
InventoryMgr *mgr = actor->getPage()->getModule()->getInventoryMgr();
|
|
InventoryItem *item = mgr->findInventoryItem(_item);
|
|
mgr->setItemOwner(_owner, item);
|
|
}
|
|
|
|
void SideEffectInventoryItemOwner::toConsole() {
|
|
debug("\t\tSideEffectInventoryItemOwner: _item=%s, _owner=%s", _item.c_str(), _owner.c_str());
|
|
}
|
|
|
|
void SideEffectVariable::deserialize(Pink::Archive &archive) {
|
|
_name = archive.readString();
|
|
_value = archive.readString();
|
|
}
|
|
|
|
void SideEffectGameVariable::execute(Actor *actor) {
|
|
actor->getPage()->getGame()->setVariable(_name, _value);
|
|
}
|
|
|
|
void SideEffectGameVariable::toConsole() {
|
|
debug("\t\tSideEffectGameVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str());
|
|
}
|
|
|
|
void SideEffectModuleVariable::execute(Actor *actor) {
|
|
actor->getPage()->getModule()->setVariable(_name, _value);
|
|
}
|
|
|
|
void SideEffectModuleVariable::toConsole() {
|
|
debug("\t\tSideEffectModuleVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str());
|
|
}
|
|
|
|
void SideEffectPageVariable::execute(Actor *actor) {
|
|
actor->getPage()->setVariable(_name, _value);
|
|
}
|
|
|
|
void SideEffectPageVariable::toConsole() {
|
|
debug("\t\tSideEffectPageVariable: _name=%s, _value=%s", _name.c_str(), _value.c_str());
|
|
}
|
|
|
|
void SideEffectRandomPageVariable::deserialize(Archive &archive) {
|
|
_name = archive.readString();
|
|
_values.deserialize(archive);
|
|
}
|
|
|
|
void SideEffectRandomPageVariable::execute(Actor *actor) {
|
|
assert(!_values.empty());
|
|
|
|
Common::RandomSource &rnd = actor->getPage()->getGame()->getRnd();
|
|
uint index = rnd.getRandomNumber(_values.size() - 1);
|
|
|
|
actor->getPage()->setVariable(_name, _values[index]);
|
|
}
|
|
|
|
void SideEffectRandomPageVariable::toConsole() {
|
|
Common::String values("{");
|
|
for (uint i = 0; i < _values.size(); ++i) {
|
|
values += _values[i];
|
|
values += ',';
|
|
}
|
|
values += '}';
|
|
debug("\t\tSideEffectRandomPageVariable: _name=%s, _values=%s", _name.c_str(), values.c_str());
|
|
}
|
|
|
|
} // End of namespace Pink
|