Transform namespace updated & freecam removed

This commit is contained in:
Jadis0x
2024-06-08 13:14:27 +03:00
parent d2ac02fde8
commit 136d3d137e
7 changed files with 43 additions and 58 deletions

View File

@@ -2,7 +2,7 @@
#include "UnityEngine/Transform.h"
app::Transform* Transform::Get(app::GameObject* go)
app::Transform* Transform::GetTransform(app::GameObject* go)
{
if (!go || !app::GameObject_get_transform) return nullptr;
@@ -11,9 +11,38 @@ app::Transform* Transform::Get(app::GameObject* go)
return __transform ? __transform : nullptr;
}
app::Vector3 Transform::Position(app::Transform* transform)
app::Vector3 Transform::GetPosition(app::Transform* transform)
{
if (!transform || !app::Transform_get_position) return app::Vector3();
return app::Transform_get_position(transform, nullptr);
}
app::Quaternion Transform::GetRotation(app::Transform* transform)
{
return app::Transform_get_rotation(transform, nullptr);
}
app::Vector3 Transform::GetForward(app::Transform* transform)
{
return app::Transform_get_forward(transform, nullptr);
}
app::Vector3 Transform::GetRight(app::Transform* transform)
{
return app::Transform_get_right(transform, nullptr);
}
app::Vector3 Transform::GetEulerAngles(app::Quaternion rotation)
{
return app::Quaternion_get_eulerAngles(&rotation, nullptr);
}
app::Quaternion Transform::QuaternionEuler(app::Vector3 eulerAngles)
{
float x = eulerAngles.x;
float y = eulerAngles.y;
float z = eulerAngles.z;
return app::Quaternion_Euler(x, y, z, nullptr);
}

View File

@@ -1,6 +1,11 @@
#pragma once
namespace Transform {
app::Transform* Get(app::GameObject* go);
app::Vector3 Position(app::Transform* transform);
app::Transform* GetTransform(app::GameObject* go);
app::Vector3 GetPosition(app::Transform* transform);
app::Quaternion GetRotation(app::Transform* transform);
app::Vector3 GetForward(app::Transform* transform);
app::Vector3 GetRight(app::Transform* transform);
app::Vector3 GetEulerAngles(app::Quaternion rotation);
app::Quaternion QuaternionEuler(app::Vector3 eulerAngles);
}

View File

