mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
SHERLOCK: RT: Implement walkToCoords
This commit is contained in:
parent
a96aad5559
commit
8abce6b025
@ -152,39 +152,6 @@ void Person::goAllTheWay() {
|
||||
}
|
||||
}
|
||||
|
||||
void Person::walkToCoords(const Point32 &destPos, int destDir) {
|
||||
Events &events = *_vm->_events;
|
||||
People &people = *_vm->_people;
|
||||
Scene &scene = *_vm->_scene;
|
||||
Talk &talk = *_vm->_talk;
|
||||
|
||||
CursorId oldCursor = events.getCursor();
|
||||
events.setCursor(WAIT);
|
||||
|
||||
_walkDest = Common::Point(destPos.x / FIXED_INT_MULTIPLIER + 10, destPos.y / FIXED_INT_MULTIPLIER);
|
||||
people._allowWalkAbort = true;
|
||||
goAllTheWay();
|
||||
|
||||
// Keep calling doBgAnim until the walk is done
|
||||
do {
|
||||
events.pollEventsAndWait();
|
||||
scene.doBgAnim();
|
||||
} while (!_vm->shouldQuit() && _walkCount);
|
||||
|
||||
if (!talk._talkToAbort) {
|
||||
// Put character exactly on destination position, and set direction
|
||||
_position = destPos;
|
||||
_sequenceNumber = destDir;
|
||||
gotoStand();
|
||||
|
||||
// Draw Holmes facing the new direction
|
||||
scene.doBgAnim();
|
||||
|
||||
if (!talk._talkToAbort)
|
||||
events.setCursor(oldCursor);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------*/
|
||||
|
||||
People *People::init(SherlockEngine *vm) {
|
||||
|
@ -85,7 +85,7 @@ public:
|
||||
/**
|
||||
* Walk to the co-ordinates passed, and then face the given direction
|
||||
*/
|
||||
void walkToCoords(const Point32 &destPos, int destDir);
|
||||
virtual void walkToCoords(const Point32 &destPos, int destDir) = 0;
|
||||
};
|
||||
|
||||
class SherlockEngine;
|
||||
|
@ -333,6 +333,39 @@ void ScalpelPerson::setWalking() {
|
||||
_frameNumber = oldFrame;
|
||||
}
|
||||
|
||||
void ScalpelPerson::walkToCoords(const Point32 &destPos, int destDir) {
|
||||
Events &events = *_vm->_events;
|
||||
People &people = *_vm->_people;
|
||||
Scene &scene = *_vm->_scene;
|
||||
Talk &talk = *_vm->_talk;
|
||||
|
||||
CursorId oldCursor = events.getCursor();
|
||||
events.setCursor(WAIT);
|
||||
|
||||
_walkDest = Common::Point(destPos.x / FIXED_INT_MULTIPLIER + 10, destPos.y / FIXED_INT_MULTIPLIER);
|
||||
people._allowWalkAbort = true;
|
||||
goAllTheWay();
|
||||
|
||||
// Keep calling doBgAnim until the walk is done
|
||||
do {
|
||||
events.pollEventsAndWait();
|
||||
scene.doBgAnim();
|
||||
} while (!_vm->shouldQuit() && _walkCount);
|
||||
|
||||
if (!talk._talkToAbort) {
|
||||
// Put character exactly on destination position, and set direction
|
||||
_position = destPos;
|
||||
_sequenceNumber = destDir;
|
||||
gotoStand();
|
||||
|
||||
// Draw Holmes facing the new direction
|
||||
scene.doBgAnim();
|
||||
|
||||
if (!talk._talkToAbort)
|
||||
events.setCursor(oldCursor);
|
||||
}
|
||||
}
|
||||
|
||||
Common::Point ScalpelPerson::getSourcePoint() const {
|
||||
return Common::Point(_position.x / FIXED_INT_MULTIPLIER + frameWidth() / 2,
|
||||
_position.y / FIXED_INT_MULTIPLIER);
|
||||
|
@ -66,6 +66,12 @@ public:
|
||||
* in a straight line
|
||||
*/
|
||||
virtual void setWalking();
|
||||
|
||||
/**
|
||||
* Walk to the co-ordinates passed, and then face the given direction
|
||||
*/
|
||||
virtual void walkToCoords(const Point32 &destPos, int destDir);
|
||||
|
||||
};
|
||||
|
||||
class ScalpelPeople : public People {
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "sherlock/tattoo/tattoo_people.h"
|
||||
#include "sherlock/tattoo/tattoo_scene.h"
|
||||
#include "sherlock/tattoo/tattoo_talk.h"
|
||||
#include "sherlock/sherlock.h"
|
||||
#include "sherlock/tattoo/tattoo.h"
|
||||
|
||||
namespace Sherlock {
|
||||
|
||||
@ -99,7 +99,7 @@ TattooPerson::TattooPerson() : Person() {
|
||||
_resetNPCPath = true;
|
||||
_savedNpcSequence = 0;
|
||||
_savedNpcFrame = 0;
|
||||
_updateNPCPath = false;
|
||||
_updateNPCPath = true;
|
||||
_npcPause = false;
|
||||
}
|
||||
|
||||
@ -475,6 +475,101 @@ void TattooPerson::setWalking() {
|
||||
_frameNumber = oldFrame;
|
||||
}
|
||||
|
||||
void TattooPerson::walkToCoords(const Point32 &destPos, int destDir) {
|
||||
TattooEngine &vm = *(TattooEngine *)_vm;
|
||||
Events &events = *_vm->_events;
|
||||
TattooPeople &people = *(TattooPeople *)_vm->_people;
|
||||
TattooScene &scene = *(TattooScene *)_vm->_scene;
|
||||
Talk &talk = *_vm->_talk;
|
||||
|
||||
CursorId oldCursor = events.getCursor();
|
||||
events.setCursor(WAIT);
|
||||
|
||||
_walkDest = Common::Point(_position.x / FIXED_INT_MULTIPLIER, _position.y / FIXED_INT_MULTIPLIER);
|
||||
|
||||
bool isHolmes = this == &people[HOLMES];
|
||||
if (isHolmes) {
|
||||
people._allowWalkAbort = true;
|
||||
} else {
|
||||
// Clear the path Variables
|
||||
_npcIndex = _npcPause;
|
||||
Common::fill(_npcPath, _npcPath + 100, 0);
|
||||
_npcFacing = destDir;
|
||||
}
|
||||
|
||||
_centerWalk = false;
|
||||
|
||||
// Only move the person if they're going an appreciable distance
|
||||
if (ABS(_walkDest.x - (_position.x / FIXED_INT_MULTIPLIER)) > 8 ||
|
||||
ABS(_walkDest.y - (_position.y / FIXED_INT_MULTIPLIER)) > 4) {
|
||||
goAllTheWay();
|
||||
|
||||
do {
|
||||
// Keep doing animations whilst walk is in progress
|
||||
events.wait(1);
|
||||
scene.doBgAnim();
|
||||
|
||||
if (events.kbHit()) {
|
||||
Common::KeyState keyState = events.getKey();
|
||||
|
||||
if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
|
||||
vm.setFlags(-76);
|
||||
vm.setFlags(396);
|
||||
scene._goToScene = 1;
|
||||
talk._talkToAbort = true;
|
||||
}
|
||||
}
|
||||
} while (!_vm->shouldQuit() && _walkCount && !talk._talkToAbort);
|
||||
}
|
||||
|
||||
_centerWalk = true;
|
||||
if (!isHolmes)
|
||||
_updateNPCPath = true;
|
||||
|
||||
if (!talk._talkToAbort) {
|
||||
// put character exactly on right spot
|
||||
_position = destPos;
|
||||
|
||||
if (_sequenceNumber != destDir) {
|
||||
// Facing character to correct ending direction
|
||||
_sequenceNumber = destDir;
|
||||
gotoStand();
|
||||
}
|
||||
|
||||
if (!isHolmes)
|
||||
_updateNPCPath = false;
|
||||
|
||||
// Secondary walking wait loop
|
||||
do {
|
||||
events.wait(1);
|
||||
scene.doBgAnim();
|
||||
|
||||
// See if we're past the initial goto stand sequence
|
||||
for (int idx = 0; idx < _frameNumber; ++idx) {
|
||||
if (_walkSequences[_sequenceNumber][idx] == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (events.kbHit()) {
|
||||
Common::KeyState keyState = events.getKey();
|
||||
|
||||
if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
|
||||
vm.setFlags(-76);
|
||||
vm.setFlags(396);
|
||||
scene._goToScene = 1;
|
||||
talk._talkToAbort = true;
|
||||
}
|
||||
}
|
||||
} while (!_vm->shouldQuit());
|
||||
|
||||
if (!isHolmes)
|
||||
_updateNPCPath = true;
|
||||
|
||||
if (!talk._talkToAbort)
|
||||
events.setCursor(oldCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void TattooPerson::clearNPC() {
|
||||
Common::fill(&_npcPath[0], &_npcPath[MAX_NPC_PATH], 0);
|
||||
_npcIndex = _npcStack = 0;
|
||||
|
@ -141,6 +141,11 @@ public:
|
||||
*/
|
||||
virtual void setWalking();
|
||||
|
||||
/**
|
||||
* Walk to the co-ordinates passed, and then face the given direction
|
||||
*/
|
||||
virtual void walkToCoords(const Point32 &destPos, int destDir);
|
||||
|
||||
/**
|
||||
* Adjusts the frame and sequence variables of a sprite that corresponds to the current speaker
|
||||
* so that it points to the beginning of the sequence number's talk sequence in the object's
|
||||
|
Loading…
x
Reference in New Issue
Block a user