Skip to content

Commit

Permalink
BLADERUNNER: Finished PoliceMaze implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Mar 24, 2018
1 parent c3d6dcf commit f153da7
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
4 changes: 4 additions & 0 deletions engines/bladerunner/item.h
Expand Up @@ -67,12 +67,16 @@ class Item {

BoundingBox *getBoundingBox() { return &_boundingBox; }
Common::Rect *getScreenRectangle() { return &_screenRectangle; }
int getFacing() const { return _facing; }
void setFacing(int facing) { _facing = facing; }

void setIsTarget(bool isTarget) { _isTarget = isTarget; }

bool isTarget() const;
bool isVisible() const { return _isVisible; }
void setVisible(bool val) { _isVisible = val; }
bool isPoliceMazeEnemy() const;
void setPoliceMazeEnemy(bool val) { _isPoliceMazeEnemy = val; }
void spinInWorld();
bool tick(Common::Rect *screenRect, bool special);

Expand Down
40 changes: 40 additions & 0 deletions engines/bladerunner/items.cpp
Expand Up @@ -46,6 +46,13 @@ void Items::getXYZ(int itemId, float *x, float *y, float *z) const {
_items[itemIndex]->getXYZ(x, y, z);
}

void Items::setXYZ(int itemId, Vector3 position) {
int itemIndex = findItem(itemId);
assert(itemIndex != -1);

_items[itemIndex]->setXYZ(position);
}

void Items::getWidthHeight(int itemId, int *width, int *height) const {
int itemIndex = findItem(itemId);
assert(itemIndex != -1);
Expand Down Expand Up @@ -151,6 +158,23 @@ bool Items::isPoliceMazeEnemy(int itemId) const {
return _items[itemIndex]->isTarget();
}

void Items::setPoliceMazeEnemy(int itemId, bool val) {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
return;
}
_items[itemIndex]->setPoliceMazeEnemy(val);
}

void Items::setIsObstacle(int itemId, bool val) {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
return;
}
_items[itemIndex]->setVisible(val);
_vm->_sceneObjects->setIsClickable(itemId + kSceneObjectOffsetItems, val);
}

BoundingBox *Items::getBoundingBox(int itemId) {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
Expand All @@ -167,6 +191,22 @@ Common::Rect *Items::getScreenRectangle(int itemId) {
return _items[itemIndex]->getScreenRectangle();
}

int Items::getFacing(int itemId) const {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
return 0;
}
return _items[itemIndex]->getFacing();
}

void Items::setFacing(int itemId, int facing) {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
return;
}
_items[itemIndex]->setFacing(facing);
}

void Items::spinInWorld(int itemId) {
int itemIndex = findItem(itemId);
if (itemIndex == -1) {
Expand Down
5 changes: 5 additions & 0 deletions engines/bladerunner/items.h
Expand Up @@ -40,6 +40,7 @@ class Items {
~Items();

void getXYZ(int itemId, float *x, float *y, float *z) const;
void setXYZ(int itemId, Vector3 position);
void getWidthHeight(int itemId, int *width, int *height) const;

void tick();
Expand All @@ -50,11 +51,15 @@ class Items {
void setIsTarget(int itemId, bool isTarget);
bool isTarget(int itemId) const;
bool isPoliceMazeEnemy(int itemId) const;
void setPoliceMazeEnemy(int itemId, bool val);
void setIsObstacle(int itemId, bool val);
bool isVisible(int itemId) const;
int findTargetUnderMouse(int mouseX, int mouseY) const;

BoundingBox *getBoundingBox(int itemId);
Common::Rect *getScreenRectangle(int itemId);
int getFacing(int itemId) const;
void setFacing(int itemId, int facing);

void spinInWorld(int itemId);

Expand Down
11 changes: 4 additions & 7 deletions engines/bladerunner/script/police_maze.cpp
Expand Up @@ -182,8 +182,6 @@ bool PoliceMazeTargetTrack::tick() {
return false;
}

#if 0

uint32 oldTime = _time;
_time = _vm->getTotalPlayTime();
int32 timeDiff = _time - oldTime;
Expand Down Expand Up @@ -248,7 +246,7 @@ bool PoliceMazeTargetTrack::tick() {
}

if (advancePoint) {
_vm->_items->setXYZ(_itemId, _points[_pointIndex].x, _points[_pointIndex].y, _points[_pointIndex].z);
_vm->_items->setXYZ(_itemId, _points[_pointIndex]);
readdObject(_itemId);

return true;
Expand Down Expand Up @@ -284,7 +282,7 @@ bool PoliceMazeTargetTrack::tick() {
_dataIndex++;

if (_vm->_items->isTarget(_itemId)) {
Sound_Play(var1, 90, 0, 0, 50, 0);
Sound_Play(var1, 90, 0, 0, 50);
Police_Maze_Decrement_Score(1);
Actor_Force_Stop_Walking(0);

Expand Down Expand Up @@ -406,7 +404,7 @@ bool PoliceMazeTargetTrack::tick() {
case 16:
var1 = _data[_dataIndex++];
var2 = _data[_dataIndex++];
Sound_Play(var1, var2, 0, 0, 50, 0);
Sound_Play(var1, var2, 0, 0, 50);
break;

case 17:
Expand Down Expand Up @@ -464,7 +462,7 @@ bool PoliceMazeTargetTrack::tick() {
case 25:
_pointIndex = _data[_dataIndex++];
_pmt_var4 = 0;
_vm->_items->setXYZ(_itemId, _points[_pointIndex].x, _points[_pointIndex].y, _points[_pointIndex].z);
_vm->_items->setXYZ(_itemId, _points[_pointIndex]);
readdObject(_itemId);
break;

Expand All @@ -476,7 +474,6 @@ bool PoliceMazeTargetTrack::tick() {
cont = false;
}
}
#endif

return true;
}
Expand Down

0 comments on commit f153da7

Please sign in to comment.