2010-08-03 11:03:08 +00:00
|
|
|
#include "activator.hpp"
|
|
|
|
|
|
|
|
#include <components/esm/loadacti.hpp>
|
|
|
|
|
2012-06-29 14:48:50 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-08-12 16:11:09 +00:00
|
|
|
#include "../mwbase/windowmanager.hpp"
|
2013-01-16 22:37:32 +00:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2013-08-28 18:36:22 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2010-08-03 15:11:41 +00:00
|
|
|
|
2014-12-19 10:26:54 +00:00
|
|
|
#include "../mwworld/cellstore.hpp"
|
|
|
|
#include "../mwworld/esmstore.hpp"
|
2010-08-03 15:11:41 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2013-08-28 18:36:22 +00:00
|
|
|
#include "../mwworld/action.hpp"
|
|
|
|
#include "../mwworld/failedaction.hpp"
|
|
|
|
#include "../mwworld/nullaction.hpp"
|
2012-06-29 14:48:50 +00:00
|
|
|
|
2015-05-09 23:09:00 +00:00
|
|
|
#include "../mwphysics/physicssystem.hpp"
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
#include "../mwrender/objects.hpp"
|
2012-07-03 11:15:20 +00:00
|
|
|
#include "../mwrender/renderinginterface.hpp"
|
2012-06-29 14:48:50 +00:00
|
|
|
|
2012-07-03 11:15:20 +00:00
|
|
|
#include "../mwgui/tooltips.hpp"
|
2010-08-14 08:02:54 +00:00
|
|
|
|
2013-08-28 18:36:22 +00:00
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
|
|
|
|
|
|
|
|
2010-08-03 11:17:31 +00:00
|
|
|
namespace MWClass
|
2010-08-03 11:03:08 +00:00
|
|
|
{
|
2014-07-18 07:56:58 +00:00
|
|
|
|
2015-01-12 10:29:56 +00:00
|
|
|
void Activator::insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 08:02:54 +00:00
|
|
|
{
|
2012-07-24 16:22:11 +00:00
|
|
|
if (!model.empty()) {
|
2015-04-12 13:34:50 +00:00
|
|
|
renderingInterface.getObjects().insertModel(ptr, model, true);
|
2010-08-14 08:02:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-09 23:09:00 +00:00
|
|
|
void Activator::insertObject(const MWWorld::Ptr& ptr, const std::string& model, MWPhysics::PhysicsSystem& physics) const
|
2012-07-24 16:22:11 +00:00
|
|
|
{
|
2012-11-05 18:40:02 +00:00
|
|
|
if(!model.empty())
|
2015-01-12 10:29:56 +00:00
|
|
|
physics.addObject(ptr, model);
|
2012-07-24 16:22:11 +00:00
|
|
|
}
|
2012-08-12 16:11:09 +00:00
|
|
|
|
2015-12-18 14:51:05 +00:00
|
|
|
std::string Activator::getModel(const MWWorld::ConstPtr &ptr) const
|
2011-11-12 04:01:12 +00:00
|
|
|
{
|
2015-12-18 14:51:05 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
|
2011-11-12 04:01:12 +00:00
|
|
|
|
2012-11-05 12:07:59 +00:00
|
|
|
const std::string &model = ref->mBase->mModel;
|
2012-07-24 16:22:11 +00:00
|
|
|
if (!model.empty()) {
|
|
|
|
return "meshes\\" + model;
|
2011-11-12 04:01:12 +00:00
|
|
|
}
|
2012-07-24 16:22:11 +00:00
|
|
|
return "";
|
2011-11-12 04:01:12 +00:00
|
|
|
}
|
|
|
|
|
2017-08-18 13:06:47 +00:00
|
|
|
bool Activator::isActivator() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-20 18:04:02 +00:00
|
|
|
bool Activator::useAnim() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-12-18 14:27:06 +00:00
|
|
|
std::string Activator::getName (const MWWorld::ConstPtr& ptr) const
|
2010-08-03 15:11:41 +00:00
|
|
|
{
|
2015-12-18 14:27:06 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
|
2010-08-03 15:11:41 +00:00
|
|
|
|
2012-11-05 12:07:59 +00:00
|
|
|
return ref->mBase->mName;
|
2010-08-03 15:11:41 +00:00
|
|
|
}
|
|
|
|
|
2015-12-17 23:12:03 +00:00
|
|
|
std::string Activator::getScript (const MWWorld::ConstPtr& ptr) const
|
2010-08-05 13:40:03 +00:00
|
|
|
{
|
2015-12-17 23:12:03 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref =
|
2010-08-05 13:40:03 +00:00
|
|
|
ptr.get<ESM::Activator>();
|
|
|
|
|
2012-11-05 12:07:59 +00:00
|
|
|
return ref->mBase->mScript;
|
2010-08-05 13:40:03 +00:00
|
|
|
}
|
|
|
|
|
2010-08-03 11:03:08 +00:00
|
|
|
void Activator::registerSelf()
|
|
|
|
{
|
2017-05-05 19:21:11 +00:00
|
|
|
std::shared_ptr<Class> instance (new Activator);
|
2010-08-03 11:03:08 +00:00
|
|
|
|
|
|
|
registerClass (typeid (ESM::Activator).name(), instance);
|
|
|
|
}
|
2012-04-16 20:58:16 +00:00
|
|
|
|
2015-12-19 15:13:00 +00:00
|
|
|
bool Activator::hasToolTip (const MWWorld::ConstPtr& ptr) const
|
2012-04-16 20:58:16 +00:00
|
|
|
{
|
2015-12-19 15:13:00 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
|
2012-04-16 20:58:16 +00:00
|
|
|
|
2012-11-05 12:07:59 +00:00
|
|
|
return (ref->mBase->mName != "");
|
2012-04-16 20:58:16 +00:00
|
|
|
}
|
|
|
|
|
2016-07-06 15:03:14 +00:00
|
|
|
bool Activator::allowTelekinesis(const MWWorld::ConstPtr &ptr) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-19 15:29:07 +00:00
|
|
|
MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::ConstPtr& ptr, int count) const
|
2012-04-16 20:58:16 +00:00
|
|
|
{
|
2015-12-18 14:27:06 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
|
2012-04-16 20:58:16 +00:00
|
|
|
|
|
|
|
MWGui::ToolTipInfo info;
|
2015-12-19 15:29:07 +00:00
|
|
|
info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(count);
|
2012-04-16 20:58:16 +00:00
|
|
|
|
|
|
|
std::string text;
|
2012-04-24 00:02:03 +00:00
|
|
|
if (MWBase::Environment::get().getWindowManager()->getFullHelp())
|
2014-01-07 19:24:01 +00:00
|
|
|
{
|
2014-07-22 18:03:35 +00:00
|
|
|
text += MWGui::ToolTips::getCellRefString(ptr.getCellRef());
|
2012-11-05 12:07:59 +00:00
|
|
|
text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script");
|
2014-01-07 19:24:01 +00:00
|
|
|
}
|
2012-04-16 20:58:16 +00:00
|
|
|
info.text = text;
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
2013-08-28 18:36:22 +00:00
|
|
|
|
2017-05-05 19:21:11 +00:00
|
|
|
std::shared_ptr<MWWorld::Action> Activator::activate(const MWWorld::Ptr &ptr, const MWWorld::Ptr &actor) const
|
2013-08-28 18:36:22 +00:00
|
|
|
{
|
2014-05-22 18:37:22 +00:00
|
|
|
if(actor.getClass().isNpc() && actor.getClass().getNpcStats(actor).isWerewolf())
|
2013-08-28 18:36:22 +00:00
|
|
|
{
|
|
|
|
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
const ESM::Sound *sound = store.get<ESM::Sound>().searchRandom("WolfActivator");
|
|
|
|
|
2017-05-05 19:21:11 +00:00
|
|
|
std::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction("#{sWerewolfRefusal}"));
|
2013-08-28 18:36:22 +00:00
|
|
|
if(sound) action->setSound(sound->mId);
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
2017-05-05 19:21:11 +00:00
|
|
|
return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction);
|
2013-08-28 18:36:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-18 15:24:24 +00:00
|
|
|
MWWorld::Ptr Activator::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
|
2012-07-25 13:18:17 +00:00
|
|
|
{
|
2015-12-18 15:24:24 +00:00
|
|
|
const MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>();
|
2012-07-25 13:18:17 +00:00
|
|
|
|
2015-11-14 16:12:05 +00:00
|
|
|
return MWWorld::Ptr(cell.insert(ref), &cell);
|
2012-07-25 13:18:17 +00:00
|
|
|
}
|
2010-08-03 11:03:08 +00:00
|
|
|
}
|