diff options
author | Andy <drumsetmonkey@gmail.com> | 2016-11-28 08:43:33 -0500 |
---|---|---|
committer | Andy <drumsetmonkey@gmail.com> | 2016-11-28 08:43:33 -0500 |
commit | 1c5b4e5a0ad8b7a65fef3df48ed50f96a4b865c7 (patch) | |
tree | 543d1a437efc734e131e3eb5a8bf5654aee7b794 /src | |
parent | 320f5d3506a8e0062606b9a178dd40d5a89b37c5 (diff) | |
parent | c155b43e5189e838c9988a464ca930efb242ee90 (diff) |
Merge branch 'master' of https://github.com/tcsullivan/gamedev
Diffstat (limited to 'src')
-rw-r--r-- | src/components.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/components.cpp b/src/components.cpp index d9b9b60..28358be 100644 --- a/src/components.cpp +++ b/src/components.cpp @@ -18,20 +18,24 @@ void MovementSystem::update(entityx::EntityManager &en, entityx::EventManager &e position.x += direction.x * dt; position.y += direction.y * dt; - if (entity.has_component<Sprite>()) { - auto& fl = entity.component<Sprite>()->faceLeft; - if (direction.x != 0) - fl = (direction.x < 0); - } + if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) { + direction.x = 0; + } else { + if (entity.has_component<Sprite>()) { + auto& fl = entity.component<Sprite>()->faceLeft; + if (direction.x != 0) + fl = (direction.x < 0); + } - if (entity.has_component<Wander>()) { - auto& countdown = entity.component<Wander>()->countdown; + if (entity.has_component<Wander>()) { + auto& countdown = entity.component<Wander>()->countdown; - if (countdown > 0) { - countdown--; - } else { - countdown = 5000 + randGet() % 10 * 100; - direction.x = (randGet() % 3 - 1) * 0.02f; + if (countdown > 0) { + countdown--; + } else { + countdown = 5000 + randGet() % 10 * 100; + direction.x = (randGet() % 3 - 1) * 0.02f; + } } } }); @@ -152,6 +156,9 @@ void DialogSystem::receive(const MouseClickEvent &mce) auto exml = game::engine.getSystem<WorldSystem>()->getXML()->FirstChildElement("Dialog"); int newIndex; + if (e.has_component<Direction>()) + d.talking = true; + if (d.index == 9999) { ui::dialogBox(name.name, "", false, randomDialog[d.rindex % randomDialog.size()]); ui::waitForDialog(); @@ -170,7 +177,6 @@ void DialogSystem::receive(const MouseClickEvent &mce) game::briceUpdate(); } - auto cxml = exml->FirstChildElement("content"); const char *content; if (cxml == nullptr) { @@ -186,6 +192,8 @@ void DialogSystem::receive(const MouseClickEvent &mce) if (exml->QueryIntAttribute("nextid", &newIndex) == XML_NO_ERROR) d.index = newIndex; } + + d.talking = false; }).detach(); } |