forked from teamnwah/openmw-tes3coop
2d0840cb3a
This commit changes the style of tes3mp serverside scripting mods. Short list of changes: * Break compatibility with old server mods * OOP style lua API * Basic dependency checker, allowing the installation of multiple server mods without changing configs * Remove support for C++ plugins * Change outdated LuaBridge to [sol2](https://github.com/ThePhD/sol2); * Support GCC, Clang and MSVC compilers * New environment variables: "TES3MP_SERVER_DIR" and "TES3MP_SERVER_USERDIR"; * New entity "Command controller" for registering new chat commands; * New Event system * Simplified Timer API * All Lua mods now run in their own environments * Add global namespace - Data that can be used for communicating between mods * Player and Actor inherit base class NetActor
62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
//
|
|
// Created by koncord on 15.08.17.
|
|
//
|
|
|
|
#include "Dialogue.hpp"
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
#include "Script/LuaState.hpp"
|
|
#include "Player.hpp"
|
|
#include "Networking.hpp"
|
|
|
|
void Dialogue::Init(LuaState &lua)
|
|
{
|
|
lua.getState()->new_usertype<Dialogue>("Dialogue",
|
|
"addTopic", &Dialogue::addTopic,
|
|
"getTopicId", &Dialogue::getTopicId,
|
|
"getChanges", &Dialogue::getChanges,
|
|
"reset", &Dialogue::reset);
|
|
}
|
|
|
|
|
|
|
|
Dialogue::Dialogue(Player *player) : player(player), changed(false)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
void Dialogue::reset()
|
|
{
|
|
player->topicChanges.topics.clear();
|
|
}
|
|
|
|
void Dialogue::update()
|
|
{
|
|
if (!changed)
|
|
return;
|
|
changed = false;
|
|
|
|
auto packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC);
|
|
|
|
packet->setPlayer(player);
|
|
packet->Send(/*toOthers*/ false);
|
|
}
|
|
|
|
void Dialogue::addTopic(const std::string &topicId)
|
|
{
|
|
if (!changed)
|
|
reset();
|
|
changed = true;
|
|
player->topicChanges.topics.push_back({topicId});
|
|
}
|
|
|
|
std::string Dialogue::getTopicId(unsigned int i) const
|
|
{
|
|
return player->topicChanges.topics.at(i).topicId;
|
|
}
|
|
|
|
unsigned int Dialogue::getChanges() const
|
|
{
|
|
return player->topicChanges.count;
|
|
}
|