mirror of
https://github.com/Milxnor/Project-Reboot-3.0.git
synced 2026-01-13 02:42:22 +01:00
great
pickup combining, almost finish shadow stones, fix some bugs with gadgets, clean up some code.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "Transform.h"
|
||||
|
||||
#include "reboot.h"
|
||||
#include "GameplayStatics.h"
|
||||
|
||||
bool AActor::HasAuthority()
|
||||
{
|
||||
@@ -210,6 +211,40 @@ void AActor::GetActorEyesViewPoint(FVector* OutLocation, FRotator* OutRotation)
|
||||
*OutRotation = AActor_GetActorEyesViewPoint_Params.OutRotation;
|
||||
}
|
||||
|
||||
AActor* AActor::GetClosestActor(UClass* ActorClass, float DistMax, std::function<bool(AActor*)> AdditionalCheck)
|
||||
{
|
||||
float TargetDist = FLT_MAX;
|
||||
AActor* TargetActor = nullptr;
|
||||
|
||||
TArray<AActor*> AllActors = UGameplayStatics::GetAllActorsOfClass(GetWorld(), ActorClass);
|
||||
auto ActorLocation = GetActorLocation();
|
||||
|
||||
for (int i = 0; i < AllActors.Num(); i++)
|
||||
{
|
||||
auto Actor = AllActors.at(i);
|
||||
|
||||
if (!Actor || Actor == this)
|
||||
continue;
|
||||
|
||||
if (!AdditionalCheck(Actor))
|
||||
continue;
|
||||
|
||||
auto CurrentActorLocation = Actor->GetActorLocation();
|
||||
|
||||
int Dist = float(sqrtf(powf(CurrentActorLocation.X - ActorLocation.X, 2.0) + powf(CurrentActorLocation.Y - ActorLocation.Y, 2.0) + powf(CurrentActorLocation.Z - ActorLocation.Z, 2.0))) / 100.f;
|
||||
|
||||
if (Dist <= DistMax && Dist < TargetDist)
|
||||
{
|
||||
TargetDist = Dist;
|
||||
TargetActor = Actor;
|
||||
}
|
||||
}
|
||||
|
||||
AllActors.Free();
|
||||
|
||||
return TargetActor;
|
||||
}
|
||||
|
||||
bool AActor::IsAlwaysRelevant()
|
||||
{
|
||||
static auto bAlwaysRelevantOffset = GetOffset("bAlwaysRelevant");
|
||||
|
||||
Reference in New Issue
Block a user