feat: Clicking on placeables may start conversations
This commit is contained in:
parent
86b89ae1e4
commit
0bbbbce393
3 changed files with 21 additions and 8 deletions
|
@ -91,14 +91,17 @@ void Area::loadLYT() {
|
|||
lyt.load(wrap(Resources::instance().get(_name, ResourceType::AreaLayout)));
|
||||
|
||||
for (auto &lytRoom : lyt.rooms()) {
|
||||
shared_ptr<Model> model(Models::instance().get(lytRoom.name));
|
||||
if (!model) continue;
|
||||
|
||||
glm::vec3 position(lytRoom.position.x, lytRoom.position.y, lytRoom.position.z);
|
||||
|
||||
shared_ptr<ModelSceneNode> model(new ModelSceneNode(&_game->sceneGraph(), Models::instance().get(lytRoom.name)));
|
||||
model->setLocalTransform(glm::translate(glm::mat4(1.0f), position));
|
||||
model->playAnimation("animloop1", kAnimationLoop);
|
||||
shared_ptr<ModelSceneNode> sceneNode(new ModelSceneNode(&_game->sceneGraph(), model));
|
||||
sceneNode->setLocalTransform(glm::translate(glm::mat4(1.0f), position));
|
||||
sceneNode->playAnimation("animloop1", kAnimationLoop);
|
||||
|
||||
shared_ptr<Walkmesh> walkmesh(Walkmeshes::instance().get(lytRoom.name, ResourceType::Walkmesh));
|
||||
unique_ptr<Room> room(new Room(lytRoom.name, position, model, walkmesh));
|
||||
unique_ptr<Room> room(new Room(lytRoom.name, position, sceneNode, walkmesh));
|
||||
|
||||
_rooms.insert(make_pair(room->name(), move(room)));
|
||||
}
|
||||
|
|
|
@ -213,12 +213,17 @@ void Module::onDoorClick(const shared_ptr<Door> &door) {
|
|||
}
|
||||
|
||||
void Module::onPlaceableClick(const shared_ptr<Placeable> &placeable) {
|
||||
if (!placeable->blueprint().hasInventory()) return;
|
||||
|
||||
shared_ptr<Creature> partyLeader(_game->party().leader());
|
||||
ActionQueue &actions = partyLeader->actionQueue();
|
||||
actions.clear();
|
||||
actions.add(make_unique<ObjectAction>(ActionType::OpenContainer, placeable));
|
||||
|
||||
if (placeable->blueprint().hasInventory()) {
|
||||
actions.clear();
|
||||
actions.add(make_unique<ObjectAction>(ActionType::OpenContainer, placeable));
|
||||
|
||||
} else if (!placeable->conversation().empty()) {
|
||||
actions.clear();
|
||||
actions.add(make_unique<StartConversationAction>(placeable, placeable->conversation()));
|
||||
}
|
||||
}
|
||||
|
||||
void Module::update(float dt) {
|
||||
|
|
|
@ -269,8 +269,13 @@ Variable Routines::getStringByStrRef(const vector<Variable> &args, ExecutionCont
|
|||
|
||||
Variable Routines::startNewModule(const vector<Variable> &args, ExecutionContext &ctx) {
|
||||
string moduleName(args[0].strValue);
|
||||
boost::to_lower(moduleName);
|
||||
|
||||
string waypoint(args.size() >= 2 ? args[1].strValue : "");
|
||||
boost::to_lower(waypoint);
|
||||
|
||||
_game->scheduleModuleTransition(moduleName, waypoint);
|
||||
|
||||
return Variable();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue