diff options
author | Eugene Sandulenko | 2013-12-06 23:22:28 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2013-12-06 23:22:28 +0200 |
commit | 8844d461a959d8ffbbd7ec397c529cdd2fcee606 (patch) | |
tree | dbb0fdaef9eade28c01b4eeb4be4c1c8919a086d /engines | |
parent | 9fbc292404cbb5ec6d1ad37cd56dc9141dfe4048 (diff) | |
download | scummvm-rg350-8844d461a959d8ffbbd7ec397c529cdd2fcee606.tar.gz scummvm-rg350-8844d461a959d8ffbbd7ec397c529cdd2fcee606.tar.bz2 scummvm-rg350-8844d461a959d8ffbbd7ec397c529cdd2fcee606.zip |
FULLPIPE: implement MctlLadder::addObject()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/motion.cpp | 65 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 4 |
2 files changed, 68 insertions, 1 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 080c607159..5e399a2fe9 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -203,7 +203,70 @@ int MctlLadder::collisionDetection(StaticANIObject *man) { } void MctlLadder::addObject(StaticANIObject *obj) { - warning("STUB: MctlLadder::addObject()"); + if (findObjectPos(obj) < 0) { + MctlLadderMovement *movement = new MctlLadderMovement; + + if (initMovement(obj, movement)) { + _mgm.addItem(obj->_id); + _movements.push_back(movement); + } else { + delete movement; + } + } +} + +int MctlLadder::findObjectPos(StaticANIObject *obj) { + int res = -1; + + for (Common::List<MctlLadderMovement *>::iterator it = _movements.begin(); it != _movements.end(); ++it, ++res) + if ((*it)->objId == obj->_id) + break; + + return res; +} + +bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) { + GameVar *v = g_fullpipe->getGameLoaderGameVar()->getSubVarByName(ani->getName()); + + if (!v) + return false; + + v = v->getSubVarByName("Test_Ladder"); + + if (!v) + return false; + + movement->staticIdsSize = 6; + movement->movVars = new MctlLadderMovementVars; + movement->staticIds = new int[movement->staticIdsSize]; + + v = v->getSubVarByName("Up"); + + if (!v) + return false; + + movement->movVars->varUpStart = v->getSubVarAsInt("Start"); + movement->movVars->varUpGo = v->getSubVarAsInt("Go"); + movement->movVars->varUpStop = v->getSubVarAsInt("Stop"); + + movement->staticIds[0] = ani->getMovementById(movement->movVars->varUpStart)->_staticsObj1->_staticsId; + movement->staticIds[2] = ani->getMovementById(movement->movVars->varUpGo)->_staticsObj1->_staticsId; + + v = v->getSubVarByName("Down"); + + if (!v) + return false; + + movement->movVars->varDownStart = v->getSubVarAsInt("Start"); + movement->movVars->varDownGo = v->getSubVarAsInt("Go"); + movement->movVars->varDownStop = v->getSubVarAsInt("Stop"); + + movement->staticIds[1] = ani->getMovementById(movement->movVars->varDownStart)->_staticsObj1->_staticsId; + movement->staticIds[3] = ani->getMovementById(movement->movVars->varDownGo)->_staticsObj1->_staticsId; + + movement->objId = ani->_id; + + return true; } void MctlLadder::freeItems() { diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 43ec367545..92240506b4 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -198,6 +198,10 @@ public: virtual void freeItems(); virtual MessageQueue *method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + +private: + int findObjectPos(StaticANIObject *obj); + bool initMovement(StaticANIObject *ani, MctlLadderMovement *movement); }; class MovGraphNode : public CObject { |