-
-
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.
Add universal snapturn option; add get/set control rotation to contro…
…ller class
- Loading branch information
Showing
6 changed files
with
191 additions
and
26 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
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 |
---|---|---|
@@ -1,7 +1,60 @@ | ||
#include <vector> | ||
#include "UObjectArray.hpp" | ||
#include "ScriptVector.hpp" | ||
#include "ScriptRotator.hpp" | ||
|
||
#include "APlayerController.hpp" | ||
|
||
namespace sdk { | ||
UClass* AController::static_class() { | ||
return sdk::find_uobject<UClass>(L"Class /Script/Engine.Controller"); | ||
} | ||
|
||
void AController::set_control_rotation(const glm::vec3& newrotation) { | ||
static const auto func = static_class()->find_function(L"SetControlRotation"); | ||
const auto frotator = sdk::ScriptRotator::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*)&newrotation, (uint8_t*)&newrotation + sizeof(glm::vec3)); | ||
} else { | ||
glm::vec<3, double> rot = newrotation; | ||
params.insert(params.end(), (uint8_t*)&rot, (uint8_t*)&rot + sizeof(glm::vec<3, double>)); | ||
} | ||
|
||
this->process_event(func, params.data()); | ||
} | ||
|
||
glm::vec3 AController::get_control_rotation() { | ||
static const auto func = static_class()->find_function(L"GetControlRotation"); | ||
const auto frotator = sdk::ScriptVector::static_struct(); | ||
|
||
const auto is_ue5 = frotator->get_struct_size() == sizeof(glm::vec<3, double>); | ||
std::vector<uint8_t> params{}; | ||
|
||
// add a vec3 | ||
if (!is_ue5) { | ||
params.insert(params.end(), sizeof(glm::vec3), 0); | ||
} else { | ||
params.insert(params.end(), sizeof(glm::vec<3, double>), 0); | ||
} | ||
this->process_event(func, params.data()); | ||
|
||
if (!is_ue5) { | ||
return *(glm::vec3*)params.data(); | ||
} | ||
return *(glm::vec<3, double>*)params.data(); | ||
} | ||
|
||
UClass* APlayerController::static_class() { | ||
return sdk::find_uobject<UClass>(L"Class /Script/Engine.PlayerController"); | ||
} | ||
|
||
APawn* APlayerController::get_acknowledged_pawn() const { | ||
return get_property<APawn*>(L"AcknowledgedPawn"); | ||
} | ||
} | ||
} |
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
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