5#include "../BasicTypes.h"
7#include "../Containers/FString.h"
11#include "../Misc/ByteSwap.h"
17#pragma warning(disable : 4244
)
20
21
45
46
47
48
49 explicit FORCEINLINE
FVector(
float InF);
52
53
54
55
56
57
61
62
63
64
65
69
70
71
72
76
77
78
79
83
84
85
86
90
91
92
93
96#ifdef IMPLEMENT_ASSIGNMENT_OPERATOR_MANUALLY
98
99
100
101
102
107
108
109
110
111
115
116
117
118
119
120
124
125
126
127
128
132
133
134
135
136
137
141
142
143
144
145
149
150
151
152
153
157
158
159
160
161
165
166
167
168
169
173
174
175
176
177
181
182
183
184
185
189
190
191
192
193
197
198
199
200
201
207
208
209
210
211
215
216
217
218
219
223
224
225
226
227
228
232
233
234
235
236
240
241
242
243
247
248
249
250
251
252
256
257
258
259
260
261
265
266
267
268
269
273
274
275
276
277
281
282
283
284
285
289
290
291
292
293
297
298
299
300
301
305
306
307
308
309
313
314
315
316
317
318
322
323
324
325
326
334
335
336
337
338
339
340 void Set(
float InX,
float InY,
float InZ);
343
344
345
346
350
351
352
353
357
358
359
360
364
365
366
367
377
378
379
380
384
385
386
387
391
392
393
394
398
399
400
401
405
406
407
408
412
413
414
415
416
420
421
422
423
427
428
429
430
431
435
436
437
438
442
443
444
445
446
450
451
452
453
454
458
459
460
461
465
466
467
468
469
473
474
475
476
477
478
482
483
484
485
486
502
503
504
505
506
510
511
512
513
514
518
519
520
521
522
526
527
528
529
530
531
535
536
537
538
539
540
544
545
546
547
548
549
553
554
555
556
557
561
562
563
564
565
569
570
571
572
573
577
578
579
580
581
582
586
587
588
589
590
591
592
593
594
598
599
600
601
602
603
607
608
609
610
611
612
619
620
621
622
626
627
628
629
630
634
635
636
637
641
642
643
644
645
646
650
651
652
656
657
658
659
663
664
665
666
667
668
669
670
671
675
676
677
678
679
680
684
685
686
687
688
689
690
694
695
696
697
698
699
700
704
705
706
707
708
709
710
711
715
716
717
718
719
720
721
725
726
727
728
729
730
734
735
736
737
738
739
744
745
746
747
748
749
754
755
756
757
758
759
763
764
765
766
767
768
773
774
775
776
777
778
782
783
784
785
786
787
788
792
793
794
795
796
797
798
802
803
804
805
806
807
808
812
813
814
815
816
817
818
819
820
824
825
826
827
828
829
830
834
835
836
837
838
839
840
844
845
846
847
848
852
853
854
855
856
861
864
865
866
867
868
869
876 #define INTEL_ORDER_VECTOR(x) (x)
878 static FORCEINLINE FVector INTEL_ORDER_VECTOR(FVector v)
880 return FVector(INTEL_ORDERF(v.X), INTEL_ORDERF(v.Y), INTEL_ORDERF(v.Z));
886
887
888
889
890
891
892
896 float DistSquared = 0.f;
900 if (Point
.X < Mins
.X)
904 else if (Point
.X > Maxs
.X)
909 if (Point
.Y < Mins
.Y)
913 else if (Point
.Y > Maxs
.Y)
918 if (Point
.Z < Mins
.Z)
922 else if (Point
.Z > Maxs
.Z)
947 const float XX = Axis
.X * Axis
.X;
948 const float YY = Axis
.Y * Axis
.Y;
949 const float ZZ = Axis
.Z * Axis
.Z;
951 const float XY = Axis
.X * Axis
.Y;
952 const float YZ = Axis
.Y * Axis
.Z;
953 const float ZX = Axis
.Z * Axis
.X;
955 const float XS = Axis
.X * S;
956 const float YS = Axis
.Y * S;
957 const float ZS = Axis
.Z * S;
959 const float OMC = 1.f - C;
962 (OMC * XX + C) *
X + (OMC * XY - ZS) *
Y + (OMC * ZX + YS) *
Z,
963 (OMC * XY + ZS) *
X + (OMC * YY + C) *
Y + (OMC * YZ - XS) *
Z,
964 (OMC * ZX - YS) *
X + (OMC * YZ + XS) *
Y + (OMC * ZZ + C) *
Z
1003 return (Point
- PlaneBase)
| PlaneNormal;
1021 const float NormalDot = Normal1
| Normal2;
1022 return FMath::Abs(NormalDot
) >= ParallelCosineThreshold;
1027 const float NormalDot = Normal1
| Normal2;
1028 return NormalDot >= ParallelCosineThreshold;
1033 const float NormalDot = Normal1
| Normal2;
1034 return FMath::Abs(NormalDot
) <= OrthogonalCosineThreshold;
1054 return RadVector
* (180.f /
PI);
1059 return DegVector
* (
PI / 180.f);
1063 :
X(InF),
Y(InF),
Z(InF)
1068 :
X(InX),
Y(InY),
Z(InZ)
1073 :
X(InColor
.R),
Y(InColor
.G),
Z(InColor
.B)
1078 :
X(InVector
.X),
Y(InVector
.Y),
Z(InVector
.Z)
1088 :
X(0.0f),
Y(0.0f),
Z(0.0f)
1092#ifdef IMPLEMENT_ASSIGNMENT_OPERATOR_MANUALLY
1093FORCEINLINE FVector& FVector::operator=(
const FVector& Other)
1099 DiagnosticCheckNaN();
1157 const float RScale = 1.f/Scale;
1212 X *= Scale;
Y *= Scale;
Z *= Scale;
1218 const float RV = 1.f/V;
1219 X *= RV;
Y *= RV;
Z *= RV;
1237 check(Index >= 0 && Index < 3);
1254 check(Index >= 0 && Index < 3);
1341 return X==0.f &&
Y==0.f &&
Z==0.f;
1346 const float SquareSum =
X*
X +
Y*
Y +
Z*
Z;
1347 if(SquareSum > Tolerance)
1350 X *= Scale;
Y *= Scale;
Z *= Scale;
1366 float OneOverLength = 1.0f/OutLength;
1388 const float RZ = 1.f/
Z;
1415 return VecSize
* VecDir;
1481 RecVector
.X = 1.f/
X;
1489 RecVector
.Y = 1.f/
Y;
1497 RecVector
.Z = 1.f/
Z;
1517 return *
this - MirrorNormal
* (2.f * (*
this | MirrorNormal));
1522 const float SquareSum =
X*
X +
Y*
Y +
Z*
Z;
1525 if(SquareSum == 1.f)
1529 else if(SquareSum < Tolerance)
1539 const float SquareSum =
X*
X +
Y*
Y;
1542 if(SquareSum == 1.f)
1553 else if(SquareSum < Tolerance)
1574 return (A
* ((*
this | A) / (A
| A)));
1579 return (Normal
* (*
this | Normal));
1604 if(PlaneDir
.Y < 0.0f)
1639 wchar_t buffer[256];
1640 swprintf_s(buffer, TEXT(
"X=%3.3f Y=%3.3f Z=%3.3f"),
X,
Y,
Z);
static unsigned int GetBuildUniqueId()
ARK_API LPVOID GetDataAddress(const std::string &name)
ARK_API BitField GetBitField(LPVOID base, const std::string &name)
ARK_API BitField GetBitField(const void *base, const std::string &name)
ARK_API DWORD64 GetAddress(const void *base, const std::string &name)
ARK_API LPVOID GetAddress(const std::string &name)
#define PLATFORM_LITTLE_ENDIAN
#define THRESH_VECTOR_NORMALIZED
#define THRESH_NORMALS_ARE_PARALLEL
#define THRESH_POINTS_ARE_SAME
#define THRESH_POINT_ON_PLANE
#define THRESH_NORMALS_ARE_ORTHOGONAL
#define KINDA_SMALL_NUMBER
FORCEINLINE float ComputeSquaredDistanceFromBoxToPoint(const FVector &Mins, const FVector &Maxs, const FVector &Point)
FORCEINLINE FVector ClampVector(const FVector &V, const FVector &Min, const FVector &Max)
FORCEINLINE FVector operator*(float Scale, const FVector &V)
ApiUtils & operator=(ApiUtils &&)=delete
void SetCheatManager(UShooterCheatManager *cheatmanager)
void SetWorld(UWorld *uworld)
ApiUtils & operator=(const ApiUtils &)=delete
void SetShooterGameMode(AShooterGameMode *shooter_game_mode)
std::unordered_map< uint64, AShooterPlayerController * > steam_id_map_
UShooterCheatManager * GetCheatManager() const override
Returns a point to URCON CheatManager.
ApiUtils(ApiUtils &&)=delete
AShooterGameMode * shooter_game_mode_
AShooterGameMode * GetShooterGameMode() const override
Returns a pointer to AShooterGameMode.
void RemovePlayerController(AShooterPlayerController *player_controller)
UShooterCheatManager * cheatmanager_
void SetPlayerController(AShooterPlayerController *player_controller)
ServerStatus GetStatus() const override
Returns the current server status.
AShooterPlayerController * FindPlayerFromSteamId_Internal(uint64 steam_id) const override
~ApiUtils() override=default
void SetStatus(ServerStatus status)
UWorld * GetWorld() const override
Returns a pointer to UWorld.
ApiUtils(const ApiUtils &)=delete
static FString GetSteamName(AController *player_controller)
Returns the steam name of player.
static FORCEINLINE FString GetItemBlueprint(UPrimalItem *item)
Returns blueprint from UPrimalItem.
static FVector GetPosition(APlayerController *player_controller)
Returns the position of a player.
uint64 GetSteamIDForPlayerID(int player_id) const
static FORCEINLINE FString GetClassBlueprint(UClass *the_class)
Returns blueprint path from any UClass.
void SendServerMessageToAll(FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to all players. Using fmt::format.
virtual UShooterCheatManager * GetCheatManager() const =0
Returns a point to URCON CheatManager.
UPrimalGameData * GetGameData()
Returns pointer to Primal Game Data.
static bool IsRidingDino(AShooterPlayerController *player_controller)
Returns true if character is riding a dino, false otherwise.
AShooterGameState * GetGameState()
Get Shooter Game State.
virtual ~IApiUtils()=default
AShooterPlayerController * FindPlayerFromSteamName(const FString &steam_name) const
Finds player from the given steam name.
static UShooterCheatManager * GetCheatManagerByPC(AShooterPlayerController *SPC)
Get UShooterCheatManager* of player controller.
static uint64 GetPlayerID(AController *controller)
static bool IsPlayerDead(AShooterPlayerController *player)
Returns true if player is dead, false otherwise.
void SendNotificationToAll(FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to all players. Using fmt::format.
APrimalDinoCharacter * SpawnDino(AShooterPlayerController *player, FString blueprint, FVector *location, int lvl, bool force_tame, bool neutered) const
Spawns a dino near player or at specific coordinates.
TArray< AShooterPlayerController * > FindPlayerFromCharacterName(const FString &character_name, ESearchCase::Type search, bool full_match) const
Finds all matching players from the given character name.
static FORCEINLINE FString GetBlueprint(UObjectBase *object)
Returns blueprint path from any UObject.
static FString GetCharacterName(AShooterPlayerController *player_controller, bool include_first_name=true, bool include_last_name=true)
Returns the character name of player.
TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType)
Gets all actors in radius at location.
void SendChatMessageToAll(const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to all players. Using fmt::format.
TArray< AActor * > GetAllActorsInRange(FVector location, float radius, EServerOctreeGroup::Type ActorType, TArray< AActor * > ignores)
Gets all actors in radius at location, with ignore actors.
virtual AShooterGameMode * GetShooterGameMode() const =0
Returns a pointer to AShooterGameMode.
static uint64 GetSteamIdFromController(AController *controller)
Returns Steam ID from player controller.
virtual UWorld * GetWorld() const =0
Returns a pointer to UWorld.
static bool TeleportToPos(AShooterPlayerController *player_controller, const FVector &pos)
Teleports player to the given position.
void SendNotification(AShooterPlayerController *player_controller, FLinearColor color, float display_scale, float display_time, UTexture2D *icon, const T *msg, Args &&... args)
Sends notification (on-screen message) to the specific player. Using fmt::format.
static uint64 GetPlayerID(APrimalCharacter *character)
virtual AShooterPlayerController * FindPlayerFromSteamId_Internal(uint64 steam_id) const =0
AShooterPlayerController * FindControllerFromCharacter(AShooterCharacter *character) const
Finds player controller from the given player character.
static APrimalDinoCharacter * GetRidingDino(AShooterPlayerController *player_controller)
Returns the dino the character is riding.
static FString GetIPAddress(AShooterPlayerController *player_controller)
Returns IP address of player.
AShooterPlayerController * FindPlayerFromSteamId(uint64 steam_id) const
Finds player from the given steam id.
virtual ServerStatus GetStatus() const =0
Returns the current server status.
void SendServerMessage(AShooterPlayerController *player_controller, FLinearColor msg_color, const T *msg, Args &&... args)
Sends server message to the specific player. Using fmt::format.
static std::optional< FString > TeleportToPlayer(AShooterPlayerController *me, AShooterPlayerController *him, bool check_for_dino, float max_dist)
Teleport one player to another.
static int GetInventoryItemCount(AShooterPlayerController *player_controller, const FString &item_name)
Counts a specific items quantity.
void SendChatMessage(AShooterPlayerController *player_controller, const FString &sender_name, const T *msg, Args &&... args)
Sends chat message to the specific player. Using fmt::format.
FString Replace(const TCHAR *From, const TCHAR *To, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
FORCEINLINE bool FindChar(TCHAR InChar, int32 &Index) const
FORCEINLINE FString Mid(int32 Start, int32 Count=INT_MAX) const
FORCEINLINE friend bool operator==(const FString &Lhs, const FString &Rhs)
FORCEINLINE bool FindLastChar(TCHAR InChar, int32 &Index) const
FORCEINLINE FString(const CharType *Src, typename TEnableIf< TIsCharType< CharType >::Value >::Type *Dummy=nullptr)
FORCEINLINE friend FString operator+(const TCHAR *Lhs, FString &&Rhs)
bool StartsWith(const FString &InPrefix, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
FORCEINLINE bool Equals(const FString &Other, ESearchCase::Type SearchCase=ESearchCase::CaseSensitive) const
bool EndsWith(const TCHAR *InSuffix, ESearchCase::Type SearchCase=ESearchCase::IgnoreCase) const
FORCEINLINE bool IsEmpty() const
FORCEINLINE int32 Len() const
FORCEINLINE friend FString operator+(FString &&Lhs, const TCHAR *Rhs)
FORCEINLINE int32 Add(const ElementType &Item)
int32 Remove(const ElementType &Item)
FORCEINLINE ObjectType * Get() const
IApiUtils & GetApiUtils()
FVector & DefaultActorLocationField()
int & TargetingTeamField()
USceneComponent * RootComponentField()
APlayerState * PlayerStateField()
UCheatManager * CheatManagerField()
FString * GetPlayerNetworkAddress(FString *result)
FUniqueNetIdRepl & UniqueIdField()
FString & PlayerNameField()
bool TeleportTo(FVector *DestLocation, FRotator *DestRotation, bool bIsATest, bool bNoCheck)
UPrimalInventoryComponent * MyInventoryComponentField()
void DoNeuter_Implementation()
static UClass * GetPrivateStaticClass()
void TameDino(AShooterPlayerController *ForPC, bool bIgnoreMaxTameLimit, int OverrideTamingTeamID)
int & TamingTeamIDField()
FString & TamerStringField()
int & AbsoluteBaseLevelField()
UPrimalPlayerData * GetPlayerData()
APrimalDinoCharacter * GetRidingDino()
unsigned __int64 GetSteamIDForPlayerID(int playerDataID)
void AddPlayerID(int playerDataID, unsigned __int64 netUniqueID)
__int64 & LinkedPlayerIDField()
void SetPlayerPos(float X, float Y, float Z)
AActor * SpawnActor(FString *blueprintPath, float spawnDistance, float spawnYOffset, float ZOffset, bool bDoDeferBeginPlay)
AShooterCharacter * GetPlayerCharacter()
FString * GetPlayerName(FString *result)
void SetTribeTamingDinoSettings(APrimalDinoCharacter *aDinoChar)
FIntVector(FVector InVector)
static FORCEINLINE T Clamp(const T X, const T Min, const T Max)
static FORCEINLINE T Square(const T A)
static FORCEINLINE void SinCos(float *ScalarSin, float *ScalarCos, float Value)
static FORCEINLINE auto DegreesToRadians(T const &DegVal) -> decltype(DegVal *(PI/180.f))
unsigned __int64 & PlayerDataIDField()
FORCEINLINE FRotator(float InPitch, float InYaw, float InRoll)
TSharedPtr< FUniqueNetId > UniqueNetId
FORCEINLINE FVector operator+(float Bias) const
FORCEINLINE FVector operator*=(float Scale)
bool operator!=(const FVector &V) const
static float Triple(const FVector &X, const FVector &Y, const FVector &Z)
static bool Orthogonal(const FVector &Normal1, const FVector &Normal2, float OrthogonalCosineThreshold=THRESH_NORMALS_ARE_ORTHOGONAL)
static bool Parallel(const FVector &Normal1, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
FORCEINLINE FVector operator-(const FVector &V) const
FORCEINLINE FVector operator-=(const FVector &V)
FVector GetSafeNormal(float Tolerance=SMALL_NUMBER) const
static FVector VectorPlaneProject(const FVector &V, const FVector &PlaneNormal)
FVector operator/=(const FVector &V)
static bool PointsAreSame(const FVector &P, const FVector &Q)
FORCEINLINE FVector(float InF)
FORCEINLINE FVector operator+=(const FVector &V)
FORCEINLINE FVector operator-() const
FORCEINLINE FVector operator^(const FVector &V) const
bool IsUniform(float Tolerance=KINDA_SMALL_NUMBER) const
FORCEINLINE FVector operator-(float Bias) const
FRotator ToOrientationRotator() const
FVector(const FLinearColor &InColor)
FVector MirrorByVector(const FVector &MirrorNormal) const
FVector Reciprocal() const
static FORCEINLINE float DistSquaredXY(const FVector &V1, const FVector &V2)
static bool PointsAreNear(const FVector &Point1, const FVector &Point2, float Dist)
bool InitFromString(const FString &InSourceString)
static FORCEINLINE float DotProduct(const FVector &A, const FVector &B)
FVector ComponentMax(const FVector &Other) const
void ToDirectionAndLength(FVector &OutDir, float &OutLength) const
FORCEINLINE float operator|(const FVector &V) const
FRotator Rotation() const
FORCEINLINE FVector GetUnsafeNormal() const
FVector GetClampedToMaxSize(float MaxSize) const
FORCEINLINE FVector operator*(const FVector &V) const
void FindBestAxisVectors(FVector &Axis1, FVector &Axis2) const
FVector(FIntVector InVector)
static const FVector ZeroVector
float SizeSquared2D() const
FVector GetSafeNormal2D(float Tolerance=SMALL_NUMBER) const
float & Component(int32 Index)
static FORCEINLINE float BoxPushOut(const FVector &Normal, const FVector &Size)
FVector operator/(float Scale) const
static FVector RadiansToDegrees(const FVector &RadVector)
FVector2D UnitCartesianToSpherical() const
static float PointPlaneDist(const FVector &Point, const FVector &PlaneBase, const FVector &PlaneNormal)
FVector BoundToCube(float Radius) const
static FORCEINLINE float DistSquared(const FVector &V1, const FVector &V2)
FORCEINLINE FVector GetSignVector() const
FORCEINLINE FVector operator/(const FVector &V) const
static FORCEINLINE float Dist2D(const FVector &V1, const FVector &V2)
FVector ComponentMin(const FVector &Other) const
float & operator[](int32 Index)
static FORCEINLINE float Dist(const FVector &V1, const FVector &V2)
FVector GridSnap(const float &GridSz) const
static bool Coincident(const FVector &Normal1, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
FVector Projection() const
static bool Coplanar(const FVector &Base1, const FVector &Normal1, const FVector &Base2, const FVector &Normal2, float ParallelCosineThreshold=THRESH_NORMALS_ARE_PARALLEL)
FORCEINLINE FVector ProjectOnTo(const FVector &A) const
static FVector PointPlaneProject(const FVector &Point, const FVector &PlaneBase, const FVector &PlaneNormal)
bool IsNormalized() const
FORCEINLINE FVector ProjectOnToNormal(const FVector &Normal) const
static FVector PointPlaneProject(const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
bool Equals(const FVector &V, float Tolerance=KINDA_SMALL_NUMBER) const
FQuat ToOrientationQuat() const
bool operator==(const FVector &V) const
FVector GetClampedToSize2D(float Min, float Max) const
float SizeSquared() const
float operator[](int32 Index) const
FVector GetClampedToSize(float Min, float Max) const
static FORCEINLINE float DistSquared2D(const FVector &V1, const FVector &V2)
FVector operator/=(float V)
static FORCEINLINE FVector CrossProduct(const FVector &A, const FVector &B)
FVector operator*=(const FVector &V)
void Set(float InX, float InY, float InZ)
FORCEINLINE FVector operator+(const FVector &V) const
FORCEINLINE FVector operator*(float Scale) const
static FVector DegreesToRadians(const FVector &DegVector)
FORCEINLINE CONSTEXPR FVector(float InX, float InY, float InZ)
FORCEINLINE float CosineAngle2D(FVector B) const
bool AllComponentsEqual(float Tolerance=KINDA_SMALL_NUMBER) const
FVector GetClampedToMaxSize2D(float MaxSize) const
static FORCEINLINE float DistXY(const FVector &V1, const FVector &V2)
static void CreateOrthonormalBasis(FVector &XAxis, FVector &YAxis, FVector &ZAxis)
FORCEINLINE bool IsUnit(float LengthSquaredTolerance=KINDA_SMALL_NUMBER) const
FVector RotateAngleAxis(const float AngleDeg, const FVector &Axis) const
float HeadingAngle() const
static float EvaluateBezier(const FVector *ControlPoints, int32 NumPoints, TArray< FVector > &OutPoints)
float Component(int32 Index) const
FORCEINLINE FVector(const FVector2D V, float InZ)
bool IsNearlyZero(float Tolerance=KINDA_SMALL_NUMBER) const
FORCEINLINE FVector(EForceInit)
static FORCEINLINE float Distance(const FVector &V1, const FVector &V2)
bool Normalize(float Tolerance=SMALL_NUMBER)
T * Get(bool bEvenIfPendingKill=false)
FORCEINLINE T * operator->()
UObject * GetDefaultObject(bool bCreateIfNeeded)
FString * GetFullName(FString *result, UObject *StopOuter)
bool IsA(UClass *SomeBase)
UPrimalGameData * PrimalGameDataOverrideField()
UPrimalGameData * PrimalGameDataField()
FPrimalPlayerDataStruct * MyDataField()
FVector * GetWorldLocation(FVector *result)
static TArray< AActor * > * ServerOctreeOverlapActors(TArray< AActor * > *result, UWorld *theWorld, FVector AtLoc, float Radius, EServerOctreeGroup::Type OctreeType, bool bForceActorLocationDistanceCheck)
TArray< TAutoWeakObjectPtr< APlayerController > > & PlayerControllerListField()
APlayerController * GetFirstPlayerController()
AGameState * GameStateField()