1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-24 21:57:44 +00:00
sapphire/src/world/Manager/PlayerMgr.cpp

78 lines
2 KiB
C++
Raw Normal View History

#include "PlayerMgr.h"
#include <Framework.h>
#include <Exd/ExdDataGenerated.h>
#include <Manager/TerritoryMgr.h>
#include <Territory/ZonePosition.h>
2019-07-21 22:33:33 +10:00
#include <Territory/Territory.h>
#include <Manager/HousingMgr.h>
#include <Actor/Player.h>
using namespace Sapphire::World::Manager;
Sapphire::World::Manager::PlayerMgr::PlayerMgr( Sapphire::FrameworkPtr pFw ) :
BaseManager( std::move( pFw ) )
{
}
void Sapphire::World::Manager::PlayerMgr::movePlayerToLandDestination( Sapphire::Entity::Player& player, uint32_t landId, uint16_t param )
{
// check if we have one in the db first
auto terriMgr = framework()->get< TerritoryMgr >();
if( !terriMgr )
return;
2019-07-21 22:33:33 +10:00
Sapphire::TerritoryPtr destinationZone;
auto terriPos = terriMgr->getTerritoryPosition( landId );
if( terriPos )
{
// check if its a housing zone, zoning is different here
if( terriMgr->isHousingTerritory( terriPos->getTargetZoneId() ) )
{
auto housingMgr = framework()->get< HousingMgr >();
auto landSetId = housingMgr->toLandSetId( terriPos->getTargetZoneId(), param );
auto housingZone = housingMgr->getHousingZoneByLandSetId( landSetId );
if( !housingZone )
return;
destinationZone = housingZone;
}
else if( terriMgr->isInstanceContentTerritory( terriPos->getTargetZoneId() ) )
{
// todo: instance dungeon handling
// will need to use setInstance so old pos gets set
return;
}
else
{
// normal zones
destinationZone = terriMgr->getZoneByTerritoryTypeId( terriPos->getTargetZoneId() );
}
}
else
{
// todo: lookup land.exd and see if it's in there if its not in our db
return;
}
if( !destinationZone )
{
player.sendDebug( "Unable to find applicable territory for Warp#{0}. "
"Check that it exists inside zonepositions table.",
landId );
return;
}
player.setPos( terriPos->getTargetPosition() );
player.setRot( terriPos->getTargetRotation() );
terriMgr->movePlayer( destinationZone, player.getAsPlayer() );
}