refactor: Modify _conversation directly when loading objects

This commit is contained in:
Vsevolod Kremianskii 2020-11-16 16:34:59 +07:00
parent 700062fe13
commit b5cd07126f
8 changed files with 11 additions and 20 deletions

View file

@ -90,6 +90,7 @@ void Creature::load(const GffStruct &gffs) {
void Creature::load(const shared_ptr<CreatureBlueprint> &blueprint) {
_blueprint = blueprint;
_tag = _blueprint->tag();
_conversation = _blueprint->conversation();
for (auto &item : _blueprint->equipment()) {
equip(item);
@ -496,10 +497,6 @@ shared_ptr<Texture> Creature::portrait() const {
return _portrait;
}
string Creature::conversation() const {
return _blueprint ? _blueprint->conversation() : "";
}
const map<InventorySlot, shared_ptr<Item>> &Creature::equipment() const {
return _equipment;
}

View file

@ -53,7 +53,6 @@ public:
Creature(uint32_t id, ObjectFactory *objectFactory, scene::SceneGraph *sceneGraph);
std::string conversation() const override;
glm::vec3 selectablePosition() const override;
void load(const resource::GffStruct &gffs);

View file

@ -45,10 +45,6 @@ Door::Door(uint32_t id, SceneGraph *sceneGraph) : SpatialObject(id, ObjectType::
_selectable = true;
}
string Door::conversation() const {
return _blueprint ? _blueprint->conversation() : "";
}
void Door::load(const GffStruct &gffs) {
_position[0] = gffs.getFloat("X");
_position[1] = gffs.getFloat("Y");
@ -69,6 +65,9 @@ void Door::load(const GffStruct &gffs) {
boost::to_lower(templResRef);
loadBlueprint(templResRef);
_conversation = _blueprint->conversation();
updateTransform();
}

View file

@ -31,8 +31,6 @@ class Door : public SpatialObject {
public:
Door(uint32_t id, scene::SceneGraph *sceneGraph);
std::string conversation() const override;
void load(const resource::GffStruct &gffs);
void open(Object *triggerrer);
void close(Object *triggerrer);

View file

@ -58,8 +58,8 @@ const string &Object::title() const {
return _title;
}
string Object::conversation() const {
return "";
const string &Object::conversation() const {
return _conversation;
}
ActionQueue &Object::actionQueue() {

View file

@ -41,7 +41,7 @@ public:
ObjectType type() const;
const std::string &tag() const;
const std::string &title() const;
virtual std::string conversation() const;
const std::string &conversation() const;
ActionQueue &actionQueue();
protected:
@ -49,6 +49,7 @@ protected:
ObjectType _type { ObjectType::None };
std::string _tag;
std::string _title;
std::string _conversation;
ActionQueue _actionQueue;
std::string _onUserDefined;

View file

@ -47,10 +47,6 @@ Placeable::Placeable(uint32_t id, ObjectFactory *objectFactory, SceneGraph *scen
_fadeDistance = 0.25f * _drawDistance;
}
string Placeable::conversation() const {
return _blueprint->conversation();
}
void Placeable::load(const GffStruct &gffs) {
_position[0] = gffs.getFloat("X");
_position[1] = gffs.getFloat("Y");
@ -62,6 +58,9 @@ void Placeable::load(const GffStruct &gffs) {
boost::to_lower(templResRef);
loadBlueprint(templResRef);
_conversation = _blueprint->conversation();
updateTransform();
}

View file

@ -35,8 +35,6 @@ class Placeable : public SpatialObject {
public:
Placeable(uint32_t id, ObjectFactory *objectFactory, scene::SceneGraph *sceneGraph);
std::string conversation() const override;
void load(const resource::GffStruct &gffs);
const PlaceableBlueprint &blueprint() const;