Skip to content

Commit

Permalink
Add 2 new types to move camera
Browse files Browse the repository at this point in the history
  • Loading branch information
ComputerElite authored Sep 20, 2021
1 parent fb45f23 commit 42fc16c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 2 additions & 0 deletions include/ModConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -39,5 +40,6 @@ DECLARE_CONFIG(ModConfig,
CONFIG_INIT_VALUE(YRot);
CONFIG_INIT_VALUE(ZRot);
CONFIG_INIT_VALUE(MoveMultiplier);
CONFIG_INIT_VALUE(MoveController);
)
)
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions src/Play3rdPerViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)");
}
}
11 changes: 5 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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;

Expand Down

0 comments on commit 42fc16c

Please sign in to comment.