2010-08-03 18:44:52 +02:00
|
|
|
|
|
|
|
#include "actionteleport.hpp"
|
|
|
|
|
2012-04-23 15:27:03 +02:00
|
|
|
#include "../mwbase/environment.hpp"
|
2012-07-03 12:30:50 +02:00
|
|
|
#include "../mwbase/world.hpp"
|
2014-01-12 14:03:11 +01:00
|
|
|
#include "../mwbase/mechanicsmanager.hpp"
|
2013-12-31 20:40:23 +01:00
|
|
|
#include "player.hpp"
|
2010-08-03 18:44:52 +02:00
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-07-27 12:00:10 +02:00
|
|
|
ActionTeleport::ActionTeleport (const std::string& cellName,
|
2010-08-03 18:44:52 +02:00
|
|
|
const ESM::Position& position)
|
2012-08-26 18:50:47 +02:00
|
|
|
: Action (true), mCellName (cellName), mPosition (position)
|
2012-08-26 11:47:45 -03:00
|
|
|
{
|
|
|
|
}
|
2010-08-03 18:44:52 +02:00
|
|
|
|
2012-07-27 12:00:10 +02:00
|
|
|
void ActionTeleport::executeImp (const Ptr& actor)
|
2010-08-03 18:44:52 +02:00
|
|
|
{
|
2013-12-31 20:40:23 +01:00
|
|
|
MWBase::World* world = MWBase::Environment::get().getWorld();
|
|
|
|
|
2014-01-12 14:03:11 +01: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 14:56:26 +02:00
|
|
|
else
|
2014-01-12 14:03:11 +01:00
|
|
|
{
|
|
|
|
if (mCellName.empty())
|
|
|
|
{
|
|
|
|
int cellX;
|
|
|
|
int cellY;
|
|
|
|
world->positionToIndex(mPosition.pos[0],mPosition.pos[1],cellX,cellY);
|
|
|
|
world->moveObject(actor,*world->getExterior(cellX,cellY),
|
|
|
|
mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
world->moveObject(actor,*world->getInterior(mCellName),mPosition.pos[0],mPosition.pos[1],mPosition.pos[2]);
|
|
|
|
}
|
2010-08-03 18:44:52 +02:00
|
|
|
}
|
|
|
|
}
|