-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK: Forgot to add UCamera/SceneComponent
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "UObjectArray.hpp" | ||
#include "ScriptVector.hpp" | ||
#include "ScriptRotator.hpp" | ||
#include "FProperty.hpp" | ||
|
||
#include "UCameraComponent.hpp" | ||
|
||
namespace sdk { | ||
UClass* UCameraComponent::static_class() { | ||
return sdk::find_uobject<UClass>(L"Class /Script/Engine.CameraComponent"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include "UObject.hpp" | ||
|
||
#include "USceneComponent.hpp" | ||
|
||
namespace sdk { | ||
class UCameraComponent : public USceneComponent { | ||
public: | ||
static UClass* static_class(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#include <sdk/Math.hpp> | ||
|
||
#include <vector> | ||
#include "UObjectArray.hpp" | ||
#include "ScriptVector.hpp" | ||
#include "ScriptRotator.hpp" | ||
#include "FProperty.hpp" | ||
|
||
#include "USceneComponent.hpp" | ||
|
||
namespace sdk { | ||
UClass* USceneComponent::static_class() { | ||
return sdk::find_uobject<UClass>(L"Class /Script/Engine.SceneComponent"); | ||
} | ||
|
||
void USceneComponent::set_world_rotation(const glm::vec3& rotation, bool sweep, bool teleport) { | ||
static auto fn = static_class()->find_function(L"K2_SetWorldRotation"); | ||
static const auto fhitresult = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/Engine.HitResult"); | ||
|
||
if (fn == nullptr) { | ||
return; | ||
} | ||
|
||
const auto frotator = sdk::ScriptVector::static_struct(); | ||
const auto is_ue5 = frotator->get_struct_size() == sizeof(glm::vec<3, double>); | ||
|
||
// Need to dynamically allocate the params because of unknown FRotator size | ||
std::vector<uint8_t> params{}; | ||
|
||
// add a vec3 | ||
if (!is_ue5) { | ||
params.insert(params.end(), (uint8_t*)&rotation, (uint8_t*)&rotation + sizeof(glm::vec3)); | ||
} else { | ||
glm::vec<3, double> rot = rotation; | ||
params.insert(params.end(), (uint8_t*)&rot, (uint8_t*)&rot + sizeof(glm::vec<3, double>)); | ||
} | ||
|
||
// add a bool | ||
params.insert(params.end(), (uint8_t*)&teleport, (uint8_t*)&sweep + sizeof(bool)); | ||
// align | ||
params.insert(params.end(), 3, 0); | ||
// add a FHitResult | ||
params.insert(params.end(), fhitresult->get_struct_size(), 0); | ||
// add a bool | ||
params.insert(params.end(), (uint8_t*)&teleport, (uint8_t*)&teleport + sizeof(bool)); | ||
|
||
this->process_event(fn, params.data()); | ||
} | ||
|
||
void USceneComponent::add_world_rotation(const glm::vec3& rotation, bool sweep, bool teleport) { | ||
static auto fn = static_class()->find_function(L"K2_AddWorldRotation"); | ||
static const auto fhitresult = sdk::find_uobject<UScriptStruct>(L"ScriptStruct /Script/Engine.HitResult"); | ||
|
||
if (fn == nullptr) { | ||
return; | ||
} | ||
|
||
const auto frotator = sdk::ScriptVector::static_struct(); | ||
const auto is_ue5 = frotator->get_struct_size() == sizeof(glm::vec<3, double>); | ||
|
||
// Need to dynamically allocate the params because of unknown FRotator size | ||
std::vector<uint8_t> params{}; | ||
|
||
// add a vec3 | ||
if (!is_ue5) { | ||
params.insert(params.end(), (uint8_t*)&rotation, (uint8_t*)&rotation + sizeof(glm::vec3)); | ||
} else { | ||
glm::vec<3, double> rot = rotation; | ||
params.insert(params.end(), (uint8_t*)&rot, (uint8_t*)&rot + sizeof(glm::vec<3, double>)); | ||
} | ||
|
||
// add a bool | ||
params.insert(params.end(), (uint8_t*)&teleport, (uint8_t*)&sweep + sizeof(bool)); | ||
// align | ||
params.insert(params.end(), 3, 0); | ||
// add a FHitResult | ||
params.insert(params.end(), fhitresult->get_struct_size(), 0); | ||
// add a bool | ||
params.insert(params.end(), (uint8_t*)&teleport, (uint8_t*)&teleport + sizeof(bool)); | ||
|
||
this->process_event(fn, params.data()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include <sdk/Math.hpp> | ||
|
||
#include "UObject.hpp" | ||
|
||
namespace sdk { | ||
class USceneComponent : public UObject { | ||
public: | ||
static UClass* static_class(); | ||
|
||
public: | ||
void set_world_rotation(const glm::vec3& rotation, bool sweep = false, bool teleport = false); | ||
void add_world_rotation(const glm::vec3& rotation, bool sweep = false, bool teleport = false); | ||
}; | ||
} |