openmw-tes3coop/apps/openmw/mwdialogue/dialoguemanager.cpp

83 lines
2.5 KiB
C++
Raw Normal View History

2010-08-06 16:01:34 +00:00
#include "dialoguemanager.hpp"
2010-08-06 16:01:34 +00:00
#include <components/esm/loadinfo.hpp>
#include <components/esm/loaddial.hpp>
#include <components/esm_store/store.hpp>
2010-08-06 16:01:34 +00:00
#include "../mwworld/class.hpp"
#include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp"
2010-08-06 16:01:34 +00:00
#include <iostream>
namespace MWDialogue
2010-08-06 16:01:34 +00:00
{
bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const
{
// TODO check actor id
// TODO check actor race
// TODO check actor class
// TODO check actor faction
// TODO check player faction
2010-08-08 09:37:59 +00:00
// check cell
if (!info.cell.empty())
if (mEnvironment.mWorld->getPlayerPos().getPlayer().getCell()->cell->name != info.cell)
return false;
// TODO check DATAstruct
// TODO check select structures
std::cout
<< "unchecked entries:" << std::endl
<< " actor id: " << info.actor << std::endl
<< " actor race: " << info.race << std::endl
<< " actor class: " << info.clas << std::endl
<< " actor faction: " << info.npcFaction << std::endl
<< " player faction: " << info.pcFaction << std::endl
<< " DATAstruct" << std::endl;
for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.selects.begin());
iter != info.selects.end(); ++iter)
std::cout << " select: " << iter->selectRule << std::endl;
return true;
}
DialogueManager::DialogueManager (MWWorld::Environment& environment) : mEnvironment (environment) {}
2010-08-06 16:01:34 +00:00
void DialogueManager::startDialogue (const MWWorld::Ptr& actor)
2010-08-06 16:01:34 +00:00
{
std::cout << "talking with " << MWWorld::Class::get (actor).getName (actor) << std::endl;
const ESM::Dialogue *dialogue = mEnvironment.mWorld->getStore().dialogs.find ("hello");
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter)
{
if (isMatching (actor, *iter))
{
// start dialogue
std::cout << "found matching info record" << std::endl;
std::cout << "response: " << iter->response << std::endl;
if (!iter->sound.empty())
{
// TODO play sound
}
if (!iter->resultScript.empty())
{
// TODO execute script
}
break;
}
}
2010-08-06 16:01:34 +00:00
}
}