2009-05-05 11:48:38 +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
|
|
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
#include "TestBase.h"
|
|
|
|
|
|
2009-05-05 11:48:38 +01:00
|
|
|
#include "rulesets/Motion.h"
|
|
|
|
|
|
|
|
|
|
#include "rulesets/Entity.h"
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "rulesets/PhysicalDomain.h"
|
|
|
|
|
#include "rulesets/OutfitProperty.h"
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2009-09-07 21:11:18 +01:00
|
|
|
#include "common/TypeNode.h"
|
|
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
class Motiontest : public Cyphesis::TestBase
|
2009-05-05 11:48:38 +01:00
|
|
|
{
|
2012-12-19 10:36:08 +00:00
|
|
|
protected:
|
|
|
|
|
Entity * tlve;
|
|
|
|
|
Entity * ent;
|
|
|
|
|
Entity * other;
|
|
|
|
|
TypeNode * type;
|
|
|
|
|
Motion * motion;
|
2014-09-29 19:24:05 +02:00
|
|
|
Domain* domain;
|
2012-12-19 10:36:08 +00:00
|
|
|
public:
|
|
|
|
|
Motiontest();
|
|
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
|
|
|
|
|
|
|
|
|
void test_adjustPosition();
|
|
|
|
|
void test_genUpdateOperation();
|
|
|
|
|
void test_genMoveOperation();
|
|
|
|
|
void test_checkCollision_no_box();
|
|
|
|
|
void test_checkCollision_moving_box();
|
|
|
|
|
void test_checkCollision_two_boxes();
|
|
|
|
|
void test_checkCollision_close();
|
|
|
|
|
void test_checkCollision_broken();
|
|
|
|
|
void test_checkCollision_velocity();
|
|
|
|
|
void test_checkCollision_inner1();
|
|
|
|
|
void test_checkCollision_inner2();
|
|
|
|
|
void test_checkCollision_inner3();
|
|
|
|
|
void test_checkCollision_inner4();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void Motiontest::setup()
|
|
|
|
|
{
|
|
|
|
|
type = new TypeNode("test_type");
|
|
|
|
|
|
|
|
|
|
tlve = new Entity("0", 0);
|
2014-09-29 19:24:05 +02:00
|
|
|
domain = new PhysicalDomain(*tlve);
|
2012-12-19 10:36:08 +00:00
|
|
|
ent = new Entity("1", 1);
|
|
|
|
|
other = new Entity("2", 2);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
ent->m_location.m_loc = tlve;
|
|
|
|
|
ent->m_location.m_pos = Point3D(1, 1, 0);
|
|
|
|
|
ent->m_location.m_velocity = Vector3D(1,0,0);
|
|
|
|
|
ent->setType(type);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// Set up another entity to test collisions with.
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_location.m_loc = tlve;
|
|
|
|
|
other->m_location.m_pos = Point3D(10, 0, 0);
|
|
|
|
|
other->setType(type);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
tlve->m_contains = new LocatedEntitySet;
|
|
|
|
|
tlve->m_contains->insert(ent);
|
|
|
|
|
tlve->m_contains->insert(other);
|
|
|
|
|
tlve->setType(type);
|
|
|
|
|
tlve->incRef();
|
|
|
|
|
tlve->incRef();
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2015-04-28 21:00:18 +02:00
|
|
|
motion = new Motion(*ent);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
std::string example_mode("walking");
|
|
|
|
|
|
|
|
|
|
motion->setMode(example_mode);
|
|
|
|
|
assert(motion->mode() == example_mode);
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Motiontest::Motiontest()
|
|
|
|
|
{
|
|
|
|
|
ADD_TEST(Motiontest::test_adjustPosition);
|
|
|
|
|
ADD_TEST(Motiontest::test_genUpdateOperation);
|
|
|
|
|
ADD_TEST(Motiontest::test_genMoveOperation);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_no_box);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_moving_box);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_two_boxes);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_close);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_broken);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_velocity);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_inner1);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_inner2);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_inner3);
|
|
|
|
|
ADD_TEST(Motiontest::test_checkCollision_inner4);
|
|
|
|
|
}
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
void Motiontest::teardown()
|
|
|
|
|
{
|
|
|
|
|
ent->m_location.m_loc = 0;
|
|
|
|
|
other->m_location.m_loc = 0;
|
|
|
|
|
|
|
|
|
|
delete motion;
|
|
|
|
|
delete tlve;
|
|
|
|
|
delete ent;
|
|
|
|
|
delete other;
|
|
|
|
|
delete type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_adjustPosition()
|
|
|
|
|
{
|
2013-08-09 22:05:17 +02:00
|
|
|
motion->adjustPosition();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
void Motiontest::test_genUpdateOperation()
|
|
|
|
|
{
|
2009-05-05 11:48:38 +01:00
|
|
|
motion->genUpdateOperation();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
void Motiontest::test_genMoveOperation()
|
|
|
|
|
{
|
2009-05-05 11:48:38 +01:00
|
|
|
motion->genMoveOperation();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
void Motiontest::test_checkCollision_no_box()
|
|
|
|
|
{
|
2009-05-05 11:48:38 +01:00
|
|
|
// No collisions yet
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2012-12-19 10:36:08 +00:00
|
|
|
ASSERT_TRUE(!motion->collision());
|
|
|
|
|
}
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
void Motiontest::test_checkCollision_moving_box()
|
|
|
|
|
{
|
2009-05-05 11:48:38 +01:00
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
2012-12-19 10:36:08 +00:00
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// No collision yet, as other still has no big box
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
assert(!motion->collision());
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_two_boxes()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// No collision yet, as other is still too far away
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
assert(!motion->collision());
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_close()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// Move it closer
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// Now it can collide
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
assert(motion->collision());
|
2009-05-05 17:12:05 +01:00
|
|
|
motion->resolveCollision();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_broken()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
2009-05-05 17:12:05 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
|
|
|
|
|
|
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
2009-05-05 17:12:05 +01:00
|
|
|
|
|
|
|
|
// Set up the collision again
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 17:12:05 +01:00
|
|
|
assert(motion->collision());
|
|
|
|
|
// But this time break the hierarchy to hit the error message
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_location.m_loc = ent;
|
2009-05-05 17:12:05 +01:00
|
|
|
|
|
|
|
|
motion->resolveCollision();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_velocity()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
2009-05-05 17:12:05 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
2009-05-05 17:12:05 +01:00
|
|
|
|
|
|
|
|
// Set up the collision again
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 17:12:05 +01:00
|
|
|
assert(motion->collision());
|
|
|
|
|
|
|
|
|
|
// Re-align the velocity so some is preserved by the collision normal
|
2012-12-19 10:36:08 +00:00
|
|
|
ent->m_location.m_velocity = Vector3D(1,1,0);
|
2009-05-05 17:12:05 +01:00
|
|
|
|
|
|
|
|
motion->resolveCollision();
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_inner1()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
2009-05-05 17:12:05 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
// Add another entity inside other
|
|
|
|
|
Entity inner("3", 3);
|
|
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
inner.m_location.m_loc = other;
|
2009-05-05 11:48:38 +01:00
|
|
|
inner.m_location.m_pos = Point3D(0,0,0);
|
|
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_contains = new LocatedEntitySet;
|
|
|
|
|
other->m_contains->insert(&inner);
|
2009-05-05 11:48:38 +01:00
|
|
|
// Make other non-simple so that collision checks go inside
|
2012-12-19 10:36:08 +00:00
|
|
|
other->m_location.setSimple(false);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
assert(motion->collision());
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_inner2()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
|
|
|
|
|
|
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
|
|
|
|
|
|
|
|
|
// Add another entity inside other
|
|
|
|
|
Entity inner("3", 3);
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = other;
|
|
|
|
|
inner.m_location.m_pos = Point3D(0,0,0);
|
|
|
|
|
|
|
|
|
|
other->m_contains = new LocatedEntitySet;
|
|
|
|
|
other->m_contains->insert(&inner);
|
|
|
|
|
// Make other non-simple so that collision checks go inside
|
|
|
|
|
other->m_location.setSimple(false);
|
|
|
|
|
|
|
|
|
|
other->m_location.m_orientation = Quaternion(1,0,0,0);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
assert(motion->collision());
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_inner3()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
|
|
|
|
|
|
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
|
|
|
|
|
|
|
|
|
// Add another entity inside other
|
|
|
|
|
Entity inner("3", 3);
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = other;
|
|
|
|
|
inner.m_location.m_pos = Point3D(0,0,0);
|
|
|
|
|
|
|
|
|
|
other->m_contains = new LocatedEntitySet;
|
|
|
|
|
other->m_contains->insert(&inner);
|
|
|
|
|
// Make other non-simple so that collision checks go inside
|
|
|
|
|
other->m_location.setSimple(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
other->m_location.m_orientation = Quaternion(1,0,0,0);
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_bBox = BBox(Point3D(-0.1,-0.1,-0.1),
|
|
|
|
|
Point3D(0.1,0.1,0.1));
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
assert(motion->collision());
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Motiontest::test_checkCollision_inner4()
|
|
|
|
|
{
|
|
|
|
|
// Set up our moving entity with a bbox so collisions can be checked for.
|
|
|
|
|
ent->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
|
|
|
|
|
|
|
|
|
|
// Set up the other entity with a bbox so collisions can be checked for.
|
|
|
|
|
other->m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
|
|
|
|
|
|
|
|
|
|
// Move it closer
|
|
|
|
|
other->m_location.m_pos = Point3D(3, 0, 0);
|
|
|
|
|
|
|
|
|
|
// Add another entity inside other
|
|
|
|
|
Entity inner("3", 3);
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_loc = other;
|
|
|
|
|
inner.m_location.m_pos = Point3D(0,0,0);
|
|
|
|
|
|
|
|
|
|
other->m_contains = new LocatedEntitySet;
|
|
|
|
|
other->m_contains->insert(&inner);
|
|
|
|
|
// Make other non-simple so that collision checks go inside
|
|
|
|
|
other->m_location.setSimple(false);
|
|
|
|
|
|
|
|
|
|
other->m_location.m_orientation = Quaternion(1,0,0,0);
|
|
|
|
|
|
|
|
|
|
inner.m_location.m_bBox = BBox(Point3D(-0.1,-0.1,-0.1),
|
|
|
|
|
Point3D(0.1,0.1,0.1));
|
|
|
|
|
|
2009-05-05 11:48:38 +01:00
|
|
|
// Move the inner entity too far away for collision this interval
|
|
|
|
|
inner.m_location.m_pos = Point3D(3,0,0);
|
|
|
|
|
|
2015-04-28 21:00:18 +02:00
|
|
|
motion->checkCollisions(*domain);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
assert(motion->collision());
|
2012-12-19 22:28:45 +00:00
|
|
|
ASSERT_EQUAL(motion->m_collEntity, other);
|
2009-05-05 11:48:38 +01:00
|
|
|
|
|
|
|
|
inner.m_location.m_loc = 0;
|
2012-12-19 10:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
Motiontest t;
|
2009-05-05 11:48:38 +01:00
|
|
|
|
2012-12-19 10:36:08 +00:00
|
|
|
t.run();
|
2009-05-05 11:48:38 +01:00
|
|
|
}
|
2012-12-19 22:51:37 +00:00
|
|
|
|
|
|
|
|
// stubs
|
|
|
|
|
|
|
|
|
|
#include "common/const.h"
|
|
|
|
|
#include "common/log.h"
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "common/Property_impl.h"
|
2012-12-19 22:51:37 +00:00
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/rulesets/stubEntity.h"
|
|
|
|
|
#include "stubs/rulesets/stubDomain.h"
|
|
|
|
|
#include "stubs/rulesets/stubTerrainProperty.h"
|
|
|
|
|
#include "stubs/rulesets/stubOutfitProperty.h"
|
2015-04-15 23:06:33 +02:00
|
|
|
#include "stubs/common/stubCustom.h"
|
2012-12-19 22:51:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
LocatedEntity::LocatedEntity(const std::string & id, long intId) :
|
|
|
|
|
Router(id, intId),
|
|
|
|
|
m_refCount(0), m_seq(0),
|
2013-01-14 09:59:54 +00:00
|
|
|
m_script(0), m_type(0), m_flags(0), m_contains(0)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LocatedEntity::~LocatedEntity()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool LocatedEntity::hasAttr(const std::string & name) const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LocatedEntity::getAttr(const std::string & name,
|
|
|
|
|
Atlas::Message::Element & attr) const
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int LocatedEntity::getAttrType(const std::string & name,
|
|
|
|
|
Atlas::Message::Element & attr,
|
|
|
|
|
int type) const
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyBase * LocatedEntity::setAttr(const std::string & name,
|
|
|
|
|
const Atlas::Message::Element & attr)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const PropertyBase * LocatedEntity::getProperty(const std::string & name) const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
PropertyBase * LocatedEntity::modProperty(const std::string & name)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PropertyBase * LocatedEntity::setProperty(const std::string & name,
|
|
|
|
|
PropertyBase * prop)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::installDelegate(int, const std::string &)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-25 22:42:00 +02:00
|
|
|
void LocatedEntity::removeDelegate(int class_no, const std::string & delegate)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void LocatedEntity::destroy()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Domain * LocatedEntity::getMovementDomain()
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::sendWorld(const Operation & op)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-15 22:53:14 +02:00
|
|
|
void LocatedEntity::onContainered(const LocatedEntity*)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::onUpdated()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::makeContainer()
|
|
|
|
|
{
|
|
|
|
|
if (m_contains == 0) {
|
|
|
|
|
m_contains = new LocatedEntitySet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::changeContainer(LocatedEntity * new_loc)
|
|
|
|
|
{
|
|
|
|
|
assert(m_location.m_loc != 0);
|
|
|
|
|
assert(m_location.m_loc->m_contains != 0);
|
|
|
|
|
m_location.m_loc->m_contains->erase(this);
|
|
|
|
|
if (m_location.m_loc->m_contains->empty()) {
|
|
|
|
|
m_location.m_loc->onUpdated();
|
|
|
|
|
}
|
|
|
|
|
new_loc->makeContainer();
|
|
|
|
|
bool was_empty = new_loc->m_contains->empty();
|
|
|
|
|
new_loc->m_contains->insert(this);
|
|
|
|
|
if (was_empty) {
|
|
|
|
|
new_loc->onUpdated();
|
|
|
|
|
}
|
|
|
|
|
assert(m_location.m_loc->checkRef() > 0);
|
2013-06-15 22:53:14 +02:00
|
|
|
LocatedEntity* oldLoc = m_location.m_loc;
|
2012-12-19 22:51:37 +00:00
|
|
|
m_location.m_loc = new_loc;
|
|
|
|
|
m_location.m_loc->incRef();
|
|
|
|
|
assert(m_location.m_loc->checkRef() > 0);
|
|
|
|
|
|
2013-06-15 22:53:14 +02:00
|
|
|
onContainered(oldLoc);
|
|
|
|
|
oldLoc->decRef();
|
2012-12-19 22:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocatedEntity::merge(const Atlas::Message::MapType & ent)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
void LocatedEntity::addChild(LocatedEntity& childEntity)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
void LocatedEntity::removeChild(LocatedEntity& childEntity)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2015-04-09 14:50:45 +02:00
|
|
|
|
|
|
|
|
void LocatedEntity::setType(const TypeNode* t)
|
|
|
|
|
{
|
|
|
|
|
m_type = t;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 22:05:09 +02:00
|
|
|
std::vector<Atlas::Objects::Root> LocatedEntity::getThoughts() const
|
|
|
|
|
{
|
|
|
|
|
return std::vector<Atlas::Objects::Root>();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/common/stubRouter.h"
|
|
|
|
|
#include "stubs/modules/stubLocation.h"
|
|
|
|
|
#include "stubs/common/stubTypeNode.h"
|
|
|
|
|
#include "stubs/common/stubProperty.h"
|
|
|
|
|
#include "rulesets/EntityProperty.h"
|
|
|
|
|
#include "stubs/rulesets/stubEntityProperty.h"
|
2012-12-19 22:51:37 +00:00
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
WFMath::CoordType squareDistance(const Point3D & u, const Point3D & v)
|
2012-12-19 22:51:37 +00:00
|
|
|
{
|
2014-09-29 19:24:05 +02:00
|
|
|
return 0.0f;
|
2012-12-19 22:51:37 +00:00
|
|
|
}
|
|
|
|
|
|