forked from ElunaLuaEngine/Eluna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VehicleMethods.h
115 lines (107 loc) · 2.65 KB
/
VehicleMethods.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
* This program is free software licensed under GPL version 3
* Please see the included DOCS/LICENSE.md for more information
*/
#ifndef VEHICLEMETHODS_H
#define VEHICLEMETHODS_H
#ifndef CLASSIC
#ifndef TBC
/***
* Inherits all methods from: none
*/
namespace LuaVehicle
{
/**
* Returns true if the [Unit] passenger is on board
*
* @param [Unit] passenger
* @return bool isOnBoard
*/
int IsOnBoard(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#ifndef TRINITY
Eluna::Push(L, vehicle->HasOnBoard(passenger));
#else
Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
#endif
return 1;
}
/**
* Returns the [Vehicle]'s owner
*
* @return [Unit] owner
*/
int GetOwner(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
#ifndef TRINITY
Eluna::Push(L, vehicle->GetOwner());
#else
Eluna::Push(L, vehicle->GetBase());
#endif
return 1;
}
/**
* Returns the [Vehicle]'s entry
*
* @return uint32 entry
*/
int GetEntry(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
#ifndef TRINITY
Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID);
#else
Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID);
#endif
return 1;
}
/**
* Returns the [Vehicle]'s passenger in the specified seat
*
* @param int8 seat
* @return [Unit] passenger
*/
int GetPassenger(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
int8 seatId = Eluna::CHECKVAL<int8>(L, 2);
Eluna::Push(L, vehicle->GetPassenger(seatId));
return 1;
}
/**
* Adds [Unit] passenger to a specified seat in the [Vehicle]
*
* @param [Unit] passenger
* @param int8 seat
*/
int AddPassenger(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
int8 seatId = Eluna::CHECKVAL<int8>(L, 3);
#ifndef TRINITY
if (vehicle->CanBoard(passenger))
vehicle->Board(passenger, seatId);
#else
vehicle->AddPassenger(passenger, seatId);
#endif
return 0;
}
/**
* Removes [Unit] passenger from the [Vehicle]
*
* @param [Unit] passenger
*/
int RemovePassenger(Eluna* /*E*/, lua_State* L, Vehicle* vehicle)
{
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
#ifndef TRINITY
vehicle->UnBoard(passenger, false);
#else
vehicle->RemovePassenger(passenger);
#endif
return 0;
}
}
#endif // CLASSIC
#endif // TBC
#endif // VEHICLEMETHODS_H