diff options
author | Eugene Sandulenko | 2018-03-23 23:35:49 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-24 02:45:26 +0100 |
commit | 967de5d4aa400608cd586bb585d9e0904f44cd20 (patch) | |
tree | 696207c88e229581a28aec8d4bd81bec8a23b69c /engines | |
parent | 540567d1d8a8446d42c5340c357f5f38c70c05cc (diff) | |
download | scummvm-rg350-967de5d4aa400608cd586bb585d9e0904f44cd20.tar.gz scummvm-rg350-967de5d4aa400608cd586bb585d9e0904f44cd20.tar.bz2 scummvm-rg350-967de5d4aa400608cd586bb585d9e0904f44cd20.zip |
BLADERUNNER: Implement PoliceMazeTargetTrack::readdObject()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/bladerunner/item.h | 4 | ||||
-rw-r--r-- | engines/bladerunner/items.cpp | 24 | ||||
-rw-r--r-- | engines/bladerunner/items.h | 4 | ||||
-rw-r--r-- | engines/bladerunner/police_maze.cpp | 20 | ||||
-rw-r--r-- | engines/bladerunner/police_maze.h | 6 |
5 files changed, 55 insertions, 3 deletions
diff --git a/engines/bladerunner/item.h b/engines/bladerunner/item.h index 6842df12ba..fcb2f2230e 100644 --- a/engines/bladerunner/item.h +++ b/engines/bladerunner/item.h @@ -65,9 +65,13 @@ public: void setXYZ(Vector3 position); void getWidthHeight(int *width, int *height) const; + BoundingBox *getBoundingBox() { return &_boundingBox; } + Common::Rect *getScreenRectangle() { return &_screenRectangle; } + void setIsTarget(bool isTarget) { _isTarget = isTarget; } bool isTarget() const; + bool isVisible() const { return _isVisible; } bool isPoliceMazeEnemy() const; void spinInWorld(); bool tick(Common::Rect *screenRect, bool special); diff --git a/engines/bladerunner/items.cpp b/engines/bladerunner/items.cpp index 81164e31a0..7de1300bff 100644 --- a/engines/bladerunner/items.cpp +++ b/engines/bladerunner/items.cpp @@ -135,6 +135,14 @@ bool Items::isTarget(int itemId) const { return _items[itemIndex]->isTarget(); } +bool Items::isVisible(int itemId) const { + int itemIndex = findItem(itemId); + if (itemIndex == -1) { + return false; + } + return _items[itemIndex]->isVisible(); +} + bool Items::isPoliceMazeEnemy(int itemId) const { int itemIndex = findItem(itemId); if (itemIndex == -1) { @@ -143,6 +151,22 @@ bool Items::isPoliceMazeEnemy(int itemId) const { return _items[itemIndex]->isTarget(); } +BoundingBox *Items::getBoundingBox(int itemId) { + int itemIndex = findItem(itemId); + if (itemIndex == -1) { + return nullptr; + } + return _items[itemIndex]->getBoundingBox(); +} + +Common::Rect *Items::getScreenRectangle(int itemId) { + int itemIndex = findItem(itemId); + if (itemIndex == -1) { + return nullptr; + } + return _items[itemIndex]->getScreenRectangle(); +} + void Items::spinInWorld(int itemId) { int itemIndex = findItem(itemId); if (itemIndex == -1) { diff --git a/engines/bladerunner/items.h b/engines/bladerunner/items.h index 1c68eb66a5..1c6f488323 100644 --- a/engines/bladerunner/items.h +++ b/engines/bladerunner/items.h @@ -50,8 +50,12 @@ public: void setIsTarget(int itemId, bool isTarget); bool isTarget(int itemId) const; bool isPoliceMazeEnemy(int itemId) const; + bool isVisible(int itemId) const; int findTargetUnderMouse(int mouseX, int mouseY) const; + BoundingBox *getBoundingBox(int itemId); + Common::Rect *getScreenRectangle(int itemId); + void spinInWorld(int itemId); private: diff --git a/engines/bladerunner/police_maze.cpp b/engines/bladerunner/police_maze.cpp index 11eeb869fe..395804d626 100644 --- a/engines/bladerunner/police_maze.cpp +++ b/engines/bladerunner/police_maze.cpp @@ -22,8 +22,10 @@ #include "bladerunner/bladerunner.h" #include "bladerunner/game_constants.h" +#include "bladerunner/items.h" #include "bladerunner/police_maze.h" #include "bladerunner/scene.h" +#include "bladerunner/scene_objects.h" #include "bladerunner/script/scene_script.h" namespace BladeRunner { @@ -34,7 +36,7 @@ PoliceMaze::PoliceMaze(BladeRunnerEngine *vm) { reset(); for (int i = 0; i < kNumMazeTracks; i++) { - _tracks[i] = new PoliceMazeTargetTrack; + _tracks[i] = new PoliceMazeTargetTrack(vm); } } @@ -116,7 +118,9 @@ void PoliceMaze::tick() { } } -PoliceMazeTargetTrack::PoliceMazeTargetTrack() { +PoliceMazeTargetTrack::PoliceMazeTargetTrack(BladeRunnerEngine *vm) { + _vm = vm; + reset(); } @@ -154,4 +158,16 @@ void PoliceMazeTargetTrack::add(int trackId, float startX, float startY, float s void PoliceMazeTargetTrack::tick() { } +void PoliceMazeTargetTrack::readdObject(int itemId) { + if (_vm->_sceneObjects->remove(itemId + kSceneObjectOffsetItems)) { + BoundingBox *boundingBox = _vm->_items->getBoundingBox(itemId); + Common::Rect *screenRect = _vm->_items->getScreenRectangle(itemId); + bool targetable = _vm->_items->isTarget(itemId); + bool obstacle = _vm->_items->isVisible(itemId); + + _vm->_sceneObjects->addItem(itemId + kSceneObjectOffsetItems, boundingBox, screenRect, targetable, obstacle); + } +} + + } // End of namespace BladeRunner diff --git a/engines/bladerunner/police_maze.h b/engines/bladerunner/police_maze.h index ce1a40fb0b..adf857c479 100644 --- a/engines/bladerunner/police_maze.h +++ b/engines/bladerunner/police_maze.h @@ -35,6 +35,8 @@ enum { class BladeRunnerEngine; class PoliceMazeTargetTrack { + BladeRunnerEngine *_vm; + uint32 _time; bool _isPresent; int _itemId; @@ -54,7 +56,7 @@ class PoliceMazeTargetTrack { bool _visible; public: - PoliceMazeTargetTrack(); + PoliceMazeTargetTrack(BladeRunnerEngine *vm); ~PoliceMazeTargetTrack(); void reset(); @@ -67,6 +69,8 @@ public: void resetVisible() { _visible = false; } bool isVisible() { return _visible; } void setTime(uint32 t) { _time = t; } + + void readdObject(int itemId); }; class PoliceMaze { |