-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnrealBeef.cpp
More file actions
747 lines (605 loc) · 23.2 KB
/
UnrealBeef.cpp
File metadata and controls
747 lines (605 loc) · 23.2 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
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
#include "UnrealBeef.h"
#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/ConstructorHelpers.h"
#include "Components/AudioComponent.h"
#include "Engine/Font.h"
#include "Engine/Canvas.h"
#include "Sound/SoundCue.h"
#include "GameFramework/HUD.h"
#include "DrawDebugHelpers.h"
#include "UnrealClient.h"
#include "NiagaraFunctionLibrary.h"
#include "NiagaraComponent.h"
typedef void* HMODULE;
extern "C" HMODULE LoadLibraryA(const char* lpLibFileName);
extern "C" int FreeLibrary(HMODULE hModule);
extern "C" void* GetProcAddress(HMODULE hModule, const char* lpProcName);
extern "C" void GetCurrentDirectoryA(int pathLen, char* path);
extern "C" void SetCurrentDirectoryA(char* path);
extern "C" void OutputDebugStringA(char* path);
std::string gUBF_DLLPath;
HMODULE gUBF_BeefModule = NULL;
bool gUBF_Initialized = false;
FString gUBF_ResultStr;
bool gUBF_WantsDLLUnload_OnAppDone = false;
bool gUBF_WantsDLLUnload_OnCPPRebuild = false;
std::vector<void**> gUBF_FuncPtrs;
#define LOADPROC(name) \
g##name = (T_##name)::GetProcAddress(gUBF_BeefModule, #name); \
if (g##name == NULL) return false; \
gUBF_FuncPtrs.push_back((void**)&g##name);
struct BF_FHitResult
{
int32 mFaceIndex;
float mDistance;
FVector mLocation;
FVector mImpactPoint;
FVector mNormal;
FVector mImpactNormal;
FVector mTraceStart;
FVector mTraceEnd;
float mPenetrationDepth;
int32 mMyItem;
int32 mItem;
uint8 mElementIdx;
bool mBlockingHit;
bool mStartPenetrating;
int32 mHitActor_Index;
uint32 mHitActor_Serial;
int32 mHitComponent_Index;
uint32 mHitComponent_Serial;
BF_FHitResult& operator=(const FHitResult& hitResult)
{
mFaceIndex = hitResult.FaceIndex;
mDistance = hitResult.Distance;
mLocation = hitResult.Location;
mImpactPoint = hitResult.ImpactPoint;
mNormal = hitResult.Normal;
mImpactNormal = hitResult.ImpactNormal;
mTraceStart = hitResult.TraceStart;
mTraceEnd = hitResult.TraceEnd;
mPenetrationDepth = hitResult.PenetrationDepth;
mMyItem = hitResult.MyItem;
mItem = hitResult.Item;
mElementIdx = hitResult.ElementIndex;
mBlockingHit = hitResult.bBlockingHit;
mStartPenetrating = hitResult.bStartPenetrating;
auto actor = hitResult.HitObjectHandle.FetchActor();
if (actor != NULL)
{
mHitActor_Index = GUObjectArray.ObjectToIndex((UObjectBase*)actor);
mHitActor_Serial = GUObjectArray.AllocateSerialNumber(mHitActor_Index);
}
auto component = hitResult.Component.Get();
if (component != NULL)
{
mHitComponent_Index = GUObjectArray.ObjectToIndex((UObjectBase*)component);
mHitComponent_Serial = GUObjectArray.AllocateSerialNumber(mHitComponent_Index);
}
return *this;
}
};
struct BF_FHitResult_Handler
{
FHitResult mHitResult;
BF_FHitResult* mBFHitResult;
BF_FHitResult_Handler(BF_FHitResult* bfHitResult) : mHitResult(ForceInit)
{
mBFHitResult = bfHitResult;
}
~BF_FHitResult_Handler()
{
if (mBFHitResult != NULL)
*mBFHitResult = mHitResult;
}
operator FHitResult* ()
{
if (mBFHitResult == NULL)
return NULL;
return &mHitResult;
}
operator FHitResult& ()
{
return mHitResult;
}
};
// GLOBAL
static const wchar_t* UBF_Class_GetName(UClass* uclass)
{
uclass->GetName(gUBF_ResultStr);
return *gUBF_ResultStr;
}
static UClass* UBF_Class_GetSuperClass(UClass* uclass)
{
return uclass->GetSuperClass();
}
static void Engine_AddOnScreenDebugMessage(uint64 Key, float TimeToDisplay, uint32 DisplayColor, const char* DebugMessage, bool bNewerOnTop, const FVector2D& TextScale)
{
GEngine->AddOnScreenDebugMessage(Key, TimeToDisplay, FColor(DisplayColor), DebugMessage, bNewerOnTop, TextScale);
}
void UBF_SetWantsDLLUnload(bool onAppDone, bool onCPPRebuild)
{
gUBF_WantsDLLUnload_OnAppDone = onAppDone;
gUBF_WantsDLLUnload_OnCPPRebuild = onCPPRebuild;
}
static void Engine_ForceGarbageCollection(bool fullPurge)
{
GEngine->ForceGarbageCollection(fullPurge);
}
static FVector Transform_TransformPosition(const FTransform& transform, const FVector& vec)
{
return transform.TransformPosition(vec);
}
static FVector Transform_TransformPositionNoScale(const FTransform& transform, const FVector& vec)
{
return transform.TransformPositionNoScale(vec);
}
static FVector Transform_TransformVector(const FTransform& transform, const FVector& vec)
{
return transform.TransformVector(vec);
}
static FVector Transform_TransformVectorNoScale(const FTransform& transform, const FVector& vec)
{
return transform.TransformVectorNoScale(vec);
}
static UObject* Engine_FindObject(const char* name)
{
FString fsName(name);
ConstructorHelpers::FObjectFinder<UObject> res(*fsName);
return res.Object;
}
static UObject* UBF_CreateObject(UClass* uclass)
{
return NewObject<UObject>((UObject*)GetTransientPackage(), uclass);
}
// UObject
static void UObject_GetWeakRef(UObject* self, int32& objectIndex, int32& objectSerialNumber)
{
objectIndex = GUObjectArray.ObjectToIndex((UObjectBase*)self);
auto object = GUObjectArray.GetObjectItemArrayUnsafe().GetObjectPtr(objectIndex);
objectSerialNumber = GUObjectArray.AllocateSerialNumber(objectIndex);
}
static UObjectBase* UObject_CheckWeakRef(int32 objectIndex, int32 objectSerialNumber)
{
auto objectItem = GUObjectArray.IndexToObject(objectIndex);
if (objectItem == NULL)
return NULL;
if (objectItem->GetSerialNumber() != objectSerialNumber)
return NULL;
return objectItem->Object;
}
static UClass* UObject_GetClass(UObject* self)
{
return self->GetClass();
}
static bool UObject_CanCast(UObject* self, UClass* toClass)
{
if (self == NULL)
return false;
auto fromClass = self->GetClass();
if (fromClass == toClass)
return true;
return fromClass->IsChildOf(toClass);
}
static AGameModeBase* UObject_GetGameMode(UObject* uobject)
{
return UGameplayStatics::GetGameMode(uobject);
}
static AGameStateBase* UObject_GetGameState(UObject* uobject)
{
return UGameplayStatics::GetGameState(uobject);
}
static void UObject_GCMarkObject(UObject* self)
{
int objectIndex = GUObjectArray.ObjectToIndex((UObjectBase*)self);
auto object = GUObjectArray.GetObjectItemArrayUnsafe().GetObjectPtr(objectIndex);
object->ClearFlags(EInternalObjectFlags::Unreachable);
}
static UObject* UObject_CreateDefaultSubobject(UObject* self, UClass* uclass, const char* name, bool transient)
{
return self->CreateDefaultSubobject(name, uclass, uclass, /*bIsRequired =*/ true, transient);
}
// USceneComponent
static void USceneComponent_AddLocalRotation(USceneComponent* self, const FRotator& rotator, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
self->AddLocalRotation(rotator, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static void USceneComponent_SetRelativeRotation(USceneComponent* self, const FRotator& rotator, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
self->SetRelativeRotation(rotator, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static void USceneComponent_SetWorldRotation(USceneComponent* self, const FRotator& rotator, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
self->SetWorldRotation(rotator, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static void USceneComponent_SetRelativeLocation(USceneComponent* self, const FVector& position, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
self->SetRelativeLocation(position, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static void USceneComponent_SetWorldLocation(USceneComponent* self, const FVector& position, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
self->SetWorldLocation(position, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static void USceneComponent_AttachToComponent(USceneComponent* self, USceneComponent* component)
{
FAttachmentTransformRules transRules(EAttachmentRule::KeepWorld, false);
self->AttachToComponent(component, transRules);
}
// UActorComponent
static void UActorComponent_DestroyComponent(UActorComponent* self, bool promoteChildren)
{
self->DestroyComponent(promoteChildren);
}
static void UActorComponent_UnregisterComponent(UActorComponent* self)
{
self->UnregisterComponent();
}
static void UActorComponent_RegisterComponent(UActorComponent* self)
{
self->RegisterComponent();
}
// AGameModeBase
// UWorld
static void World_DrawDebugLine(UWorld* self, const FVector& lineStart, const FVector& lineEnd, uint32 color, bool persistentLine, float lifetime, uint8 depthPriority, float thickness)
{
DrawDebugLine(self, lineStart, lineEnd, FColor(color), persistentLine, lifetime, depthPriority, thickness);
}
static bool World_LineTraceSingleByChannel(UWorld* world, BF_FHitResult* hitResult, const FVector& start, const FVector& end, ECollisionChannel collisionChannel, AActor* ignoredActor)
{
FCollisionQueryParams collisionParams = FCollisionQueryParams::DefaultQueryParam;
if (ignoredActor != NULL)
collisionParams.AddIgnoredActor(ignoredActor);
bool hit = world->LineTraceSingleByChannel(BF_FHitResult_Handler(hitResult), start, end, collisionChannel, collisionParams);
return hit;
}
static void World_RemoveActor(UWorld* self, AActor* actor, bool shouldModifyLevel)
{
self->RemoveActor(actor, shouldModifyLevel);
}
static AActor* World_SpawnActor(UWorld* self, UClass* uclass, FVector* location, FRotator* rotation, const char* name, EObjectFlags flags)
{
FActorSpawnParameters spawnParams;
if (name != NULL)
spawnParams.Name = name;
spawnParams.ObjectFlags = flags;
return self->SpawnActor(uclass, location, rotation, spawnParams);
}
static void World_DrawDebugDirectionalArrow(UWorld* self, const FVector& lineStart, const FVector& lineEnd, float arrowSize, uint32 color, bool persistentLine, float lifetime, uint8 depthPriority, float thickness)
{
DrawDebugDirectionalArrow(self, lineStart, lineEnd, arrowSize, FColor(color), persistentLine, lifetime, depthPriority, thickness);
}
static void World_DrawDebugCircle(UWorld* self, const FVector& center, float radius, int32 segments, uint32 color, bool persistentLine, float lifetime, uint8 depthPriority, float thickness, const FVector& yAxis, const FVector& zAxis, bool drawAxis)
{
DrawDebugCircle(self, center, radius, segments, FColor(color), persistentLine, lifetime, depthPriority, thickness, yAxis, zAxis, drawAxis);
}
static void World_GetScreenSize(UWorld* self, float* width, float* height)
{
FVector2D sizeXY;
self->GetGameViewport()->GetViewportSize(sizeXY);
*width = sizeXY.X;
*height = sizeXY.Y;
}
// AActor
static UWorld* Actor_GetWorld(AActor* self)
{
return self->GetWorld();
}
static FVector Actor_GetActorForwardVector(AActor* self)
{
return self->GetActorForwardVector();
}
static FVector Actor_GetActorUpVector(AActor* self)
{
return self->GetActorUpVector();
}
static FVector Actor_GetActorRightVector(AActor* self)
{
return self->GetActorRightVector();
}
static FVector Actor_GetActorLocation(AActor* self)
{
return self->GetActorLocation();
}
static FQuat Actor_GetActorQuat(AActor* self)
{
return self->GetActorQuat();
}
static FRotator Actor_GetActorRotation(AActor* self)
{
return self->GetActorRotation();
}
static FVector Actor_GetActorScale(AActor* self)
{
return self->GetActorScale();
}
static FTransform Actor_GetTransform(AActor* self)
{
int size = sizeof(FTransform);
auto trans = self->GetTransform();
return trans;
}
static FVector Actor_GetVelocity(AActor* self)
{
return self->GetVelocity();
}
static bool Actor_SetActorLocation(AActor* self, const FVector& NewLocation, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
return self->SetActorLocation(NewLocation, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static bool Actor_SetActorTransform(AActor* self, const FTransform& NewTransform, bool bSweep, BF_FHitResult* OutSweepHitResult, ETeleportType Teleport)
{
return self->SetActorTransform(NewTransform, bSweep, BF_FHitResult_Handler(OutSweepHitResult), Teleport);
}
static bool Actor_SetActorRotation_Rotator(AActor* self, FRotator NewRotation, ETeleportType Teleport)
{
return self->SetActorRotation(NewRotation, Teleport);
}
static bool Actor_SetActorRotation_Quat(AActor* self, const FQuat& NewRotation, ETeleportType Teleport)
{
return self->SetActorRotation(NewRotation, Teleport);
}
static bool Actor_Destroy(AActor* self, bool netForce, bool shouldModifyLevel)
{
return self->Destroy(netForce, shouldModifyLevel);
}
static bool Actor_IsBeingDestroyed(AActor* self)
{
return self->IsActorBeingDestroyed();
}
static void Actor_SetActorTickInterval(AActor* self, float tickInterval)
{
self->SetActorTickInterval(tickInterval);
}
static float Actor_GetActorTickInterval(AActor* self)
{
return self->GetActorTickInterval();
}
static USceneComponent* Actor_GetRootComponent(AActor* self)
{
return self->GetRootComponent();
}
// Pawn
static AController* Pawn_GetController(APawn* self)
{
return self->GetController();
}
// AController
static void Controller_Possess(AController* self, APawn* pawn)
{
self->Possess(pawn);
}
// APlayerController
static bool PlayerController_IsInputKeyDown(APlayerController* self, const char* keyName)
{
return self->IsInputKeyDown(FKey(keyName));
}
static bool PlayerController_WasInputKeyJustPressed(APlayerController* self, const char* keyName)
{
return self->WasInputKeyJustPressed(FKey(keyName));
}
static bool PlayerController_WasInputKeyJustReleased(APlayerController* self, const char* keyName)
{
return self->WasInputKeyJustReleased(FKey(keyName));
}
static AHUD* PlayerController_GetHUD(APlayerController* self)
{
return self->GetHUD();
}
static void PlayerController_SetAudioListenerOverride(APlayerController* self, USceneComponent* component, const FVector& location, const FRotator& rotation)
{
self->SetAudioListenerOverride(component, location, rotation);
}
static void PlayerController_ClearAudioListenerOverride(APlayerController* self)
{
self->ClearAudioListenerOverride();
}
static void PlayerController_SetAudioListenerAttenuationOverride(APlayerController* self, USceneComponent* component, const FVector& attenuationLocationOverride)
{
self->SetAudioListenerAttenuationOverride(component, attenuationLocationOverride);
}
static void PlayerController_ClearAudioListenerAttenuationOverride(APlayerController* self)
{
self->ClearAudioListenerAttenuationOverride();
}
// AHUD
static void HUD_DrawText(AHUD* self, const char* text, float x, float y, uint32 color, UFont* font, float scale, bool scalePosition)
{
self->DrawText(text, FLinearColor(FColor(color)), x, y, font, scale, scalePosition);
}
static void HUD_DrawRect(AHUD* self, uint32 color, float x, float y, float width, float height)
{
self->DrawRect(FLinearColor(FColor(color)), x, y, width, height);
}
// UAudioComponent
static void AudioComponent_SetSound(UAudioComponent* self, USoundBase* soundBase)
{
self->SetSound(soundBase);
}
static void AudioComponent_Play(UAudioComponent* self, float startTime)
{
self->Play(startTime);
}
static void AudioComponent_Stop(UAudioComponent* self)
{
self->Stop();
}
static void AudioComponent_SetPaused(UAudioComponent* self, bool paused)
{
self->SetPaused(paused);
}
static void AudioComponent_SetAutoDestroy(UAudioComponent* self, bool autoDestroy)
{
self->bAutoDestroy = autoDestroy;
}
static bool AudioComponent_IsPlaying(UAudioComponent* self)
{
return self->IsPlaying();
}
static void AudioComponent_SetVolumeMultiplier(UAudioComponent* self, float multiplier)
{
self->SetVolumeMultiplier(multiplier);
}
static void AudioComponent_SetPitchMultiplier(UAudioComponent* self, float multiplier)
{
self->SetPitchMultiplier(multiplier);
}
/// USoundBase
static void USoundBase_Play2D(USoundBase* self, UObject* refObject, float volumeMultiplier, float pitchMultiplier, float startTime)
{
UGameplayStatics::PlaySound2D(refObject, self, volumeMultiplier, pitchMultiplier, startTime);
}
static void USoundBase_PlayAtLocation(USoundBase* self, UObject* refObject, const FVector& location, float volumeMultiplier, float pitchMultiplier, float startTime)
{
UGameplayStatics::PlaySoundAtLocation(refObject, self, location, volumeMultiplier, pitchMultiplier, startTime);
}
static void USoundBase_PrimeSound(USoundBase* self)
{
UGameplayStatics::PrimeSound(self);
}
static UAudioComponent* USoundBase_SpawnSound2D(USoundBase* self, UObject* refObject, float volumeMultiplier, float pitchMultiplier, float startTime)
{
return UGameplayStatics::SpawnSound2D(refObject, self, volumeMultiplier, pitchMultiplier, startTime);
}
static UAudioComponent* USoundBase_CreateSound2D(USoundBase* self, UObject* refObject, float volumeMultiplier, float pitchMultiplier, float startTime)
{
return UGameplayStatics::CreateSound2D(refObject, self, volumeMultiplier, pitchMultiplier, startTime);
}
static UAudioComponent* USoundBase_SpawnAttached(USoundBase* self, USceneComponent* component, const char* pointName, const FVector& location, EAttachLocation::Type locationType,
bool stopWhenAttachedToDestroyed, float volumeMultiplier, float pitchMultiplier, float startTime, bool autoDestroy)
{
return UGameplayStatics::SpawnSoundAttached(self, component, pointName, location, locationType, stopWhenAttachedToDestroyed, volumeMultiplier, pitchMultiplier, startTime, NULL, NULL, autoDestroy);
}
/// UNiagaraSystem
UNiagaraComponent* NiagaraSystem_SpawnSystemAtLocation(UNiagaraSystem* self, UWorld* world, const FVector& location, const FRotator& rotation)
{
return UNiagaraFunctionLibrary::SpawnSystemAtLocation(world, self, location, rotation);
}
/// UNiagaraComponent
void NiagaraComponent_SetVariableFloat(UNiagaraComponent* self, const char* name, float value)
{
self->SetVariableFloat(name, value);
}
void NiagaraComponent_SetVariableInt(UNiagaraComponent* self, const char* name, int value)
{
self->SetVariableInt(name, value);
}
void NiagaraComponent_DestroyInstance(UNiagaraComponent* self)
{
self->DestroyInstance();
}
void NiagaraComponent_ReinitializeSystem(UNiagaraComponent* self)
{
self->ReinitializeSystem();
}
void UBF_Unload()
{
if (!gUBF_Initialized)
return;
for (auto& ptr : gUBF_FuncPtrs)
*ptr = NULL;
gUBF_FuncPtrs.clear();
gUBF_Initialized = false;
::FreeLibrary(gUBF_BeefModule);
gUBF_BeefModule = NULL;
}
void UBF_RegisterClasses()
{
void* mainCallbacks[] = { &UBF_Class_GetName, &UBF_Class_GetSuperClass, &Engine_AddOnScreenDebugMessage, &UBF_SetWantsDLLUnload,
&Engine_ForceGarbageCollection, &Transform_TransformPosition, &Transform_TransformPositionNoScale,
&Transform_TransformVector, &Transform_TransformVectorNoScale, &Engine_FindObject, &UBF_CreateObject };
UBF_App_Init(UBF_VERSION, mainCallbacks);
void* objectCallbacks[] = { &UObject_GetClass, &UObject_CanCast, &UObject_GetWeakRef, &UObject_CheckWeakRef, &UObject_GetGameMode, &UObject_GetGameState,
&UObject_GCMarkObject, &UObject_CreateDefaultSubobject };
UBF_Class_Register(UObject::StaticClass(), objectCallbacks);
void* usceneComponentCallbacks[] = { &USceneComponent_AddLocalRotation, &USceneComponent_SetRelativeRotation, &USceneComponent_SetWorldRotation,
&USceneComponent_SetRelativeLocation, &USceneComponent_SetWorldLocation, &USceneComponent_AttachToComponent };
UBF_Class_Register(USceneComponent::StaticClass(), usceneComponentCallbacks);
void* uactorComponentCallbacks[] = { &UActorComponent_DestroyComponent, &UActorComponent_UnregisterComponent, &UActorComponent_RegisterComponent };
UBF_Class_Register(UActorComponent::StaticClass(), uactorComponentCallbacks);
void* gamemodeCallbacks[] = { NULL };
UBF_Class_Register(AGameModeBase::StaticClass(), gamemodeCallbacks);
void* worldCallbacks[] = { &World_DrawDebugLine, &World_LineTraceSingleByChannel, &World_RemoveActor, &World_SpawnActor, &World_DrawDebugDirectionalArrow,
&World_DrawDebugCircle, &World_GetScreenSize };
UBF_Class_Register(UWorld::StaticClass(), worldCallbacks);
void* actorCallbacks[] = { &Actor_GetWorld, &Actor_GetActorForwardVector, &Actor_GetActorUpVector, &Actor_GetActorRightVector,
&Actor_GetActorLocation, &Actor_GetActorQuat, &Actor_GetActorRotation, &Actor_GetActorScale, &Actor_GetTransform,
&Actor_GetVelocity, &Actor_SetActorLocation, &Actor_SetActorTransform, &Actor_SetActorRotation_Rotator, &Actor_SetActorRotation_Quat,
&Actor_Destroy, &Actor_IsBeingDestroyed, &Actor_GetActorTickInterval, &Actor_SetActorTickInterval, &Actor_GetRootComponent };
UBF_Class_Register(AActor::StaticClass(), actorCallbacks);
void* pawnCallbacks[] = { &Pawn_GetController };
UBF_Class_Register(APawn::StaticClass(), pawnCallbacks);
void* controllerCallbacks[] = { &Controller_Possess };
UBF_Class_Register(AController::StaticClass(), controllerCallbacks);
void* playerControllerCallbacks[] = { &PlayerController_IsInputKeyDown, &PlayerController_WasInputKeyJustPressed, &PlayerController_WasInputKeyJustReleased,
&PlayerController_GetHUD, &PlayerController_SetAudioListenerOverride, & PlayerController_ClearAudioListenerOverride,
&PlayerController_SetAudioListenerAttenuationOverride, & PlayerController_ClearAudioListenerAttenuationOverride };
UBF_Class_Register(APlayerController::StaticClass(), playerControllerCallbacks);
void* hudCallbacks[] = { &HUD_DrawText, &HUD_DrawRect };
UBF_Class_Register(AHUD::StaticClass(), hudCallbacks);
void* fontCallbacks[] = { NULL };
UBF_Class_Register(UFont::StaticClass(), fontCallbacks);
void* soundBaseCallbacks[] = { &USoundBase_Play2D, &USoundBase_PlayAtLocation, &USoundBase_PrimeSound, &USoundBase_SpawnSound2D, &USoundBase_CreateSound2D,
&USoundBase_SpawnAttached};
UBF_Class_Register(USoundBase::StaticClass(), soundBaseCallbacks);
void* soundCueCallbacks[] = { NULL };
UBF_Class_Register(USoundCue::StaticClass(), soundCueCallbacks);
void* audioComponentCallbacks[] = { &AudioComponent_SetSound, &AudioComponent_Play, &AudioComponent_Stop, &AudioComponent_SetPaused, &AudioComponent_SetAutoDestroy,
&AudioComponent_IsPlaying, &AudioComponent_SetVolumeMultiplier, &AudioComponent_SetPitchMultiplier };
UBF_Class_Register(UAudioComponent::StaticClass(), audioComponentCallbacks);
void* niagaraSystemCallbacks[] = { &NiagaraSystem_SpawnSystemAtLocation };
UBF_Class_Register(UNiagaraSystem::StaticClass(), niagaraSystemCallbacks);
void* niagaraComponentCallbacks[] = { &NiagaraComponent_SetVariableFloat, &NiagaraComponent_SetVariableInt, &NiagaraComponent_DestroyInstance, &NiagaraComponent_ReinitializeSystem };
UBF_Class_Register(UNiagaraComponent::StaticClass(), niagaraComponentCallbacks);
}
void UBF_ReloadComplete(EReloadCompleteReason completeReason)
{
if (gUBF_WantsDLLUnload_OnCPPRebuild)
{
UBF_Unload();
UBF_Init(gUBF_DLLPath.c_str());
}
else
{
UBF_RegisterClasses();
}
}
bool UBF_Init(const char* dllPath)
{
if (gUBF_BeefModule != NULL)
{
UBF_App_Start();
return gUBF_Initialized;
}
gUBF_DLLPath = dllPath;
gUBF_BeefModule = ::LoadLibraryA(dllPath);
if (gUBF_BeefModule == NULL)
return false;
LOADPROC(App_Init);
LOADPROC(App_Start);
LOADPROC(App_Done);
LOADPROC(App_PreGarbageCollectDelegate);
LOADPROC(Class_Register);
LOADPROC(Object_Created);
LOADPROC(Object_Deleted);
LOADPROC(Actor_Tick);
LOADPROC(World_StartTick);
LOADPROC(HUD_DrawHUD);
FWorldDelegates::OnWorldTickStart.AddStatic(&UBF_World_StartTick);
FCoreUObjectDelegates::ReloadCompleteDelegate.AddStatic(&UBF_ReloadComplete);
FCoreUObjectDelegates::GetPreGarbageCollectDelegate().AddStatic(&UBF_App_PreGarbageCollectDelegate);
UBF_RegisterClasses();
UBF_App_Start();
gUBF_Initialized = true;
return true;
}
void UBF_App_Done()
{
if (gApp_Done != NULL)
gApp_Done();
if (gUBF_WantsDLLUnload_OnAppDone)
{
UBF_Unload();
}
}