2008-08-14 00:03:12 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2004 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 "TerrainModProperty.h"
|
|
|
|
|
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/LocatedEntity.h"
|
2011-01-06 19:49:24 +00:00
|
|
|
#include "TerrainModTranslator.h"
|
2010-09-13 02:09:26 +01:00
|
|
|
#include "TerrainProperty.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/Domain.h"
|
2008-08-14 00:03:12 +00:00
|
|
|
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
|
2010-09-17 22:00:59 +01:00
|
|
|
#include "modules/TerrainContext.h"
|
|
|
|
|
|
2013-01-10 00:19:31 +00:00
|
|
|
#include <Atlas/Objects/RootEntity.h>
|
2013-02-14 00:04:58 +00:00
|
|
|
#include <Atlas/Objects/Operation.h>
|
2008-08-14 00:03:12 +00:00
|
|
|
|
|
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
|
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
using Atlas::Message::FloatType;
|
2013-01-10 00:19:31 +00:00
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
|
|
|
|
using Atlas::Objects::Root;
|
2008-08-14 00:03:12 +00:00
|
|
|
|
|
|
|
|
/// \brief TerrainModProperty constructor
|
|
|
|
|
///
|
2016-09-19 18:01:01 +02:00
|
|
|
TerrainModProperty::TerrainModProperty() :
|
|
|
|
|
m_translator(nullptr)
|
2008-08-14 00:03:12 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 21:04:56 +01:00
|
|
|
TerrainModProperty::~TerrainModProperty()
|
|
|
|
|
{
|
2010-11-11 17:32:53 +00:00
|
|
|
// TODO remove the mod from the terrain
|
2010-09-12 20:20:24 +01:00
|
|
|
// This is already covered from the Delete op handler when
|
|
|
|
|
// the entity is deleted
|
2016-09-19 18:01:01 +02:00
|
|
|
delete m_translator;
|
2009-01-05 21:04:56 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-08 00:19:23 +00:00
|
|
|
TerrainModProperty * TerrainModProperty::copy() const
|
|
|
|
|
{
|
|
|
|
|
// This is for instantiation of a class property.
|
|
|
|
|
// This is complex here, as is it not yet clear if this
|
|
|
|
|
// class can be a class property.
|
|
|
|
|
return new TerrainModProperty(*this);
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void TerrainModProperty::apply(LocatedEntity * owner)
|
2010-09-12 20:20:24 +01:00
|
|
|
{
|
2016-09-19 18:01:01 +02:00
|
|
|
delete m_translator;
|
|
|
|
|
|
|
|
|
|
m_translator = new TerrainModTranslator(m_data);
|
2011-01-11 13:09:23 +00:00
|
|
|
|
2010-09-12 20:20:24 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-19 18:01:01 +02:00
|
|
|
Mercator::TerrainMod * TerrainModProperty::parseModData(const WFMath::Point<3>& pos, const WFMath::Quaternion& orientation) const
|
2008-08-14 00:03:12 +00:00
|
|
|
{
|
2016-09-19 18:01:01 +02:00
|
|
|
if (m_translator) {
|
|
|
|
|
return m_translator->parseData(pos, orientation);
|
2009-01-06 13:33:18 +01:00
|
|
|
}
|
2016-09-19 17:45:45 +02:00
|
|
|
return nullptr;
|
2008-08-14 00:03:12 +00:00
|
|
|
}
|
2010-09-18 23:59:30 +01:00
|
|
|
|
2018-05-01 14:22:06 +02:00
|
|
|
int TerrainModProperty::getAttr(const std::string & name, Element & val) const
|
2010-09-18 23:59:30 +01:00
|
|
|
{
|
2018-10-30 19:31:27 +01:00
|
|
|
auto I = m_data.find(name);
|
2010-09-18 23:59:30 +01:00
|
|
|
if (I != m_data.end()) {
|
|
|
|
|
val = I->second;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-19 18:01:01 +02:00
|
|
|
void TerrainModProperty::setAttr(const std::string & name, const Element & val)
|
2010-09-18 23:59:30 +01:00
|
|
|
{
|
|
|
|
|
m_data[name] = val;
|
|
|
|
|
}
|
|
|
|
|
|