2010-08-03 16:44:52 +00:00
|
|
|
|
|
|
|
#include "actionteleport.hpp"
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
2014-01-12 13:03:11 +00:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2013-12-31 19:40:23 +00:00
|
|
|
#include "player.hpp"
|
2010-08-03 16:44:52 +00:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-07-27 10:00:10 +00:00
|
|
|
ActionTeleport::ActionTeleport (const std::string& cellName,
|
2010-08-03 16:44:52 +00:00
|
|
|
const ESM::Position& position)
|
2012-08-26 16:50:47 +00:00
|
|
|
: Action (true), mCellName (cellName), mPosition (position)
|
2012-08-26 14:47:45 +00:00
|
|
|
{
|
|
|
|
}
|
2010-08-03 16:44:52 +00:00
|
|
|
|
2012-07-27 10:00:10 +00:00
|
|
|
void ActionTeleport::executeImp (const Ptr& actor)
|
2010-08-03 16:44:52 +00:00
|
|
|
{
|
2013-12-31 19:40:23 +00:00
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
2014-01-12 13:03:11 +00:00
|
|
|
//find any NPC that is following the actor and teleport him too
|
|
|
|
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
|
|
|
|
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();it++)
|
|
|
|
{
|
|
|
|
std::cout << "teleporting someone!" << (*it).getCellRef().mRefID;
|
|
|
|
executeImp(*it);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(actor == world->getPlayerPtr())
|
|
|
|
{
|
|
|
|
world->getPlayer().setTeleported(true);
|
|
|
|
if (mCellName.empty())
|
|
|
|
world->changeToExteriorCell (mPosition);
|
|
|
|
else
|
|
|
|
world->changeToInteriorCell (mCellName, mPosition);
|
|
|
|
}
|
2010-08-20 12:56:26 +00:00
|
|
|
else
|
2014-01-12 13:03:11 +00:00
|
|
|
{
|
|
|
|
if (mCellName.empty())
|
|
|
|
{
|
|
|
|
int cellX;
|
|
|
|
int cellY;
|
|
|
|
world->positionToIndex(mPosition.pos[0],mPosition.pos[1],cellX,cellY);
|
2014-03-07 05:11:00 +00:00
|
|
|
world->moveObject(actor,world->getExterior(cellX,cellY),
|
2014-01-12 13:03:11 +00:00
|
|
|
mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
|
|
|
}
|
|
|
|
else
|
2014-03-07 05:11:00 +00:00
|
|
|
world->moveObject(actor,world->getInterior(mCellName),mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
2014-01-12 13:03:11 +00:00
|
|
|
}
|
2010-08-03 16:44:52 +00:00
|
|
|
}
|
|
|
|
}
|