STARK: Store a reference to the current Camera and Floor

This commit is contained in:
Bastien Bouclet 2015-01-04 15:03:09 +01:00
parent 73d58c644e
commit e75ef310d4
10 changed files with 40 additions and 7 deletions

View File

@ -23,9 +23,12 @@
#include "engines/stark/resourceprovider.h"
#include "engines/stark/archiveloader.h"
#include "engines/stark/resources/root.h"
#include "engines/stark/resources/camera.h"
#include "engines/stark/resources/floor.h"
#include "engines/stark/resources/layer.h"
#include "engines/stark/resources/level.h"
#include "engines/stark/resources/location.h"
#include "engines/stark/resources/root.h"
#include "engines/stark/stateprovider.h"
namespace Stark {
@ -136,6 +139,15 @@ void ResourceProvider::requestLocationChange(uint16 level, uint16 location) {
newlyLoaded = _archiveLoader->load(locationArchive);
currentLocation->setLocation(_archiveLoader->useRoot<Location>(locationArchive));
if (currentLocation->getLocation()->has3DLayer()) {
Layer3D *layer = currentLocation->getLocation()->findChildWithSubtype<Layer3D>(Layer::kLayer3D);
currentLocation->setFloor(layer->findChild<Floor>());
currentLocation->setCamera(layer->findChild<Camera>());
} else {
currentLocation->setFloor(nullptr);
currentLocation->setCamera(nullptr);
}
// If we just loaded a resource tree, restore its state
if (newlyLoaded) {
_stateProvider->restoreLocationState(currentLocation->getLevel(), currentLocation->getLocation());

View File

@ -27,10 +27,12 @@
namespace Stark {
class Resource;
class Root;
class Camera;
class Floor;
class Level;
class Location;
class Resource;
class Root;
class ArchiveLoader;
class StateProvider;
@ -42,19 +44,27 @@ class Current {
public:
Current() :
_level(nullptr),
_location(nullptr) {
_location(nullptr),
_floor(nullptr),
_camera(nullptr) {
}
Level *getLevel() const { return _level; }
Location *getLocation() const { return _location; }
Floor *getFloor() const { return _floor; }
Camera *getCamera() const { return _camera; }
void setLevel(Level *level) { _level = level; }
void setLocation(Location *location) { _location = location; }
void setFloor(Floor *floor) { _floor = floor; }
void setCamera(Camera *camera) { _camera = camera; }
private:
Level *_level;
Location *_location;
/* Item *_interactive; */
Floor *_floor;
Camera *_camera;
};
/**

View File

@ -32,7 +32,7 @@ Command::~Command() {
Command::Command(Resource *parent, byte subType, uint16 index, const Common::String &name) :
Resource(parent, subType, index, name) {
_type = ResourceType::kCommand;
_type = TYPE;
}
void Command::readData(XRCReadStream *stream) {

View File

@ -36,6 +36,8 @@ class ResourceReference;
class Command : public Resource {
public:
static const ResourceType::Type TYPE = ResourceType::kCommand;
Command(Resource *parent, byte subType, uint16 index, const Common::String &name);
virtual ~Command();

View File

@ -29,7 +29,7 @@ namespace Stark {
Floor::Floor(Resource *parent, byte subType, uint16 index, const Common::String &name) :
Resource(parent, subType, index, name),
_facesCount(0) {
_type = ResourceType::kFloor;
_type = TYPE;
}
Floor::~Floor() {

View File

@ -36,6 +36,8 @@ class XRCReadStream;
class Floor : public Resource {
public:
static const ResourceType::Type TYPE = ResourceType::kFloor;
Floor(Resource *parent, byte subType, uint16 index, const Common::String &name);
virtual ~Floor();

View File

@ -30,7 +30,7 @@ FloorFace::FloorFace(Resource *parent, byte subType, uint16 index, const Common:
Resource(parent, subType, index, name),
_unk1(0),
_unk2(0) {
_type = ResourceType::kFloorFace;
_type = TYPE;
for (uint i = 0; i < ARRAYSIZE(_indices); i++) {
_indices[i] = 0;

View File

@ -36,6 +36,8 @@ class XRCReadStream;
class FloorFace : public Resource {
public:
static const ResourceType::Type TYPE = ResourceType::kFloorFace;
FloorFace(Resource *parent, byte subType, uint16 index, const Common::String &name);
virtual ~FloorFace();

View File

@ -41,6 +41,10 @@ void Location::onAllLoaded() {
_layers = listChildren<Layer>();
}
bool Location::has3DLayer() {
return findChildWithSubtype<Layer>(Layer::kLayer3D) != nullptr;
}
RenderEntryArray Location::listRenderEntries() {
RenderEntryArray renderEntries;

View File

@ -43,6 +43,7 @@ public:
// Resource API
void onAllLoaded() override;
bool has3DLayer();
RenderEntryArray listRenderEntries();
protected: