pickup combining, almost finish shadow stones, fix some bugs with gadgets, clean up some code.
This commit is contained in:
Milxnor
2023-05-02 23:48:05 -04:00
parent 3b0f0ad4e1
commit f49f166c2d
27 changed files with 574 additions and 216 deletions

View File

@@ -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");