-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaBindingsSystem.cpp
More file actions
248 lines (222 loc) · 14.7 KB
/
LuaBindingsSystem.cpp
File metadata and controls
248 lines (222 loc) · 14.7 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
// Make sure that binding definition files are always set to NOT use pre-compiled headers and conformance mode (/permissive) otherwise everything will be on fire!
#include "LuaBindingRegisterDefinitions.h"
#include "return_reference_to_policy.hpp"
using namespace RTE;
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Box) {
return luabind::class_<Box>("Box")
.def(luabind::constructor<>())
.def(luabind::constructor<const Vector&, const Vector&>())
.def(luabind::constructor<float, float, float, float>())
.def(luabind::constructor<const Vector&, float, float>())
.def(luabind::constructor<const Box&>())
.def(luabind::self == luabind::other<const Box&>())
.property("ClassName", &Box::GetClassName)
.property("Corner", &Box::GetCorner, &Box::SetCorner)
.property("Width", &Box::GetWidth, &Box::SetWidth)
.property("Height", &Box::GetHeight, &Box::SetHeight)
.property("Center", &Box::GetCenter, &Box::SetCenter)
.property("Area", &Box::GetArea)
.def("GetRandomPoint", &Box::GetRandomPoint)
.def("Unflip", &Box::Unflip)
.def("IsWithinBox", &Box::IsWithinBox)
.def("IsWithinBoxX", &Box::IsWithinBoxX)
.def("IsWithinBoxY", &Box::IsWithinBoxY)
.def("GetWithinBoxX", &Box::GetWithinBoxX)
.def("GetWithinBoxY", &Box::GetWithinBoxY)
.def("GetWithinBox", &Box::GetWithinBox)
.def("IntersectsBox", &Box::IntersectsBox);
}
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Controller) {
return luabind::class_<Controller>("Controller")
.def(luabind::constructor<>())
.property("InputMode", &Controller::GetInputMode, &Controller::SetInputMode)
.property("ControlledActor", &Controller::GetControlledActor, &Controller::SetControlledActor)
.property("Team", &Controller::GetTeam, &Controller::SetTeam)
.property("AnalogMove", &Controller::GetAnalogMove, &Controller::SetAnalogMove)
.property("AnalogAim", &Controller::GetAnalogAim, &Controller::SetAnalogAim)
.property("AnalogCursor", &Controller::GetAnalogCursor, &Controller::SetAnalogCursor)
.property("Player", &Controller::GetPlayer, &Controller::SetPlayer)
.property("MouseMovement", &Controller::GetMouseMovement)
.property("Disabled", &Controller::IsDisabled, &Controller::SetDisabled)
.def("IsPlayerControlled", &Controller::IsPlayerControlled)
.def("RelativeCursorMovement", &Controller::RelativeCursorMovement)
.def("IsMouseControlled", &Controller::IsMouseControlled)
.def("IsKeyboardOnlyControlled", &Controller::IsKeyboardOnlyControlled)
.def("IsGamepadControlled", &Controller::IsGamepadControlled)
.def("SetState", &Controller::SetState)
.def("IsState", &Controller::IsState)
.def("Override", &Controller::Override)
.enum_("ControlState")[luabind::value("PRIMARY_ACTION", ControlState::PRIMARY_ACTION),
luabind::value("SECONDARY_ACTION", ControlState::SECONDARY_ACTION),
luabind::value("MOVE_IDLE", ControlState::MOVE_IDLE),
luabind::value("MOVE_RIGHT", ControlState::MOVE_RIGHT),
luabind::value("MOVE_LEFT", ControlState::MOVE_LEFT),
luabind::value("MOVE_UP", ControlState::MOVE_UP),
luabind::value("MOVE_DOWN", ControlState::MOVE_DOWN),
luabind::value("MOVE_FAST", ControlState::MOVE_FAST),
luabind::value("BODY_JUMPSTART", ControlState::BODY_JUMPSTART),
luabind::value("BODY_JUMP", ControlState::BODY_JUMP),
luabind::value("BODY_CROUCH", ControlState::BODY_PRONE), // awful, but script compat
luabind::value("BODY_PRONE", ControlState::BODY_PRONE),
luabind::value("BODY_WALKCROUCH", ControlState::BODY_CROUCH),
luabind::value("AIM_UP", ControlState::AIM_UP),
luabind::value("AIM_DOWN", ControlState::AIM_DOWN),
luabind::value("AIM_SHARP", ControlState::AIM_SHARP),
luabind::value("WEAPON_FIRE", ControlState::WEAPON_FIRE),
luabind::value("WEAPON_RELOAD", ControlState::WEAPON_RELOAD),
luabind::value("WEAPON_RELOADHELD", ControlState::WEAPON_RELOADHELD),
luabind::value("PIE_MENU_OPENED", ControlState::PIE_MENU_OPENED),
luabind::value("PIE_MENU_ACTIVE", ControlState::PIE_MENU_ACTIVE),
luabind::value("WEAPON_CHANGE_NEXT", ControlState::WEAPON_CHANGE_NEXT),
luabind::value("WEAPON_CHANGE_PREV", ControlState::WEAPON_CHANGE_PREV),
luabind::value("WEAPON_PICKUP", ControlState::WEAPON_PICKUP),
luabind::value("WEAPON_DROP", ControlState::WEAPON_DROP),
luabind::value("WEAPON_PRIMARY_HOTKEY", ControlState::WEAPON_PRIMARY_HOTKEY),
luabind::value("WEAPON_AUXILIARY_HOTKEY", ControlState::WEAPON_AUXILIARY_HOTKEY),
luabind::value("ACTOR_PRIMARY_HOTKEY", ControlState::ACTOR_PRIMARY_HOTKEY),
luabind::value("ACTOR_AUXILIARY_HOTKEY", ControlState::ACTOR_AUXILIARY_HOTKEY),
luabind::value("WEAPON_PRIMARY_HOTKEYSTART", ControlState::WEAPON_PRIMARY_HOTKEYSTART),
luabind::value("WEAPON_AUXILIARY_HOTKEYSTART", ControlState::WEAPON_AUXILIARY_HOTKEYSTART),
luabind::value("ACTOR_PRIMARY_HOTKEYSTART", ControlState::ACTOR_PRIMARY_HOTKEYSTART),
luabind::value("ACTOR_AUXILIARY_HOTKEYSTART", ControlState::ACTOR_AUXILIARY_HOTKEYSTART),
luabind::value("ACTOR_NEXT", ControlState::ACTOR_NEXT),
luabind::value("ACTOR_PREV", ControlState::ACTOR_PREV),
luabind::value("ACTOR_BRAIN", ControlState::ACTOR_BRAIN),
luabind::value("ACTOR_NEXT_PREP", ControlState::ACTOR_NEXT_PREP),
luabind::value("ACTOR_PREV_PREP", ControlState::ACTOR_PREV_PREP),
luabind::value("HOLD_RIGHT", ControlState::HOLD_RIGHT),
luabind::value("HOLD_LEFT", ControlState::HOLD_LEFT),
luabind::value("HOLD_UP", ControlState::HOLD_UP),
luabind::value("HOLD_DOWN", ControlState::HOLD_DOWN),
luabind::value("PRESS_PRIMARY", ControlState::PRESS_PRIMARY),
luabind::value("PRESS_SECONDARY", ControlState::PRESS_SECONDARY),
luabind::value("PRESS_RIGHT", ControlState::PRESS_RIGHT),
luabind::value("PRESS_LEFT", ControlState::PRESS_LEFT),
luabind::value("PRESS_UP", ControlState::PRESS_UP),
luabind::value("PRESS_DOWN", ControlState::PRESS_DOWN),
luabind::value("RELEASE_PRIMARY", ControlState::RELEASE_PRIMARY),
luabind::value("RELEASE_SECONDARY", ControlState::RELEASE_SECONDARY),
luabind::value("PRESS_FACEBUTTON", ControlState::PRESS_FACEBUTTON),
luabind::value("RELEASE_FACEBUTTON", ControlState::RELEASE_FACEBUTTON),
luabind::value("SCROLL_UP", ControlState::SCROLL_UP),
luabind::value("SCROLL_DOWN", ControlState::SCROLL_DOWN),
luabind::value("DEBUG_ONE", ControlState::DEBUG_ONE),
luabind::value("CONTROLSTATECOUNT", ControlState::CONTROLSTATECOUNT)]
.enum_("InputMode")[luabind::value("CIM_DISABLED", Controller::InputMode::CIM_DISABLED),
luabind::value("CIM_PLAYER", Controller::InputMode::CIM_PLAYER),
luabind::value("CIM_AI", Controller::InputMode::CIM_AI),
luabind::value("CIM_NETWORK", Controller::InputMode::CIM_NETWORK),
luabind::value("CIM_INPUTMODECOUNT", Controller::InputMode::CIM_INPUTMODECOUNT)];
}
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, DataModule) {
return luabind::class_<DataModule>("DataModule")
.property("FileName", &DataModule::GetFileName)
.property("FriendlyName", &DataModule::GetFriendlyName)
.property("Author", &DataModule::GetAuthor)
.property("Description", &DataModule::GetDescription)
.property("Version", &DataModule::GetVersionNumber)
.property("IsFaction", &DataModule::IsFaction)
.property("IsMerchant", &DataModule::IsMerchant)
.def_readwrite("Presets", &DataModule::m_EntityList, luabind::return_stl_iterator);
}
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Timer) {
return luabind::class_<Timer>("Timer")
.def(luabind::constructor<>())
.def(luabind::constructor<double>())
.def(luabind::constructor<double, double>())
.property("StartRealTimeMS", &Timer::GetStartRealTimeMS, &Timer::SetStartRealTimeMS)
.property("ElapsedRealTimeS", &Timer::GetElapsedRealTimeS, &Timer::SetElapsedRealTimeS)
.property("ElapsedRealTimeMS", &Timer::GetElapsedRealTimeMS, &Timer::SetElapsedRealTimeMS)
.property("StartSimTimeMS", &Timer::GetStartSimTimeMS, &Timer::SetStartSimTimeMS)
.property("ElapsedSimTimeS", &Timer::GetElapsedSimTimeS, &Timer::SetElapsedSimTimeS)
.property("ElapsedSimTimeMS", &Timer::GetElapsedSimTimeMS, &Timer::SetElapsedSimTimeMS)
.property("RealTimeLimitProgress", &Timer::GetRealTimeLimitProgress, &Timer::SetRealTimeLimitProgress)
.property("SimTimeLimitProgress", &Timer::GetSimTimeLimitProgress, &Timer::SetSimTimeLimitProgress)
.def("Reset", &Timer::Reset)
.def("SetRealTimeLimitMS", &Timer::SetRealTimeLimitMS)
.def("SetRealTimeLimitS", &Timer::SetRealTimeLimitS)
.def("IsPastRealTimeLimit", &Timer::IsPastRealTimeLimit)
.def("LeftTillRealTimeLimitMS", &Timer::LeftTillRealTimeLimitMS)
.def("LeftTillRealTimeLimitS", &Timer::LeftTillRealTimeLimitS)
.def("LeftTillRealMS", &Timer::LeftTillRealMS)
.def("IsPastRealMS", &Timer::IsPastRealMS)
.def("AlternateReal", &Timer::AlternateReal)
.def("GetSimTimeLimitMS", &Timer::GetSimTimeLimitMS)
.def("SetSimTimeLimitMS", &Timer::SetSimTimeLimitMS)
.def("GetSimTimeLimitS", &Timer::GetSimTimeLimitS)
.def("SetSimTimeLimitS", &Timer::SetSimTimeLimitS)
.def("IsPastSimTimeLimit", &Timer::IsPastSimTimeLimit)
.def("LeftTillSimTimeLimitMS", &Timer::LeftTillSimTimeLimitMS)
.def("LeftTillSimTimeLimitS", &Timer::LeftTillSimTimeLimitS)
.def("LeftTillSimMS", &Timer::LeftTillSimMS)
.def("IsPastSimMS", &Timer::IsPastSimMS)
.def("AlternateSim", &Timer::AlternateSim);
}
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, Vector) {
return luabind::class_<Vector>("Vector")
.def(luabind::constructor<>())
.def(luabind::constructor<float, float>())
.def(luabind::self == luabind::other<const Vector&>())
.def(luabind::const_self + luabind::other<const Vector&>())
.def(luabind::const_self - luabind::other<const Vector&>())
.def(luabind::const_self * float())
.def(luabind::const_self / float())
.def(luabind::tostring(luabind::const_self))
.property("ClassName", &Vector::GetClassName)
.property("RoundedX", &Vector::GetRoundIntX)
.property("RoundedY", &Vector::GetRoundIntY)
.property("Rounded", &Vector::GetRounded)
.property("FlooredX", &Vector::GetFloorIntX)
.property("FlooredY", &Vector::GetFloorIntY)
.property("Floored", &Vector::GetFloored)
.property("CeilingedX", &Vector::GetCeilingIntX)
.property("CeilingedY", &Vector::GetCeilingIntY)
.property("Ceilinged", &Vector::GetCeilinged)
.property("Magnitude", &Vector::GetMagnitude)
.property("SqrMagnitude", &Vector::GetSqrMagnitude)
.property("Largest", &Vector::GetLargest)
.property("Smallest", &Vector::GetSmallest)
.property("Normalized", &Vector::GetNormalized)
.property("Perpendicular", &Vector::GetPerpendicular)
.property("AbsRadAngle", &Vector::GetAbsRadAngle, &Vector::SetAbsRadAngle)
.property("AbsDegAngle", &Vector::GetAbsDegAngle, &Vector::SetAbsDegAngle)
.def_readwrite("X", &Vector::m_X)
.def_readwrite("Y", &Vector::m_Y)
.def("MagnitudeIsGreaterThan", &Vector::MagnitudeIsGreaterThan)
.def("MagnitudeIsLessThan", &Vector::MagnitudeIsLessThan)
.def("SetMagnitude", &Vector::SetMagnitude, luabind::return_reference_to(_1))
.def("GetXFlipped", &Vector::GetXFlipped)
.def("GetYFlipped", &Vector::GetYFlipped)
.def("CapMagnitude", &Vector::CapMagnitude, luabind::return_reference_to(_1))
.def("ClampMagnitude", &Vector::ClampMagnitude, luabind::return_reference_to(_1))
.def("FlipX", &Vector::FlipX, luabind::return_reference_to(_1))
.def("FlipY", &Vector::FlipY, luabind::return_reference_to(_1))
.def("IsZero", &Vector::IsZero)
.def("IsOpposedTo", &Vector::IsOpposedTo)
.def("Dot", &Vector::Dot)
.def("Cross", &Vector::Cross)
.def("Round", &Vector::Round, luabind::return_reference_to(_1))
.def("ToHalf", &Vector::ToHalf, luabind::return_reference_to(_1))
.def("Floor", &Vector::Floor, luabind::return_reference_to(_1))
.def("Ceiling", &Vector::Ceiling, luabind::return_reference_to(_1))
.def("Normalize", &Vector::Normalize, luabind::return_reference_to(_1))
.def("Perpendicularize", &Vector::Perpendicularize, luabind::return_reference_to(_1))
.def("Reset", &Vector::Reset)
.def("RadRotate", &Vector::RadRotate, luabind::return_reference_to(_1))
.def("DegRotate", &Vector::DegRotate, luabind::return_reference_to(_1))
.def("GetRadRotatedCopy", &Vector::GetRadRotatedCopy)
.def("GetDegRotatedCopy", &Vector::GetDegRotatedCopy)
.def("AbsRotateTo", &Vector::AbsRotateTo, luabind::return_reference_to(_1))
.def("SetXY", &Vector::SetXY, luabind::return_reference_to(_1));
}
LuaBindingRegisterFunctionDefinitionForType(SystemLuaBindings, PathRequest) {
using namespace micropather;
return luabind::class_<PathRequest>("PathRequest")
.def_readonly("Path", &PathRequest::path, luabind::return_stl_iterator)
.def_readonly("PathLength", &PathRequest::pathLength)
.def_readonly("Status", &PathRequest::status)
.def_readonly("TotalCost", &PathRequest::totalCost)
.enum_("Status")[luabind::value("Solved", micropather::MicroPather::SOLVED),
luabind::value("NoSolution", micropather::MicroPather::NO_SOLUTION),
luabind::value("StartEndSame", micropather::MicroPather::START_END_SAME)];
}