@@ -31,11 +31,11 @@ static void DrawBoxESP(app::GameObject *it, float footOffset, float headOffset,
if (!it || cam == nullptr)
return;
app::Transform* _transform = Transform::Get(it);
app::Transform* _transform = Transform::GetTransform(it);
if (_transform == nullptr)
return;
app::Vector3 pos = Transform::Position(_transform);
app::Vector3 pos = Transform::GetPosition(_transform);
app::Vector3 footpos = app::Camera_WorldToScreenPoint_1(cam, app::Vector3{pos.x, pos.y + footOffset, pos.z}, NULL);
app::Vector3 headpos = app::Camera_WorldToScreenPoint_1(cam, app::Vector3{pos.x, pos.y + headOffset, pos.z}, NULL);

View File

@@ -174,10 +174,10 @@ void Misc::SpawnPrefab(const char* prefabName) {
if (localPlayer) {
app::Quaternion rotation = app::Quaternion_get_identity(NULL);
app::Transform* playerTransform = Transform::Get(localPlayer);
app::Transform* playerTransform = Transform::GetTransform(localPlayer);
if (playerTransform == nullptr) return;
app::Vector3 playerPos = Transform::Position(playerTransform);
app::Vector3 playerPos = Transform::GetPosition(playerTransform);
if (app::BoltNetwork_Instantiate_6) {
app::GameObject* go = (app::GameObject*)app::BoltNetwork_Instantiate_6(p, playerPos, rotation, nullptr);

View File

@@ -93,52 +93,6 @@ typedef void(__stdcall* TNolanBehaviour_Update)(app::NolanBehaviour*, MethodInfo
TNolanBehaviour_Update oNolanBehaviour_Update = NULL;
void __stdcall hNolanBehaviour_Update(app::NolanBehaviour* __this, MethodInfo* method) {
if (settings::freecam && IsLocalPlayer(__this)) {
app::CameraController* cameraController = __this->fields.cameraController;
cameraController->fields.m_Anchor = nullptr;
cameraController->fields.m_Character = nullptr;
cameraController->fields.m_CharacterLocomotion = nullptr;
app::Transform* cameraControllerTransform = app::CameraController_get_CameraTransform(cameraController, nullptr);
static app::Vector3 newCameraPosition = app::Transform_get_position(cameraControllerTransform, nullptr);
static app::Quaternion newCameraRotation = app::Transform_get_rotation(cameraControllerTransform, nullptr);
// Kamera hareketi ve rotasyonu için inputları kontrol et
float moveSpeed = 15.0f;
float rotateSpeed = 2.0f;
if (GetAsyncKeyState('W') & 0x8000) {
newCameraPosition = newCameraPosition + (app::Transform_get_forward(cameraControllerTransform, nullptr) * moveSpeed * Time_DeltaTime());
}
if (GetAsyncKeyState('S') & 0x8000) {
newCameraPosition = newCameraPosition - (app::Transform_get_forward(cameraControllerTransform, nullptr) * moveSpeed * Time_DeltaTime());
}
if (GetAsyncKeyState('A') & 0x8000) {
newCameraPosition = newCameraPosition - (app::Transform_get_right(cameraControllerTransform, nullptr) * moveSpeed * Time_DeltaTime());
}
if (GetAsyncKeyState('D') & 0x8000) {
newCameraPosition = newCameraPosition + (app::Transform_get_right(cameraControllerTransform, nullptr) * moveSpeed * Time_DeltaTime());
}
// Mouse hareketlerini al
float deltaX = Input::GetAxis("Mouse X") * rotateSpeed;
float deltaY = Input::GetAxis("Mouse Y") * rotateSpeed;
// Kamerayı döndür
app::Quaternion rotationX = app::Quaternion_Euler(0, deltaX, 0, nullptr);
app::Quaternion rotationY = app::Quaternion_Euler(-deltaY, 0, 0, nullptr);
newCameraRotation = app::Quaternion_op_Multiply(newCameraRotation, rotationX, nullptr);
newCameraRotation = app::Quaternion_op_Multiply(rotationY, newCameraRotation, nullptr);
// Yeni pozisyon ve rotasyonu ayarla
app::Transform_set_position(cameraControllerTransform, newCameraPosition, nullptr);
app::Transform_set_rotation(cameraControllerTransform, newCameraRotation, nullptr);
}
if (settings::fly && IsLocalPlayer(__this)) {
float speed = settings::fly_speed;
@@ -147,7 +101,7 @@ void __stdcall hNolanBehaviour_Update(app::NolanBehaviour* __this, MethodInfo* m
if (transform) {
app::Vector3 pos = Transform::Position(transform);
app::Vector3 pos = Transform::GetPosition(transform);
if (GetAsyncKeyState('W') & 0x8000) {
pos = pos + (app::Transform_get_forward(transform, nullptr) * speed * Time_DeltaTime());
@@ -168,7 +122,6 @@ void __stdcall hNolanBehaviour_Update(app::NolanBehaviour* __this, MethodInfo* m
pos = pos - (app::Transform_get_up(transform, nullptr) * speed * Time_DeltaTime());
}
app::GameObject* thisGameObject = app::Component_get_gameObject((app::Component*)__this, nullptr);
if (thisGameObject != nullptr || !Object::IsNull((app::Object_1*)thisGameObject)) {

View File

@@ -48,5 +48,4 @@ namespace settings {
float new_azazel_speed = 0.f;
bool disable_longInteract = false;
bool freecam = false;
}

View File

@@ -49,7 +49,6 @@ namespace settings {
extern bool freeze_azazel;
extern float new_azazel_speed;
extern bool disable_longInteract;
extern bool freecam;
}
#endif