Skip to content

Commit 0e40145

Browse files
committed
Implement Position and WorldPosition exports, update inherit objects/classes
1 parent 154ced3 commit 0e40145

5 files changed

Lines changed: 68 additions & 7 deletions

File tree

‎src/Bindings/Exports/GameObjectExport.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void export_gameobject_class()
1010
{
1111
using namespace PyEng::GameObjectAdapter;
1212

13-
bp::class_<GameObject, boost::noncopyable> gameobject_class("GameObject", bp::no_init);
13+
bp::class_<GameObject, bp::bases<WorldObject>, boost::noncopyable> gameobject_class("GameObject", bp::no_init);
1414

1515
gameobject_class.def("GetEntry", &GameObject::GetEntry);
1616
gameobject_class.def("GetName", &GameObject::GetName, bp::return_value_policy<bp::copy_const_reference>());

‎src/Bindings/Exports/ItemExport.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "PythonHeaders.h"
22
#include "ItemAdapter.h"
3+
#include "ItemTemplate.h"
34

45
namespace bp = boost::python;
56

‎src/Bindings/Exports/ObjectExport.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ void export_object_class()
3939

4040
/**
4141
* @brief WorldObject Class - Base class for objects in the game world
42-
* @note Inherits from Object, WorldObject
42+
* @note Inherits from Object, WorldLocation
4343
*/
4444
void export_worldobject_class()
4545
{
46-
bp::class_<WorldObject, bp::bases<Object>, boost::noncopyable> worldobject_class("WorldObject", bp::no_init);
46+
bp::class_<WorldObject, bp::bases<Object, WorldLocation>, boost::noncopyable> worldobject_class("WorldObject",
47+
bp::no_init);
4748

4849
// common
4950
worldobject_class.def("GetName", &WorldObject::GetName, bp::return_value_policy<bp::copy_const_reference>());
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include "PythonHeaders.h"
2+
#include "Position.h"
3+
4+
namespace bp = boost::python;
5+
6+
/**
7+
* @brief Position struct - 3D coordinates with orientation
8+
*/
9+
void export_position_struct()
10+
{
11+
bp::class_<Position> position_struct("Position", bp::no_init);
12+
13+
// coordinates and orientation
14+
position_struct.def("GetPositionX", &Position::GetPositionX);
15+
position_struct.def("GetPositionY", &Position::GetPositionY);
16+
position_struct.def("GetPositionZ", &Position::GetPositionZ);
17+
position_struct.def("GetOrientation", &Position::GetOrientation);
18+
19+
// distance helpers
20+
position_struct.def("GetExactDist2d",
21+
static_cast<float (Position::*)(float, float) const>(&Position::GetExactDist2d));
22+
position_struct.def("GetExactDist",
23+
static_cast<float (Position::*)(float, float, float) const>(&Position::GetExactDist));
24+
position_struct.def("GetExactDist2dSq",
25+
static_cast<float (Position::*)(float, float) const>(&Position::GetExactDist2dSq));
26+
position_struct.def("GetExactDistSq",
27+
static_cast<float (Position::*)(float, float, float) const>(&Position::GetExactDistSq));
28+
position_struct.def("GetExactDist2dTo",
29+
static_cast<float (Position::*)(Position const&) const>(&Position::GetExactDist2d));
30+
position_struct.def("GetExactDistTo",
31+
static_cast<float (Position::*)(Position const&) const>(&Position::GetExactDist));
32+
position_struct.def("GetExactDist2dSqTo",
33+
static_cast<float (Position::*)(Position const&) const>(&Position::GetExactDist2dSq));
34+
position_struct.def("GetExactDistSqTo",
35+
static_cast<float (Position::*)(Position const&) const>(&Position::GetExactDistSq));
36+
37+
// angle helpers
38+
position_struct.def("GetAngle", static_cast<float (Position::*)(float, float) const>(&Position::GetAngle));
39+
40+
// validity
41+
position_struct.def("IsPositionValid", &Position::IsPositionValid);
42+
}
43+
44+
/**
45+
* @brief WorldLocation class - Position with map context
46+
* @note Inherits from Position
47+
*/
48+
void export_worldlocation_class()
49+
{
50+
bp::class_<WorldLocation, bp::bases<Position>> worldlocation_class("WorldLocation", bp::no_init);
51+
52+
// map id accessors
53+
worldlocation_class.def("GetMapId", &WorldLocation::GetMapId);
54+
worldlocation_class.def("SetMapId", &WorldLocation::SetMapId);
55+
}

‎src/Bindings/PythonModule.cpp‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
CREATE_REGISTRY_SCOPE(Exports);
66

77
// Forward declarations into the Exports scope
8-
REGISTER_TO_SCOPE(Exports, export_unit_class, 20);
9-
REGISTER_TO_SCOPE(Exports, export_worldobject_class, 10);
10-
REGISTER_TO_SCOPE(Exports, export_player_class, 21);
11-
REGISTER_TO_SCOPE(Exports, export_game_constants, 1);
128
REGISTER_TO_SCOPE(Exports, export_hook_api, 0);
9+
REGISTER_TO_SCOPE(Exports, export_game_constants, 1);
1310
REGISTER_TO_SCOPE(Exports, export_object_class, 5);
11+
REGISTER_TO_SCOPE(Exports, export_position_struct, 5);
12+
REGISTER_TO_SCOPE(Exports, export_worldlocation_class, 10);
13+
REGISTER_TO_SCOPE(Exports, export_worldobject_class, 15);
14+
REGISTER_TO_SCOPE(Exports, export_unit_class, 20);
15+
REGISTER_TO_SCOPE(Exports, export_creature_class, 25);
16+
REGISTER_TO_SCOPE(Exports, export_gameobject_class, 25);
17+
REGISTER_TO_SCOPE(Exports, export_player_class, 25);
1418

1519
// Register module name with Python before Py_Initialize()
1620
extern "C" PyObject* PyInit_azerothcore();

0 commit comments

Comments
 (0)