Skip to content

Commit

Permalink
SDK: Forgot to update AActor
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Oct 22, 2023
1 parent ef4598d commit 9c482b1
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
76 changes: 76 additions & 0 deletions shared/sdk/AActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "UObjectArray.hpp"
#include "ScriptVector.hpp"
#include "ScriptRotator.hpp"
#include "UCameraComponent.hpp"

#include "AActor.hpp"

Expand Down Expand Up @@ -99,4 +100,79 @@ bool AActor::set_actor_rotation(const glm::vec3& rotation, bool teleport) {

return ret;
};

USceneComponent* AActor::get_component_by_class(UClass* uclass) {
static const auto func = AActor::static_class()->find_function(L"GetComponentByClass");

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

struct {
sdk::UClass* uclass;
sdk::USceneComponent* ret;
} params;

params.uclass = uclass;
params.ret = nullptr;

this->process_event(func, &params);

return params.ret;
}

UCameraComponent* AActor::get_camera_component() {
return (UCameraComponent*)get_component_by_class(UCameraComponent::static_class());
}

struct FTransform {
glm::vec4 Rotation{0.0f, 0.0f, 0.0f, 1.0f}; // quat
glm::vec4 Translation{0.0f, 0.0f, 0.0f, 1.0f};
glm::vec4 Scale3D{1.0f, 1.0f, 1.0f, 1.0f};
};


USceneComponent* AActor::add_component_by_class(UClass* uclass) {
static const auto func = AActor::static_class()->find_function(L"AddComponentByClass");

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

struct {
sdk::UClass* uclass;
bool bManualAttachment{false};
char pad_9[0x7];
FTransform RelativeTransform{};
bool bDeferredFinish{false};
char pad_41[0x7];
sdk::USceneComponent* ret{nullptr};
} params;

params.uclass = uclass;
params.ret = nullptr;

this->process_event(func, &params);

return params.ret;
}

void AActor::finish_add_component(sdk::UObject* component) {
static const auto func = AActor::static_class()->find_function(L"FinishAddComponent");

if (func == nullptr) {
return;
}

struct {
sdk::UObject* Component{}; // 0x0
bool bManualAttachment{}; // 0x8
char pad_9[0x7];
FTransform RelativeTransform{}; // 0x10
} params;

params.Component = component;

this->process_event(func, &params);
}
}
9 changes: 9 additions & 0 deletions shared/sdk/AActor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include "UClass.hpp"

namespace sdk {
class UCameraComponent;
class USceneComponent;

class AActor : public UObject {
public:
static UClass* static_class();
Expand All @@ -15,6 +18,12 @@ class AActor : public UObject {

bool set_actor_rotation(const glm::vec3& rotation, bool teleport);

USceneComponent* get_component_by_class(UClass* uclass);
UCameraComponent* get_camera_component();

USceneComponent* add_component_by_class(UClass* uclass);
void finish_add_component(sdk::UObject* component);

protected:
};
}

0 comments on commit 9c482b1

Please sign in to comment.