2009-05-20 18:33:08 +01:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2009 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
2011-02-15 09:30:46 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-05-20 18:33:08 +01:00
|
|
|
#include "rulesets/Pedestrian.h"
|
|
|
|
|
|
|
|
|
|
#include "rulesets/Entity.h"
|
2010-05-02 22:41:06 +01:00
|
|
|
#include "rulesets/Domain.h"
|
2009-05-20 18:33:08 +01:00
|
|
|
#include "rulesets/TerrainProperty.h"
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
#include "common/BaseWorld.h"
|
|
|
|
|
|
2009-05-20 18:33:08 +01:00
|
|
|
#include <Atlas/Objects/RootOperation.h>
|
|
|
|
|
#include <Atlas/Objects/SmartPtr.h>
|
|
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
2010-05-02 22:41:06 +01:00
|
|
|
class TestWorld : public BaseWorld {
|
|
|
|
|
public:
|
2013-01-17 10:17:07 +00:00
|
|
|
explicit TestWorld(LocatedEntity & w) : BaseWorld(w) {
|
2010-05-02 22:41:06 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-03 12:19:42 +01:00
|
|
|
virtual bool idle() { return false; }
|
2013-01-17 10:17:07 +00:00
|
|
|
virtual LocatedEntity * addEntity(LocatedEntity * ent) {
|
2010-05-02 22:41:06 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2013-01-17 10:17:07 +00:00
|
|
|
virtual LocatedEntity * addNewEntity(const std::string &,
|
2010-05-02 22:41:06 +01:00
|
|
|
const Atlas::Objects::Entity::RootEntity &) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2013-11-15 22:55:17 +01:00
|
|
|
void delEntity(LocatedEntity * obj) {}
|
2010-05-02 22:41:06 +01:00
|
|
|
int createSpawnPoint(const Atlas::Message::MapType & data,
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity *) { return 0; }
|
2010-05-02 22:41:06 +01:00
|
|
|
int getSpawnList(Atlas::Message::ListType & data) { return 0; }
|
2013-11-24 15:01:38 +01:00
|
|
|
int removeSpawnPoint(LocatedEntity *) {return 0; }
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity * spawnNewEntity(const std::string & name,
|
2010-05-02 22:41:06 +01:00
|
|
|
const std::string & type,
|
|
|
|
|
const Atlas::Objects::Entity::RootEntity & desc) {
|
|
|
|
|
return addNewEntity(type, desc);
|
|
|
|
|
}
|
2013-11-16 21:05:45 +01:00
|
|
|
virtual int moveToSpawn(const std::string & name,
|
|
|
|
|
Location& location){return 0;}
|
2011-12-02 23:42:24 +00:00
|
|
|
virtual Task * newTask(const std::string &, LocatedEntity &) { return 0; }
|
2010-05-02 22:41:06 +01:00
|
|
|
virtual Task * activateTask(const std::string &, const std::string &,
|
2011-12-06 10:07:25 +00:00
|
|
|
LocatedEntity *, LocatedEntity &) { return 0; }
|
2013-01-17 10:17:07 +00:00
|
|
|
virtual ArithmeticScript * newArithmetic(const std::string &, LocatedEntity *) {
|
2010-07-13 18:03:57 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2010-05-02 22:41:06 +01:00
|
|
|
virtual void message(const Atlas::Objects::Operation::RootOperation & op,
|
2013-01-17 10:17:07 +00:00
|
|
|
LocatedEntity & ent) { }
|
|
|
|
|
virtual LocatedEntity * findByName(const std::string & name) { return 0; }
|
|
|
|
|
virtual LocatedEntity * findByType(const std::string & type) { return 0; }
|
|
|
|
|
virtual void addPerceptive(LocatedEntity *) { }
|
2010-05-02 22:41:06 +01:00
|
|
|
};
|
|
|
|
|
|
2009-05-20 18:33:08 +01:00
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
Entity * e = new Entity("1", 1);
|
|
|
|
|
Entity * wrld = new Entity("0", 0);
|
2010-05-02 22:41:06 +01:00
|
|
|
|
2009-05-20 18:33:08 +01:00
|
|
|
e->m_location.m_loc = wrld;
|
|
|
|
|
e->m_location.m_loc->makeContainer();
|
|
|
|
|
assert(e->m_location.m_loc->m_contains != 0);
|
|
|
|
|
e->m_location.m_loc->m_contains->insert(e);
|
|
|
|
|
|
2010-05-02 22:41:06 +01:00
|
|
|
TestWorld test_world(*wrld);
|
2009-05-20 18:33:08 +01:00
|
|
|
|
|
|
|
|
Pedestrian * p = new Pedestrian(*e);
|
|
|
|
|
|
|
|
|
|
p->getTickAddition(Point3D(0,0,0), Vector3D(1,0,0));
|
|
|
|
|
|
|
|
|
|
p->setTarget(Point3D(2,0,0));
|
|
|
|
|
|
|
|
|
|
p->getTickAddition(Point3D(0,0,0), Vector3D(1,0,0));
|
|
|
|
|
|
|
|
|
|
Location loc;
|
|
|
|
|
p->getUpdatedLocation(loc);
|
|
|
|
|
|
|
|
|
|
e->m_location.m_velocity = Vector3D(1,0,0);
|
|
|
|
|
p->getUpdatedLocation(loc);
|
|
|
|
|
|
|
|
|
|
e->m_location.m_pos = Point3D(1,0,0);
|
|
|
|
|
p->getUpdatedLocation(loc);
|
|
|
|
|
|
|
|
|
|
e->m_location.m_pos = Point3D(2,0,0);
|
|
|
|
|
p->getUpdatedLocation(loc);
|
|
|
|
|
|
|
|
|
|
e->m_location.m_pos = Point3D(3,0,0);
|
|
|
|
|
p->getUpdatedLocation(loc);
|
|
|
|
|
|
|
|
|
|
p->generateMove(loc);
|
|
|
|
|
|
|
|
|
|
delete p;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2010-05-02 22:41:06 +01:00
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/rulesets/stubEntity.h"
|
|
|
|
|
#include "stubs/rulesets/stubLocatedEntity.h"
|
|
|
|
|
#include "stubs/common/stubRouter.h"
|
|
|
|
|
#include "stubs/rulesets/stubDomain.h"
|
|
|
|
|
#include "stubs/common/stubBaseWorld.h"
|
|
|
|
|
#include "stubs/modules/stubLocation.h"
|
2010-05-02 22:41:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
float squareDistance(const Point3D & u, const Point3D & v)
|
|
|
|
|
{
|
|
|
|
|
return 1.f;
|
|
|
|
|
}
|