Added serverPathfinding library

This commit is contained in:
Anonymous
2014-01-15 09:54:09 -07:00
parent 7d149b2784
commit cd99b53a31
43 changed files with 5888 additions and 2 deletions
@@ -0,0 +1,127 @@
// ======================================================================
//
// ServerPathfindingNotification.cpp
// copyright (c) 2001 Sony Online Entertainment
//
// ======================================================================
#include "serverPathfinding/FirstServerPathfinding.h"
#include "serverPathfinding/ServerPathfindingNotification.h"
#include "serverGame/ServerObject.h"
#include "serverGame/BuildingObject.h"
#include "serverPathfinding/CityPathGraphManager.h"
#include "serverPathfinding/ServerPathfindingConstants.h"
#include "sharedObject/Object.h"
namespace ServerPathfindingNotificationNamespace
{
ServerPathfindingNotification g_notification;
};
using namespace ServerPathfindingNotificationNamespace;
// ======================================================================
// CityPathGraphManager notification
ServerPathfindingNotification::ServerPathfindingNotification()
{
}
ServerPathfindingNotification::~ServerPathfindingNotification()
{
}
// ----------------------------------------------------------------------
void ServerPathfindingNotification::addToWorld ( Object & object ) const
{
BuildingObject * building = dynamic_cast<BuildingObject*>(&object);
if(building)
{
CityPathGraphManager::addBuilding( building );
}
else if(object.asServerObject() != NULL && object.asServerObject()->isWaypoint())
{
CityPathGraphManager::addWaypoint( object.asServerObject() );
}
else
{
}
}
void ServerPathfindingNotification::removeFromWorld ( Object & object ) const
{
BuildingObject * building = dynamic_cast<BuildingObject*>(&object);
if(building)
{
CityPathGraphManager::removeBuilding( building );
}
else if(object.asServerObject() != NULL && object.asServerObject()->isWaypoint())
{
CityPathGraphManager::removeWaypoint( object.asServerObject() );
}
else
{
CityPathGraphManager::destroyPathGraph(object.asServerObject());
}
}
bool ServerPathfindingNotification::positionChanged ( Object & object, bool /*dueToParentChange*/, Vector const & oldPosition) const
{
BuildingObject * building = dynamic_cast<BuildingObject*>(&object);
if(building)
{
CityPathGraphManager::moveBuilding( building, oldPosition );
}
else if(object.asServerObject() != NULL && object.asServerObject()->isWaypoint())
{
CityPathGraphManager::moveWaypoint( object.asServerObject(), oldPosition );
}
return true;
}
bool ServerPathfindingNotification::positionAndRotationChanged ( Object & object, bool /*dueToParentChange*/, Vector const & oldPosition ) const
{
BuildingObject * building = dynamic_cast<BuildingObject*>(&object);
if(building)
{
CityPathGraphManager::moveBuilding( building, oldPosition );
}
else if(object.asServerObject() != NULL && object.asServerObject()->isWaypoint())
{
CityPathGraphManager::moveWaypoint( object.asServerObject(), oldPosition );
}
return true;
}
// ----------------------------------------------------------------------
void ServerPathfindingNotification::destroyBuilding ( BuildingObject * building )
{
CityPathGraphManager::destroyBuilding(building);
}
// ----------------------------------------------------------------------
void ServerPathfindingNotification::destroyWaypoint ( ServerObject * building )
{
CityPathGraphManager::destroyWaypoint(building);
}
// ----------------------------------------------------------------------
ServerPathfindingNotification & ServerPathfindingNotification::getInstance ( void )
{
return g_notification;
}
// ======================================================================