From 42fc16cd21ebb4eb3b8d4056169855864496106c Mon Sep 17 00:00:00 2001 From: ComputerElite <71177995+ComputerElite@users.noreply.github.com> Date: Mon, 20 Sep 2021 08:45:38 -0700 Subject: [PATCH] Add 2 new types to move camera --- Android.mk | 2 +- include/ModConfig.hpp | 2 ++ mod.json | 2 +- src/Play3rdPerViewController.cpp | 3 +++ src/main.cpp | 11 +++++------ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Android.mk b/Android.mk index b6f8765..c373391 100644 --- a/Android.mk +++ b/Android.mk @@ -62,7 +62,7 @@ LOCAL_SHARED_LIBRARIES += codegen LOCAL_SHARED_LIBRARIES += questui LOCAL_SHARED_LIBRARIES += custom-types LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"Play3rdPer"' -DVERSION='"0.4.0"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' +LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"Play3rdPer"' -DVERSION='"0.4.1"' -I'./shared' -I'./extern' -isystem'extern/codegen/include' LOCAL_CPPFLAGS += -std=c++2a LOCAL_C_INCLUDES += ./include ./src include $(BUILD_SHARED_LIBRARY) diff --git a/include/ModConfig.hpp b/include/ModConfig.hpp index 34bf916..c893433 100644 --- a/include/ModConfig.hpp +++ b/include/ModConfig.hpp @@ -20,6 +20,7 @@ DECLARE_CONFIG(ModConfig, CONFIG_VALUE(YRot, float, "Y Rot", 0); CONFIG_VALUE(ZRot, float, "Z Rot", 0); CONFIG_VALUE(MoveMultiplier, float, "Change movement multipler", 5.0f); + CONFIG_VALUE(MoveController, int, "Controls for moving the camera", 0); CONFIG_INIT_FUNCTION( CONFIG_INIT_VALUE(Active); @@ -39,5 +40,6 @@ DECLARE_CONFIG(ModConfig, CONFIG_INIT_VALUE(YRot); CONFIG_INIT_VALUE(ZRot); CONFIG_INIT_VALUE(MoveMultiplier); + CONFIG_INIT_VALUE(MoveController); ) ) \ No newline at end of file diff --git a/mod.json b/mod.json index 5769193..2a01e90 100644 --- a/mod.json +++ b/mod.json @@ -2,7 +2,7 @@ "_QPVersion": "0.1.1", "id": "Play3rdPer", "name": "Third Person mod", - "version": "0.4.0", + "version": "0.4.1", "author": "ComputerElite", "packageId": "com.beatgames.beatsaber", "packageVersion": "1.17.1", diff --git a/src/Play3rdPerViewController.cpp b/src/Play3rdPerViewController.cpp index aa00179..17d455d 100644 --- a/src/Play3rdPerViewController.cpp +++ b/src/Play3rdPerViewController.cpp @@ -93,5 +93,8 @@ void DidActivate(ViewController* self, bool firstActivation, bool addedToHierarc // ZR QuestUI::BeatSaberUI::AddHoverHint(AddConfigValueIncrementFloat(container->get_transform(), getModConfig().ZRot, 0, 5.0f, -360, 360)->get_gameObject(), "Offset on the z rotation"); + + // MoveController + QuestUI::BeatSaberUI::AddHoverHint(AddConfigValueIncrementInt(container->get_transform(), getModConfig().MoveController, 1, 0, 2)->get_gameObject(), "What is used to move the camera (0 = Head, 1 = Left Controller, 2 = Right Controller)"); } } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 637dbce..8f79b44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -72,9 +72,6 @@ UnityEngine::Vector3 saberRot = UnityEngine::Vector3(getModConfig().XRot.GetValu UnityEngine::Vector3 saberPos = UnityEngine::Vector3(getModConfig().XOffset.GetValue(), getModConfig().YOffset.GetValue(), getModConfig().ZOffset.GetValue()); UnityEngine::Vector3 prevPos = UnityEngine::Vector3(0.0f, 0.0f, 0.0f); -UnityEngine::Vector3 prevRot = UnityEngine::Vector3(0.0f, 0.0f, 0.0f); -// UnityEngine::Vector3 prevPosOffset = UnityEngine::Vector3(0.0f, 0.0f, 0.0f); -// UnityEngine::Vector3 prevRotOffset = UnityEngine::Vector3(0.0f, 0.0f, 0.0f); bool replay = false; float rotated = 0.0f; @@ -89,6 +86,7 @@ MAKE_HOOK_MATCH(LightManager_OnWillRenderObject, &LightManager::OnWillRenderObje UnityEngine::Vector3 rot = c->get_transform()->get_eulerAngles(); UnityEngine::Vector3 pos = c->get_transform()->get_position(); + if(getModConfig().LeftSaber.GetValue() && getModConfig().SwapSaber.GetValue() && rightController != nullptr) { saberPos = rightController->get_position(); saberRot = rightController->get_rotation().get_eulerAngles(); @@ -112,15 +110,16 @@ MAKE_HOOK_MATCH(LightManager_OnWillRenderObject, &LightManager::OnWillRenderObje } } else if(getModConfig().MoveWhilePlaying.GetValue()) { + UnityEngine::Vector3 diffPos = getModConfig().MoveController.GetValue() == 0 ? c->get_transform()->get_position() : (getModConfig().MoveController.GetValue() == 1 ? leftController->get_position() : rightController->get_position()); GlobalNamespace::OVRInput::Update(); if(GlobalNamespace::OVRInput::Get(GlobalNamespace::OVRInput::Button::Four, OVRInput::Controller::Touch)) { - UnityEngine::Vector3 posDifference = pos - prevPos; + UnityEngine::Vector3 posDifference = diffPos - prevPos; + getModConfig().XOffset.SetValue(posDifference.x * getModConfig().MoveMultiplier.GetValue() + getModConfig().XOffset.GetValue()); getModConfig().YOffset.SetValue(posDifference.y * getModConfig().MoveMultiplier.GetValue() + getModConfig().YOffset.GetValue()); getModConfig().ZOffset.SetValue(posDifference.z * getModConfig().MoveMultiplier.GetValue() + getModConfig().ZOffset.GetValue()); } - prevPos = pos; - prevRot = rot; + prevPos = diffPos; } else framesPressed = 0;