Skip to content

Commit

Permalink
SDK: Add AActor::get_overlapping_actors/components
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 28, 2023
1 parent 7ea4617 commit ea43fc7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions shared/sdk/AActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,39 @@ UWorld* AActor::get_world() {

return level->get_property<UWorld*>(L"OwningWorld");
}

TArray<AActor*> AActor::get_overlapping_actors(UClass* uclass) {
static const auto func = AActor::static_class()->find_function(L"GetOverlappingActors");

if (func == nullptr) {
return {};
}

struct {
TArray<AActor*> out_actors{};
UClass* actor_class{};
} params{};

params.actor_class = uclass;

this->process_event(func, &params);

return std::move(params.out_actors);
}

TArray<UPrimitiveComponent*> AActor::get_overlapping_components() {
static const auto func = AActor::static_class()->find_function(L"GetOverlappingComponents");

if (func == nullptr) {
return {};
}

struct {
TArray<UPrimitiveComponent*> out_components{};
} params{};

this->process_event(func, &params);

return std::move(params.out_components);
}
}
6 changes: 6 additions & 0 deletions shared/sdk/AActor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Math.hpp"

#include "UClass.hpp"
#include "TArray.hpp"

namespace sdk {
class UCameraComponent;
Expand All @@ -13,6 +14,8 @@ class UActorComponent;
class AActor;
class UWorld;

class UPrimitiveComponent;

class AActor : public UObject {
public:
static UClass* static_class();
Expand Down Expand Up @@ -43,6 +46,9 @@ class AActor : public UObject {
UObject* get_level();
UWorld* get_world();

TArray<AActor*> get_overlapping_actors(UClass* uclass = nullptr);
TArray<UPrimitiveComponent*> get_overlapping_components();

protected:
};
}

0 comments on commit ea43fc7

Please sign in to comment.