2008-09-10 14:12:04 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2008 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
#include "MindProperty.h"
|
|
|
|
|
|
2013-07-26 21:02:51 +02:00
|
|
|
#include "server/PossessionAuthenticator.h"
|
2013-07-26 21:45:11 +02:00
|
|
|
#include "server/ExternalMindsManager.h"
|
2013-07-26 21:02:51 +02:00
|
|
|
|
2018-10-30 20:12:45 +01:00
|
|
|
#include "common/operations/Setup.h"
|
2008-09-12 13:59:09 +00:00
|
|
|
|
|
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
|
|
|
|
#include <Atlas/Objects/Operation.h>
|
2008-09-10 14:12:04 +00:00
|
|
|
|
2011-12-15 18:33:32 +00:00
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::MapType;
|
2008-09-12 13:59:09 +00:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
|
|
|
|
using Atlas::Objects::Operation::Setup;
|
|
|
|
|
using Atlas::Objects::Operation::Look;
|
|
|
|
|
|
2018-08-09 21:30:10 +02:00
|
|
|
MindProperty::MindProperty(const MindProperty & rhs) = default;
|
2013-01-28 13:17:23 +00:00
|
|
|
|
2011-12-15 18:33:32 +00:00
|
|
|
void MindProperty::set(const Element & val)
|
|
|
|
|
{
|
2013-11-11 20:23:34 +01:00
|
|
|
Property<Atlas::Message::MapType>::set(val);
|
2011-12-15 18:33:32 +00:00
|
|
|
if (!val.isMap()) {
|
2018-02-08 21:46:49 +01:00
|
|
|
m_language.clear();
|
|
|
|
|
m_script.clear();
|
2011-12-15 18:33:32 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const MapType & data = val.Map();
|
2011-12-16 13:14:18 +00:00
|
|
|
if (data.empty()) {
|
2018-02-08 21:46:49 +01:00
|
|
|
m_language.clear();
|
|
|
|
|
m_script.clear();
|
2011-12-16 13:14:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2011-12-15 18:33:32 +00:00
|
|
|
|
2013-08-12 17:55:55 +02:00
|
|
|
{
|
|
|
|
|
auto I = data.find("name");
|
|
|
|
|
if (I == data.end()) {
|
|
|
|
|
return;
|
2011-12-15 18:33:32 +00:00
|
|
|
}
|
2013-08-12 17:55:55 +02:00
|
|
|
if (!I->second.isString()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_script = I->second.asString();
|
2011-12-15 18:33:32 +00:00
|
|
|
}
|
2013-08-12 17:55:55 +02:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
auto I = data.find("language");
|
|
|
|
|
if (I == data.end()) {
|
2011-12-15 18:33:32 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2013-08-12 17:55:55 +02:00
|
|
|
if (!I->second.isString()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
m_language = I->second.asString();
|
2011-12-15 18:33:32 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-07 23:03:25 +00:00
|
|
|
MindProperty * MindProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
return new MindProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void MindProperty::apply(LocatedEntity * ent)
|
2008-09-10 14:12:04 +00:00
|
|
|
{
|
2018-08-09 21:30:10 +02:00
|
|
|
ExternalMindsManager::instance().requestPossession(ent);
|
2008-09-10 14:12:04 +00:00
|
|
|
}
|
2013-08-22 10:43:03 +02:00
|
|
|
|
|
|
|
|
bool MindProperty::isMindEnabled() const
|
|
|
|
|
{
|
2018-02-08 21:46:49 +01:00
|
|
|
return !m_language.empty() || !m_script.empty();
|
2013-08-22 10:43:03 +02:00
|
|
|
}
|
|
|
|
|
|