-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathLuaAdapterDefinitions.h
More file actions
698 lines (624 loc) · 39.3 KB
/
LuaAdapterDefinitions.h
File metadata and controls
698 lines (624 loc) · 39.3 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#pragma once
#include "LuabindDefinitions.h"
#include "ActivityMan.h"
#include "AudioMan.h"
#include "MusicMan.h"
#include "CameraMan.h"
#include "ConsoleMan.h"
#include "FrameMan.h"
#include "MetaMan.h"
#include "MovableMan.h"
#include "PerformanceMan.h"
#include "PostProcessMan.h"
#include "PresetMan.h"
#include "PrimitiveMan.h"
#include "SceneMan.h"
#include "SettingsMan.h"
#include "TimerMan.h"
#include "UInputMan.h"
#include "Box.h"
#include "Controller.h"
#include "DataModule.h"
#include "GraphicalPrimitive.h"
#include "PathFinder.h"
#include "GUIBanner.h"
#include "BuyMenuGUI.h"
#include "SceneEditorGUI.h"
#include "GameActivity.h"
#include "GAScripted.h"
#include "ActorEditor.h"
#include "Entity.h"
#include "ACDropShip.h"
#include "ACrab.h"
#include "ACraft.h"
#include "ACRocket.h"
#include "Actor.h"
#include "ADoor.h"
#include "AEmitter.h"
#include "AEJetpack.h"
#include "AHuman.h"
#include "Arm.h"
#include "AtomGroup.h"
#include "Attachable.h"
#include "Deployment.h"
#include "Emission.h"
#include "Gib.h"
#include "GlobalScript.h"
#include "HDFirearm.h"
#include "HeldDevice.h"
#include "Leg.h"
#include "LimbPath.h"
#include "Magazine.h"
#include "Material.h"
#include "MetaPlayer.h"
#include "MOSParticle.h"
#include "MOPixel.h"
#include "MOSprite.h"
#include "MOSRotating.h"
#include "MovableObject.h"
#include "PEmitter.h"
#include "Round.h"
#include "Scene.h"
#include "SceneObject.h"
#include "SLBackground.h"
#include "SLTerrain.h"
#include "SoundContainer.h"
#include "TerrainObject.h"
#include "TDExplosive.h"
#include "ThrownDevice.h"
#include "Turret.h"
#include "PieMenu.h"
#include "PieSlice.h"
#include "System/MicroPather/micropather.h"
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
struct lua_State;
namespace RTE {
class LuabindObjectWrapper;
#pragma region Entity Lua Adapter Macros
struct LuaAdaptersEntityCreate {
/// Convenience macro to generate preset clone-create adapter functions that will return the exact pre-cast types, so we don't have to do: myNewActor = ToActor(PresetMan:GetPreset("AHuman", "Soldier Light", "All")):Clone()
/// But can instead do: myNewActor = CreateActor("Soldier Light", "All");
/// Or even: myNewActor = CreateActor("Soldier Light");
/// Or for a randomly selected Preset within a group: myNewActor = RandomActor("Light Troops");
#define LuaEntityCreateFunctionsDeclarationsForType(TYPE) \
static TYPE* Create##TYPE(std::string preseName, std::string moduleName); \
static TYPE* Create##TYPE(std::string preset); \
static TYPE* Random##TYPE(std::string groupName, int moduleSpaceID); \
static TYPE* Random##TYPE(std::string groupName, std::string dataModuleName); \
static TYPE* Random##TYPE(std::string groupName)
LuaEntityCreateFunctionsDeclarationsForType(SoundContainer);
LuaEntityCreateFunctionsDeclarationsForType(Attachable);
LuaEntityCreateFunctionsDeclarationsForType(Arm);
LuaEntityCreateFunctionsDeclarationsForType(Leg);
LuaEntityCreateFunctionsDeclarationsForType(AEmitter);
LuaEntityCreateFunctionsDeclarationsForType(AEJetpack);
LuaEntityCreateFunctionsDeclarationsForType(Turret);
LuaEntityCreateFunctionsDeclarationsForType(Actor);
LuaEntityCreateFunctionsDeclarationsForType(ADoor);
LuaEntityCreateFunctionsDeclarationsForType(AHuman);
LuaEntityCreateFunctionsDeclarationsForType(ACrab);
LuaEntityCreateFunctionsDeclarationsForType(ACraft);
LuaEntityCreateFunctionsDeclarationsForType(ACDropShip);
LuaEntityCreateFunctionsDeclarationsForType(ACRocket);
LuaEntityCreateFunctionsDeclarationsForType(MOSParticle);
LuaEntityCreateFunctionsDeclarationsForType(MOSRotating);
LuaEntityCreateFunctionsDeclarationsForType(MOPixel);
LuaEntityCreateFunctionsDeclarationsForType(Scene);
LuaEntityCreateFunctionsDeclarationsForType(HeldDevice);
LuaEntityCreateFunctionsDeclarationsForType(Round);
LuaEntityCreateFunctionsDeclarationsForType(Magazine);
LuaEntityCreateFunctionsDeclarationsForType(HDFirearm);
LuaEntityCreateFunctionsDeclarationsForType(ThrownDevice);
LuaEntityCreateFunctionsDeclarationsForType(TDExplosive);
LuaEntityCreateFunctionsDeclarationsForType(TerrainObject);
LuaEntityCreateFunctionsDeclarationsForType(PEmitter);
LuaEntityCreateFunctionsDeclarationsForType(PieSlice);
LuaEntityCreateFunctionsDeclarationsForType(PieMenu);
};
struct LuaAdaptersEntityClone {
/// Convenience macro to generate a preset clone adapter function for a type.
#define LuaEntityCloneFunctionDeclarationForType(TYPE) \
static TYPE* Clone##TYPE(const TYPE* thisEntity)
LuaEntityCloneFunctionDeclarationForType(Entity);
LuaEntityCloneFunctionDeclarationForType(SoundContainer);
LuaEntityCloneFunctionDeclarationForType(SceneObject);
LuaEntityCloneFunctionDeclarationForType(MovableObject);
LuaEntityCloneFunctionDeclarationForType(Attachable);
LuaEntityCloneFunctionDeclarationForType(Arm);
LuaEntityCloneFunctionDeclarationForType(Leg);
LuaEntityCloneFunctionDeclarationForType(Emission);
LuaEntityCloneFunctionDeclarationForType(AEmitter);
LuaEntityCloneFunctionDeclarationForType(AEJetpack);
LuaEntityCloneFunctionDeclarationForType(Turret);
LuaEntityCloneFunctionDeclarationForType(Actor);
LuaEntityCloneFunctionDeclarationForType(ADoor);
LuaEntityCloneFunctionDeclarationForType(AHuman);
LuaEntityCloneFunctionDeclarationForType(ACrab);
LuaEntityCloneFunctionDeclarationForType(ACraft);
LuaEntityCloneFunctionDeclarationForType(ACDropShip);
LuaEntityCloneFunctionDeclarationForType(ACRocket);
LuaEntityCloneFunctionDeclarationForType(MOSParticle);
LuaEntityCloneFunctionDeclarationForType(MOSRotating);
LuaEntityCloneFunctionDeclarationForType(MOPixel);
LuaEntityCloneFunctionDeclarationForType(Scene);
LuaEntityCloneFunctionDeclarationForType(HeldDevice);
LuaEntityCloneFunctionDeclarationForType(Round);
LuaEntityCloneFunctionDeclarationForType(Magazine);
LuaEntityCloneFunctionDeclarationForType(HDFirearm);
LuaEntityCloneFunctionDeclarationForType(ThrownDevice);
LuaEntityCloneFunctionDeclarationForType(TDExplosive);
LuaEntityCloneFunctionDeclarationForType(TerrainObject);
LuaEntityCloneFunctionDeclarationForType(PEmitter);
LuaEntityCloneFunctionDeclarationForType(PieSlice);
LuaEntityCloneFunctionDeclarationForType(PieMenu);
};
struct LuaAdaptersEntityCast {
/// Convenience macro to generate type casting adapter functions for a type.
#define LuaEntityCastFunctionsDeclarationsForType(TYPE) \
static TYPE* To##TYPE(Entity* entity); \
static const TYPE* ToConst##TYPE(const Entity* entity); \
static bool Is##TYPE(Entity* entity); \
static LuabindObjectWrapper* ToLuabindObject##TYPE(Entity* entity, lua_State* luaState)
static std::unordered_map<std::string, std::function<LuabindObjectWrapper*(Entity*, lua_State*)>> s_EntityToLuabindObjectCastFunctions; //!< Map of preset names to casting methods for ensuring objects are downcast properly when passed into Lua.
LuaEntityCastFunctionsDeclarationsForType(Entity);
LuaEntityCastFunctionsDeclarationsForType(SoundContainer);
LuaEntityCastFunctionsDeclarationsForType(SceneObject);
LuaEntityCastFunctionsDeclarationsForType(MovableObject);
LuaEntityCastFunctionsDeclarationsForType(Attachable);
LuaEntityCastFunctionsDeclarationsForType(Arm);
LuaEntityCastFunctionsDeclarationsForType(Leg);
LuaEntityCastFunctionsDeclarationsForType(Emission);
LuaEntityCastFunctionsDeclarationsForType(AEmitter);
LuaEntityCastFunctionsDeclarationsForType(AEJetpack);
LuaEntityCastFunctionsDeclarationsForType(Turret);
LuaEntityCastFunctionsDeclarationsForType(Actor);
LuaEntityCastFunctionsDeclarationsForType(ADoor);
LuaEntityCastFunctionsDeclarationsForType(AHuman);
LuaEntityCastFunctionsDeclarationsForType(ACrab);
LuaEntityCastFunctionsDeclarationsForType(ACraft);
LuaEntityCastFunctionsDeclarationsForType(ACDropShip);
LuaEntityCastFunctionsDeclarationsForType(ACRocket);
LuaEntityCastFunctionsDeclarationsForType(MOSParticle);
LuaEntityCastFunctionsDeclarationsForType(MOSRotating);
LuaEntityCastFunctionsDeclarationsForType(MOPixel);
LuaEntityCastFunctionsDeclarationsForType(MOSprite);
LuaEntityCastFunctionsDeclarationsForType(Scene);
LuaEntityCastFunctionsDeclarationsForType(Deployment);
LuaEntityCastFunctionsDeclarationsForType(GameActivity);
LuaEntityCastFunctionsDeclarationsForType(GlobalScript);
LuaEntityCastFunctionsDeclarationsForType(GAScripted);
LuaEntityCastFunctionsDeclarationsForType(HeldDevice);
LuaEntityCastFunctionsDeclarationsForType(Round);
LuaEntityCastFunctionsDeclarationsForType(Magazine);
LuaEntityCastFunctionsDeclarationsForType(HDFirearm);
LuaEntityCastFunctionsDeclarationsForType(ThrownDevice);
LuaEntityCastFunctionsDeclarationsForType(TDExplosive);
LuaEntityCastFunctionsDeclarationsForType(TerrainObject);
LuaEntityCastFunctionsDeclarationsForType(PEmitter);
LuaEntityCastFunctionsDeclarationsForType(PieSlice);
LuaEntityCastFunctionsDeclarationsForType(PieMenu);
};
struct LuaAdaptersPropertyOwnershipSafetyFaker {
/// Special handling for passing ownership through properties. If you try to pass null to this normally, LuaJIT crashes.
/// This handling avoids that, and is a bit safer since there's no actual ownership transfer from Lua to C++.
#define LuaPropertyOwnershipSafetyFakerFunctionDeclaration(OBJECTTYPE, PROPERTYTYPE, SETTERFUNCTION) \
static void OBJECTTYPE##SETTERFUNCTION(OBJECTTYPE* luaSelfObject, PROPERTYTYPE* objectToSet)
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(MOSRotating, SoundContainer, SetGibSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Attachable, AEmitter, SetBreakWound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Attachable, AEmitter, SetParentBreakWound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AEmitter, Attachable, SetFlash);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AEmitter, SoundContainer, SetEmissionSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AEmitter, SoundContainer, SetBurstSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AEmitter, SoundContainer, SetEndSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ADoor, Attachable, SetDoor);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Arm, HeldDevice, SetHeldDevice);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Leg, Attachable, SetFoot);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, PieMenu, SetPieMenu);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, SoundContainer, SetBodyHitSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, SoundContainer, SetAlarmSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, SoundContainer, SetPainSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, SoundContainer, SetDeathSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Actor, SoundContainer, SetDeviceSwitchSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ADoor, SoundContainer, SetDoorMoveStartSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ADoor, SoundContainer, SetDoorMoveSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ADoor, SoundContainer, SetDoorDirectionChangeSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ADoor, SoundContainer, SetDoorMoveEndSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Attachable, SetHead);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, AEJetpack, SetJetpack);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Arm, SetFGArm);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Arm, SetBGArm);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Leg, SetFGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Leg, SetBGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Attachable, SetFGFoot);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, Attachable, SetBGFoot);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(AHuman, SoundContainer, SetStrideSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, Turret, SetTurret);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, AEJetpack, SetJetpack);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, Leg, SetLeftFGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, Leg, SetLeftBGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, Leg, SetRightFGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, Leg, SetRightBGLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACrab, SoundContainer, SetStrideSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(Turret, HeldDevice, SetFirstMountedDevice);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACraft, SoundContainer, SetHatchOpenSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACraft, SoundContainer, SetHatchCloseSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACraft, SoundContainer, SetCrashSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, AEmitter, SetRightThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, AEmitter, SetLeftThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, AEmitter, SetURightThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, AEmitter, SetULeftThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, Attachable, SetRightHatch);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACDropShip, Attachable, SetLeftHatch);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, Leg, SetRightLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, Leg, SetLeftLeg);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, AEmitter, SetMainThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, AEmitter, SetLeftThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, AEmitter, SetRightThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, AEmitter, SetULeftThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(ACRocket, AEmitter, SetURightThruster);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, Magazine, SetMagazine);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, Attachable, SetFlash);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetPreFireSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetFireSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetFireEchoSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetActiveSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetDeactivationSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetEmptySound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetReloadStartSound);
LuaPropertyOwnershipSafetyFakerFunctionDeclaration(HDFirearm, SoundContainer, SetReloadEndSound);
};
#pragma endregion
#pragma region Entity Lua Adapters
struct LuaAdaptersEntity {
// TODO this is a temporary fix for lua PresetName setting causing scripts to have to rerun. It should be replaced with a DisplayName property someday.
static void SetPresetName(Entity* luaSelfObject, const std::string& presetName);
};
#pragma endregion
#pragma region Scene Lua Adapters
struct LuaAdaptersScene {
static int CalculatePath1(Scene* luaSelfObject, const Vector& start, const Vector& end, float jumpHeight, float digStrength) {
return CalculatePath(luaSelfObject, start, end, jumpHeight, digStrength, Activity::Teams::NoTeam);
}
static int CalculatePath(Scene* luaSelfObject, const Vector& start, const Vector& end, float jumpHeight, float digStrength, Activity::Teams team);
static void CalculatePathAsync1(Scene* luaSelfObject, const luabind::object& callback, const Vector& start, const Vector& end, float jumpHeight, float digStrength) {
return CalculatePathAsync(luaSelfObject, callback, start, end, jumpHeight, digStrength, Activity::Teams::NoTeam);
}
static void CalculatePathAsync(Scene* luaSelfObject, const luabind::object& callback, const Vector& start, const Vector& end, float jumpHeight, float digStrength, Activity::Teams team);
};
#pragma endregion
#pragma region Actor Lua Adapters
struct LuaAdaptersActor {
static std::vector<Vector>* GetSceneWaypoints(Actor* luaSelfObject);
};
#pragma endregion
#pragma region AHuman Lua Adapters
struct LuaAdaptersAHuman {
static void ReloadFirearms(AHuman* luaSelfObject);
};
#pragma endregion
#pragma region Attachable Lua Adapters
struct LuaAdaptersAttachable {
static Attachable* RemoveFromParent1(Attachable* luaSelfObject);
static Attachable* RemoveFromParent2(Attachable* luaSelfObject, bool addToMovableMan, bool addBreakWounds);
};
#pragma endregion
#pragma region GlobalScript Lua Adapters
struct LuaAdaptersGlobalScript {
static void Deactivate(GlobalScript* luaSelfObject);
};
#pragma endregion
#pragma region Activity Lua Adapters
struct LuaAdaptersActivity {
static void SendMessage1(Activity* luaSelfObject, const std::string& message);
static void SendMessage2(Activity* luaSelfObject, const std::string& message, luabind::object context);
};
#pragma endregion
#pragma region MovableObject Lua Adapters
struct LuaAdaptersMovableObject {
static bool HasScript(MovableObject* luaSelfObject, const std::string& scriptPath);
static bool AddScript(MovableObject* luaSelfObject, const std::string& scriptPath);
static bool EnableScript(MovableObject* luaSelfObject, const std::string& scriptPath);
static bool DisableScript1(MovableObject* luaSelfObject);
static bool DisableScript2(MovableObject* luaSelfObject, const std::string& scriptPath);
static void SendMessage1(MovableObject* luaSelfObject, const std::string& message);
static void SendMessage2(MovableObject* luaSelfObject, const std::string& message, luabind::object context);
};
#pragma endregion
#pragma region MOSRotating Lua Adapters
struct LuaAdaptersMOSRotating {
static void GibThis(MOSRotating* luaSelfObject);
static std::vector<AEmitter*>* GetWounds1(const MOSRotating* luaSelfObject);
static std::vector<AEmitter*>* GetWounds2(const MOSRotating* luaSelfObject, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables);
// Need a seperate implementation function without the return so we can safely recurse.
static void GetWoundsImpl(const MOSRotating* luaSelfObject, bool includePositiveDamageAttachables, bool includeNegativeDamageAttachables, bool includeNoDamageAttachables, std::vector<AEmitter*>& wounds);
};
#pragma endregion
#pragma region BuyMenuGUI Lua Adapters
struct LuaAdaptersBuyMenuGUI {
static std::list<SceneObject*>* GetOrderList(const BuyMenuGUI* luaSelfObject);
};
#pragma endregion
#pragma region PieMenu Lua Adapters
struct LuaAdaptersPieMenu {
static int GetPieCommand(PieMenu* luaSelfObject);
static bool AddPieSlice(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource);
static bool AddPieSliceIfPresetNameIsUnique1(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource);
static bool AddPieSliceIfPresetNameIsUnique2(PieMenu* luaSelfObject, PieSlice* pieSliceToAdd, const Entity* pieSliceOriginalSource, bool onlyCheckPieSlicesWithSameOriginalSource);
};
#pragma endregion
#pragma region PieSlice Lua Adapters
struct LuaAdaptersPieSlice {
static int GetType(PieSlice* luaSelfObject);
};
#pragma endregion
#pragma region SceneObject Lua Adapters
struct LuaAdaptersSceneObject {
static float GetTotalValue(const SceneObject* luaSelfObject, int nativeModule, float foreignMult);
static int GetBuyableMode(const SceneObject* luaSelfObject);
};
#pragma endregion
#pragma region Turret Lua Adapters
struct LuaAdaptersTurret {
static void AddMountedFirearm(Turret* luaSelfObject, HDFirearm* newMountedDevice);
};
#pragma endregion
#pragma region MovableMan Lua Adapters
struct LuaAdaptersMovableMan {
/// Adds the given MovableObject to MovableMan if it doesn't already exist in there, or prints an error if it does.
/// @param movableMan A reference to MovableMan, provided by Lua.
/// @param movableObject A pointer to the MovableObject to be added.
static void AddMO(MovableMan& movableMan, MovableObject* movableObject);
/// Adds the given Actor to MovableMan if it doesn't already exist in there, or prints an error if it does.
/// @param movableMan A reference to MovableMan, provided by Lua.
/// @param actor A pointer to the Actor to be added.
static void AddActor(MovableMan& movableMan, Actor* actor);
/// Adds the given item MovableObject (generally a HeldDevice) to MovableMan if it doesn't already exist in there, or prints an error if it does.
/// @param movableMan A reference to MovableMan, provided by Lua.
/// @param item A pointer to the item to be added.
static void AddItem(MovableMan& movableMan, HeldDevice* item);
/// Adds the given particle MovableObject to MovableMan if it doesn't already exist in there, or prints an error if it does.
/// @param movableMan A reference to MovableMan, provided by Lua.
/// @param particle A pointer to the particle to be added.
static void AddParticle(MovableMan& movableMan, MovableObject* particle);
static void SendGlobalMessage1(MovableMan& movableMan, const std::string& message);
static void SendGlobalMessage2(MovableMan& movableMan, const std::string& message, luabind::object context);
};
#pragma endregion
#pragma region MusicMan Lua Adapters
struct LuaAdaptersMusicMan {
static bool PlayDynamicSong1(MusicMan& musicMan, const std::string& songName);
static bool PlayDynamicSong2(MusicMan& musicMan, const std::string& songName, const std::string& songSectionType);
static bool PlayDynamicSong3(MusicMan& musicMan, const std::string& songName, const std::string& songSectionType, bool playImmediately);
static bool PlayDynamicSong4(MusicMan& musicMan, const std::string& songName, const std::string& songSectionType, bool playImmediately, bool playTransition);
static bool PlayDynamicSong5(MusicMan& musicMan, const std::string& songName, const std::string& songSectionType, bool playImmediately, bool playTransition, bool smoothFade);
static bool SetNextDynamicSongSection1(MusicMan& musicMan, const std::string& songSectionType);
static bool SetNextDynamicSongSection2(MusicMan& musicMan, const std::string& songSectionType, bool playImmediately);
static bool SetNextDynamicSongSection3(MusicMan& musicMan, const std::string& songSectionType, bool playImmediately, bool playTransition);
static bool SetNextDynamicSongSection4(MusicMan& musicMan, const std::string& songSectionType, bool playImmediately, bool playTransition, bool smoothFade);
static bool CyclePlayingSoundContainers1(MusicMan& musicMan);
static bool CyclePlayingSoundContainers2(MusicMan& musicMan, bool smoothFade);
static bool EndDynamicMusic1(MusicMan& musicMan);
static bool EndDynamicMusic2(MusicMan& musicMan, bool fadeOutCurrent);
};
#pragma endregion
#pragma region TimerMan Lua Adapters
struct LuaAdaptersTimerMan {
/// Gets the current number of ticks that the simulation should be updating with. Lua can't handle int64 (or long long apparently) so we'll expose this specialized function.
/// @return The current fixed delta time that the simulation should be updating with, in ticks.
static double GetDeltaTimeTicks(const TimerMan& timerMan);
/// Gets the number of ticks per second. Lua can't handle int64 (or long long apparently) so we'll expose this specialized function.
/// @return The number of ticks per second.
static double GetTicksPerSecond(const TimerMan& timerMan);
};
#pragma endregion
#pragma region UInputMan Lua Adapters
struct LuaAdaptersUInputMan {
/// Gets whether a mouse button is being held down right now.
/// @param whichButton Which button to check for.
/// @return Whether the mouse button is held or not.
static bool MouseButtonHeld(const UInputMan& uinputMan, int whichButton);
/// Gets whether a mouse button was pressed between the last update and the one previous to it.
/// @param whichButton Which button to check for.
/// @return Whether the mouse button is pressed or not.
static bool MouseButtonPressed(const UInputMan& uinputMan, int whichButton);
/// Gets whether a mouse button was released between the last update and the one previous to it.
/// @param whichButton Which button to check for.
/// @return Whether the mouse button is released or not.
static bool MouseButtonReleased(const UInputMan& uinputMan, int whichButton);
};
#pragma endregion
#pragma region PresetMan Lua Adapters
struct LuaAdaptersPresetMan {
/// Reloads the specified Entity preset in PresetMan.
/// @param presetName The preset name of the Entity to reload.
/// @param className The class name of the Entity to reload.
/// @param moduleName The module name of the Entity to reload.
/// @return Whether or not the Entity was reloaded.
static bool ReloadEntityPreset1(PresetMan& presetMan, const std::string& presetName, const std::string& className, const std::string& moduleName);
/// Reloads the specified Entity preset in PresetMan.
/// @param presetName The preset name of the Entity to reload.
/// @param className The class name of the Entity to reload.
/// @return Whether or not the Entity was reloaded.
static bool ReloadEntityPreset2(PresetMan& presetMan, const std::string& presetName, const std::string& className);
/// Gets a list all previously read in (defined) Entities which are associated with a specific group.
/// @param group The group to look for. "All" will look in all.
/// @param type The name of the least common denominator type of the Entities you want. "All" will look at all types.
/// @param whichModule Whether to only get those of one specific DataModule (0-n), or all (-1).
/// @return The list of all Entities with the given group and type in the module.
static std::list<Entity*>* GetAllEntitiesOfGroup(PresetMan& presetMan, const std::string& group, const std::string& type, int whichModule);
static std::list<Entity*>* GetAllEntitiesOfGroup2(PresetMan& presetMan, const std::string& group, const std::string& type) { return GetAllEntitiesOfGroup(presetMan, group, type, -1); }
static std::list<Entity*>* GetAllEntitiesOfGroup3(PresetMan& presetMan, const std::string& group) { return GetAllEntitiesOfGroup2(presetMan, group, "All"); }
/// Gets a list all previously read in (defined) Entities.
/// @return The list of all Entities.
static std::list<Entity*>* GetAllEntities(PresetMan& presetMan) { return GetAllEntitiesOfGroup3(presetMan, "All"); }
};
#pragma endregion
#pragma region SceneMan Lua Adapters
struct LuaAdaptersSceneMan {
/// Traces along a vector and returns MOID of the first non-ignored
/// non-NoMOID MO encountered. If a non-air terrain pixel is encountered
/// first, g_NoMOID will be returned.
/// @param start The starting position.
/// @param ray The vector to trace along.
/// @param ignoreMOIDs A vector of MOIDs to ignore. Any child MO's of this MOID will also be ignored. (default: g_NoMOID)
/// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam)
/// team which also has team ignoring enabled itself.
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
/// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false)
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
/// for optimization reasons. 0 = every pixel is checked.
/// @return The MOID of the hit non-ignored MO, or g_NoMOID if terrain or no MO was hit.
static MOID CastMORay1(SceneMan& sceneMan, const Vector& start, const Vector& ray, const luabind::object& ignoreMOIDs, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0);
/// Traces along a vector and returns MOID of the first non-ignored
/// non-NoMOID MO encountered. If a non-air terrain pixel is encountered
/// first, g_NoMOID will be returned.
/// @param start The starting position.
/// @param ray The vector to trace along.
/// @param ignoreMOID An MOID to ignore. Any child MO's of this MOID will also be ignored. (default: g_NoMOID)
/// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam)
/// team which also has team ignoring enabled itself.
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
/// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false)
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
/// for optimization reasons. 0 = every pixel is checked.
/// @return The MOID of the hit non-ignored MO, or g_NoMOID if terrain or no MO was hit.
static MOID CastMORay2(SceneMan& sceneMan, const Vector& start, const Vector& ray, MOID ignoreMOID = g_NoMOID, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0);
/// Traces along a vector and returns a vector of all MOs encountered.
/// @param start The starting position.
/// @param ray The vector to trace along.
/// @param ignoreMOIDs A vector of MOIDs to ignore. Any child MOs of an MOID will also be ignored. (default: g_NoMOID)
/// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific team (default: Activity::NoTeam)
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
/// @param ignoreAllTerrain Whether to ignore all terrain hits or not. (default: false)
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
/// for optimization reasons. 0 = every pixel is checked.
/// @return A vector of pointers to all MovableObjects met along the ray, who aren't ignored.
static const std::vector<MovableObject*>* CastAllMOsRay(SceneMan& sceneMan, const Vector& start, const Vector& ray, const luabind::object& ignoreMOIDs, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, bool ignoreAllTerrain = false, int skip = 0);
/// Traces along a vector and returns the length of how far the trace went
/// without hitting any non-ignored terrain material or MOID at all.
/// @param start The starting position.
/// @param ray The vector to trace along.
/// @param obstaclePos A reference to the vector screen will be filled out with the absolute
/// location of the first obstacle, or the end of the ray if none was hit.
/// @param freePos A reference to the vector screen will be filled out with the absolute
/// location of the last free position before hitting an obstacle, or the
/// end of the ray if none was hit. This is only altered if thre are any
/// free pixels encountered.
/// @param ignoreMOIDs A vector of MOIDs to ignore. Any child MO's of an MOID will also be ignored. (default: g_NoMOID)
/// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam)
/// team which also has team ignoring enabled itself.
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
/// for optimization reasons. 0 = every pixel is checked.
/// @return How far along, in pixel units, the ray the pixel of any obstacle was
/// encountered. If no pixel of the right material was found, < 0 is returned.
/// If an obstacle on the starting position was encountered, 0 is returned.
static float CastObstacleRay1(SceneMan& sceneMan, const Vector& start, const Vector& ray, Vector& obstaclePos, Vector& freePos, const luabind::object& ignoreMOIDs, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, int skip = 0);
/// Traces along a vector and returns the length of how far the trace went
/// without hitting any non-ignored terrain material or MOID at all.
/// @param start The starting position.
/// @param ray The vector to trace along.
/// @param obstaclePos A reference to the vector screen will be filled out with the absolute
/// location of the first obstacle, or the end of the ray if none was hit.
/// @param freePos A reference to the vector screen will be filled out with the absolute
/// location of the last free position before hitting an obstacle, or the
/// end of the ray if none was hit. This is only altered if thre are any
/// free pixels encountered.
/// @param ignoreMOID An MOID to ignore. Any child MOs of this MOID will also be ignored. (default: g_NoMOID)
/// @param ignoreTeam To enable ignoring of all MOIDs associated with an object of a specific (default: Activity::NoTeam)
/// team which also has team ignoring enabled itself.
/// @param ignoreMaterial A specific material ID to ignore hits with. (default: 0)
/// @param skip For every pixel checked along the line, how many to skip between them (default: 0)
/// for optimization reasons. 0 = every pixel is checked.
/// @return How far along, in pixel units, the ray the pixel of any obstacle was
/// encountered. If no pixel of the right material was found, < 0 is returned.
/// If an obstacle on the starting position was encountered, 0 is returned.
static float CastObstacleRay2(SceneMan& sceneMan, const Vector& start, const Vector& ray, Vector& obstaclePos, Vector& freePos, MOID ignoreMOID = g_NoMOID, int ignoreTeam = Activity::NoTeam, unsigned char ignoreMaterial = 0, int skip = 0);
/// Takes a Box and returns a list of Boxes that describe the Box, wrapped appropriately for the current Scene.
/// @param boxToWrap The Box to wrap.
/// @return A list of Boxes that make up the Box to wrap, wrapped appropriately for the current Scene.
static const std::list<Box>* WrapBoxes(SceneMan& sceneMan, const Box& boxToWrap);
};
#pragma endregion
#pragma region PrimitiveMan Lua Adapters
struct LuaAdaptersPrimitiveMan {
/// Schedule to draw a polygon primitive.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param centerPos Position of primitive's center in Scene coordinates.
/// @param color Color to draw primitive with.
/// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position.
static void DrawPolygonPrimitive(PrimitiveMan& primitiveMan, const Vector& centerPos, int color, const luabind::object& verticesTable);
/// Schedule to draw a polygon primitive visible only to a specified player.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param player Player screen to draw primitive on.
/// @param centerPos Position of primitive's center in Scene coordinates.
/// @param color Color to draw primitive with.
/// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position.
static void DrawPolygonPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& centerPos, int color, const luabind::object& verticesTable);
/// Schedule to draw a filled polygon primitive.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param startPos Start position of the primitive in Scene coordinates.
/// @param color Color to draw primitive with.
/// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position.
static void DrawPolygonFillPrimitive(PrimitiveMan& primitiveMan, const Vector& startPos, int color, const luabind::object& verticesTable);
/// Schedule to draw a filled polygon primitive visible only to a specified player.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param player Player screen to draw primitive on.
/// @param startPos Start position of the primitive in Scene coordinates.
/// @param color Color to draw primitive with.
/// @param verticesTable A Lua table that contains the positions of the primitive's vertices, relative to the center position.
static void DrawPolygonFillPrimitiveForPlayer(PrimitiveMan& primitiveMan, int player, const Vector& startPos, int color, const luabind::object& verticesTable);
/// Schedules to draw multiple primitives of varying type with transparency enabled.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param transValue The transparency value the primitives should be drawn at. From 0 (opaque) to 100 (transparent).
/// @param primitivesTable A Lua table of primitives to schedule drawing for.
static void DrawPrimitivesWithTransparency(PrimitiveMan& primitiveMan, int transValue, const luabind::object& primitivesTable);
/// Schedule to draw multiple primitives of varying type with blending enabled.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param blendMode The blending mode the primitives should be drawn with. See DrawBlendMode enumeration.
/// @param blendAmount The blending amount for all the channels. 0-100.
/// @param primitivesTable A Lua table of primitives to schedule drawing for.
static void DrawPrimitivesWithBlending(PrimitiveMan& primitiveMan, int blendMode, int blendAmount, const luabind::object& primitivesTable);
/// Schedule to draw multiple primitives of varying type with blending enabled.
/// @param primitiveMan A reference to PrimitiveMan, provided by Lua.
/// @param blendMode The blending mode the primitives should be drawn with. See DrawBlendMode enumeration.
/// @param blendAmountR The blending amount for the Red channel. 0-100.
/// @param blendAmountG The blending amount for the Green channel. 0-100.
/// @param blendAmountB The blending amount for the Blue channel. 0-100.
/// @param blendAmountA The blending amount for the Alpha channel. 0-100.
/// @param primitivesTable A Lua table of primitives to schedule drawing for.
static void DrawPrimitivesWithBlendingPerChannel(PrimitiveMan& primitiveMan, int blendMode, int blendAmountR, int blendAmountG, int blendAmountB, int blendAmountA, const luabind::object& primitivesTable);
};
#pragma endregion
#pragma region Utility Lua Adapters
struct LuaAdaptersUtility {
/// Gets the ratio between the physics engine's meters and on-screen pixels.
/// @return A float describing the current MPP ratio.
static float GetMPP();
/// Gets the ratio between on-screen pixels and the physics engine's meters.
/// @return A float describing the current PPM ratio.
static float GetPPM();
/// Gets the ratio between the physics engine's Liters and on-screen pixels.
/// @return A float describing the current LPP ratio.
static float GetLPP();
/// Gets the ratio between the on-screen pixels and the physics engine's Liters.
/// @return A float describing the current PPL ratio.
static float GetPPL();
/// Gets the pathfinder jump-height value that represents flying.
/// @return A float describing the pathfinder jump-height value that represents flying.
static float GetPathFindingFlyingJumpHeight();
/// Gets the default pathfinder penetration value that'll allow pathing through corpses, debris, and such stuff.
/// @return A float describing the default pathfinder penetration value.
static float GetPathFindingDefaultDigStrength();
/// Explicit deletion of any Entity instance that Lua owns. It will probably be handled by the GC, but this makes it instantaneous.
/// @param entityToDelete The Entity to delete.
static void DeleteEntity(Entity* entityToDelete);
};
#pragma endregion
} // namespace RTE
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif