mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-10 04:43:26 +00:00
STARK: Implement two 3D placement opcodes
This commit is contained in:
parent
7797f58e1f
commit
aff3cac029
@ -46,7 +46,7 @@ void ResourceReference::addPathElement(ResourceType type, uint16 index) {
|
||||
_path.push_back(PathElement(type, index));
|
||||
}
|
||||
|
||||
Resource *ResourceReference::resolve() {
|
||||
Resource *ResourceReference::resolve() const {
|
||||
ResourceProvider *resourceProvider = StarkServices::instance().resourceProvider;
|
||||
Global *global = StarkServices::instance().global;
|
||||
|
||||
|
@ -47,10 +47,10 @@ public:
|
||||
|
||||
/** Resolve the reference to the actual resource */
|
||||
template <class T>
|
||||
T* resolve();
|
||||
T* resolve() const;
|
||||
|
||||
private:
|
||||
Resource *resolve();
|
||||
Resource *resolve() const;
|
||||
|
||||
class PathElement {
|
||||
public:
|
||||
@ -69,7 +69,7 @@ private:
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T* ResourceReference::resolve() {
|
||||
T* ResourceReference::resolve() const {
|
||||
return Resource::cast<T>(resolve());
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,10 @@ Bookmark::Bookmark(Resource *parent, byte subType, uint16 index, const Common::S
|
||||
_type = TYPE;
|
||||
}
|
||||
|
||||
Math::Vector3d Bookmark::getPosition() const {
|
||||
return _position;
|
||||
}
|
||||
|
||||
void Bookmark::readData(XRCReadStream *stream) {
|
||||
_position = stream->readVector3();
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
// Resource API
|
||||
void readData(XRCReadStream *stream) override;
|
||||
|
||||
Math::Vector3d getPosition() const;
|
||||
|
||||
protected:
|
||||
void printData() override;
|
||||
|
||||
|
@ -21,7 +21,10 @@
|
||||
*/
|
||||
|
||||
#include "engines/stark/resources/command.h"
|
||||
|
||||
#include "engines/stark/debug.h"
|
||||
#include "engines/stark/resources/bookmark.h"
|
||||
#include "engines/stark/resources/item.h"
|
||||
#include "engines/stark/resourcereference.h"
|
||||
#include "engines/stark/xrcreader.h"
|
||||
|
||||
@ -36,7 +39,58 @@ Command::Command(Resource *parent, byte subType, uint16 index, const Common::Str
|
||||
}
|
||||
|
||||
Command *Command::execute(uint32 callMode, Script *script) {
|
||||
return nullptr;
|
||||
switch (_subType) {
|
||||
case k3DPlaceOn:
|
||||
op3DPlaceOn(_arguments[1].referenceValue, _arguments[2].referenceValue);
|
||||
return nextCommand();
|
||||
case kPlaceDirection:
|
||||
opPlaceDirection(_arguments[1].referenceValue, _arguments[2].intValue);
|
||||
return nextCommand();
|
||||
default:
|
||||
// warning("Unimplemented opcode %d", _subType);
|
||||
break;
|
||||
}
|
||||
|
||||
return nextCommand();
|
||||
}
|
||||
|
||||
void Command::op3DPlaceOn(const ResourceReference &itemRef, const ResourceReference &targetRef) {
|
||||
ItemSub5610 *item = itemRef.resolve<ItemSub5610>();
|
||||
Resource *target = targetRef.resolve<Resource>();
|
||||
|
||||
switch (target->getType().get()) {
|
||||
case ResourceType::kBookmark:
|
||||
item->placeOnBookmark(Resource::cast<Bookmark>(target));
|
||||
break;
|
||||
default:
|
||||
warning("Unimplemented op3DPlaceOn target type %s", target->getType().getName());
|
||||
}
|
||||
}
|
||||
|
||||
void Command::opPlaceDirection(const ResourceReference &itemRef, int32 direction) {
|
||||
ItemSub5610 *item = itemRef.resolve<ItemSub5610>();
|
||||
|
||||
item->setDirection(abs(direction) % 360);
|
||||
}
|
||||
|
||||
Command *Command::nextCommand() {
|
||||
assert(!_arguments.empty());
|
||||
|
||||
return resolveArgumentSiblingReference(_arguments[0]);
|
||||
}
|
||||
|
||||
Command *Command::nextCommandIf(bool predicate) {
|
||||
assert(!_arguments.size() >= 2);
|
||||
|
||||
if (predicate) {
|
||||
return resolveArgumentSiblingReference(_arguments[1]);
|
||||
} else {
|
||||
return resolveArgumentSiblingReference(_arguments[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Command *Command::resolveArgumentSiblingReference(const Argument &argument) {
|
||||
return _parent->findChildWithIndex<Command>(argument.intValue);
|
||||
}
|
||||
|
||||
void Command::readData(XRCReadStream *stream) {
|
||||
|
@ -44,7 +44,11 @@ public:
|
||||
|
||||
enum SubType {
|
||||
kCommandBegin = 0,
|
||||
kCommandEnd = 1
|
||||
kCommandEnd = 1,
|
||||
|
||||
k3DPlaceOn = 81,
|
||||
|
||||
kPlaceDirection = 133
|
||||
};
|
||||
|
||||
struct Argument {
|
||||
@ -61,12 +65,25 @@ public:
|
||||
ResourceReference referenceValue;
|
||||
};
|
||||
|
||||
/** Execute the command */
|
||||
Command *execute(uint32 callMode, Script *script);
|
||||
|
||||
/** Obtain the next command to be executed */
|
||||
Command *nextCommand();
|
||||
|
||||
/** Obtain the next command to be executed, depending on a predicate */
|
||||
Command *nextCommandIf(bool predicate);
|
||||
|
||||
protected:
|
||||
void readData(XRCReadStream *stream) override;
|
||||
void printData() override;
|
||||
|
||||
Command *resolveArgumentSiblingReference(const Argument &argument);
|
||||
|
||||
|
||||
void op3DPlaceOn(const ResourceReference &itemRef, const ResourceReference &targetRef);
|
||||
void opPlaceDirection(const ResourceReference &itemRef, int32 direction);
|
||||
|
||||
Common::Array<Argument> _arguments;
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "engines/stark/resources/anim.h"
|
||||
#include "engines/stark/resources/animhierarchy.h"
|
||||
#include "engines/stark/resources/bonesmesh.h"
|
||||
#include "engines/stark/resources/bookmark.h"
|
||||
#include "engines/stark/resources/textureset.h"
|
||||
#include "engines/stark/xrcreader.h"
|
||||
|
||||
@ -167,6 +168,15 @@ ItemSub5610::ItemSub5610(Resource *parent, byte subType, uint16 index, const Com
|
||||
_field_6C(-1) {
|
||||
}
|
||||
|
||||
void ItemSub5610::placeOnBookmark(Bookmark *target) {
|
||||
// TODO: valorize the z coordinate using the floor height at that position
|
||||
_position3D = target->getPosition();
|
||||
}
|
||||
|
||||
void ItemSub5610::setDirection(uint direction) {
|
||||
_direction3D = direction;
|
||||
}
|
||||
|
||||
ItemSub56::~ItemSub56() {
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ namespace Stark {
|
||||
class Anim;
|
||||
class AnimHierarchy;
|
||||
class BonesMesh;
|
||||
class Bookmark;
|
||||
class RenderEntry;
|
||||
class TextureSet;
|
||||
class Visual;
|
||||
@ -109,6 +110,9 @@ public:
|
||||
ItemSub5610(Resource *parent, byte subType, uint16 index, const Common::String &name);
|
||||
virtual ~ItemSub5610();
|
||||
|
||||
void placeOnBookmark(Bookmark *target);
|
||||
void setDirection(uint direction);
|
||||
|
||||
protected:
|
||||
int32 _field_6C;
|
||||
Math::Vector3d _position3D;
|
||||
|
Loading…
x
Reference in New Issue
Block a user