Skip to content

Commit

Permalink
Functional on BepInEx now
Browse files Browse the repository at this point in the history
Nothing added, it just works.
  • Loading branch information
Tribow committed Jul 30, 2024
1 parent 715c32f commit 11c69f8
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 83 deletions.
4 changes: 3 additions & 1 deletion CameraAdditions/CameraAdditions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Patches\Assembly-CSharp\AbstractCamMode\CamModeLateUpdate.cs" />
<Compile Include="Patches\Assembly-CSharp\CarCamera\BalanceFlyingCamera.cs" />
<Compile Include="Patches\Assembly-CSharp\CarCamera\IncrementCameraModes.cs" />
<Compile Include="Patches\Assembly-CSharp\CarCamera\SetCameraFOV.cs" />
<Compile Include="Patches\Assembly-CSharp\CarCamera\SetUserSelectedCameraModeIndex.cs" />
<Compile Include="Patches\Assembly-CSharp\ChaseCamMode\CamModeLateUpdate.cs" />
<Compile Include="Patches\Assembly-CSharp\CockpitCamMode\CamModeLateUpdate.cs" />
<Compile Include="Patches\Assembly-CSharp\MountedCamMode\CamModeLateUpdate.cs" />
<Compile Include="Patches\Assembly-CSharp\SpectatorFreeCamera\CamModeInitializer.cs" />
<Compile Include="Patches\Assembly-CSharp\WingsGadget\GadgetUpdateLocal.cs" />
<Compile Include="Plugin.cs" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using HarmonyLib;

namespace CameraAdditions.Patches
{
[HarmonyPatch(typeof(ChaseCamMode), "CamModeLateUpdate")]
internal static class ChaseCamMode__CamModeLateUpdate
{
[HarmonyPrefix]
internal static void PositionPrefix(ChaseCamMode __instance)
{
float zoomOffset;
//This is to prevent a super glitchy camera when zooming in too far
if (Mod.ZoomOffset.Value < -3f)
zoomOffset = -3f;
else
zoomOffset = Mod.ZoomOffset.Value;

__instance.maxDistanceLowSpeed_ = Mod.Instance.maxDistanceLowSpeed + zoomOffset;
__instance.maxDistanceHighSpeed_ = Mod.Instance.maxDistanceHighSpeed + zoomOffset;
__instance.minDistance_ = Mod.Instance.minDistance + zoomOffset;
__instance.height_ = Mod.Instance.height + (zoomOffset / 4.5f);

if (Mod.LockCameraPosition.Value)
{
__instance.maxDistanceLowSpeed_ = __instance.maxDistanceHighSpeed_;
}
}

[HarmonyPostfix]
internal static void PositionPostfix(ChaseCamMode __instance)
{
__instance.transform.position += __instance.transform.right * Mod.XOffset.Value;
__instance.transform.position += __instance.transform.up * Mod.YOffset.Value;

__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using HarmonyLib;

namespace CameraAdditions.Patches
{
[HarmonyPatch(typeof(CockpitCamMode), "CamModeLateUpdate")]
internal static class CockpitCamMode__CamModeLateUpdate
{
[HarmonyPostfix]
internal static void PositionPostfix(CockpitCamMode __instance)
{
__instance.transform.position += __instance.transform.right * (Mod.XOffset.Value / 10);
__instance.transform.position += __instance.transform.up * (Mod.YOffset.Value / 10);
__instance.transform.position += __instance.transform.forward * (Mod.ZoomOffset.Value / 10);

__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using HarmonyLib;

namespace CameraAdditions.Patches
{
[HarmonyPatch(typeof(MountedCamMode), "CamModeLateUpdate")]
internal static class MountedCamMode__CamModeLateUpdate
{
[HarmonyPostfix]
internal static void PositionPostfix(CockpitCamMode __instance)
{
__instance.transform.position += __instance.transform.right * (Mod.XOffset.Value / 10);
__instance.transform.position += __instance.transform.up * (Mod.YOffset.Value / 10);
__instance.transform.position += __instance.transform.forward * (Mod.ZoomOffset.Value / 10);

__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
}
}
}
40 changes: 15 additions & 25 deletions CameraAdditions/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ void Awake()
FOVOffset = Config.Bind<int>("General",
FOVOffsetKey,
0,
new ConfigDescription("Adjust the offset of the FOV (Affects all cameras)",
new AcceptableValueRange<int>(-50, 50)));
new ConfigDescription("Adjust the offset of the FOV (Affects all cameras)"));

LockFOV = Config.Bind<bool>("General",
LockFOVKey,
Expand All @@ -125,38 +124,32 @@ void Awake()
XOffset = Config.Bind<float>("Position Offsets",
XOffsetKey,
0f,
new ConfigDescription("Adjust the X axis offset of all Car Camera Modes",
new AcceptableValueRange<float>(-20f, 20f)));
new ConfigDescription("Adjust the X axis offset of all Car Camera Modes"));

YOffset = Config.Bind<float>("Position Offsets",
YOffsetKey,
0f,
new ConfigDescription("Adjust the Y axis offset of all Car Camera Modes",
new AcceptableValueRange<float>(-20f, 20f)));
new ConfigDescription("Adjust the Y axis offset of all Car Camera Modes"));

ZoomOffset = Config.Bind<float>("Position Offsets",
ZoomOffsetKey,
0f,
new ConfigDescription("Adjust the Z axis offset of all Car Camera Modes (For the Chase Camera it affects the Zoom, not the Z axis)",
new AcceptableValueRange<float>(-20f, 20f)));
new ConfigDescription("Adjust the Z axis offset of all Car Camera Modes (For the Chase Camera it affects the Zoom, not the Z axis)"));

XRotationOffset = Config.Bind<float>("Rotation Offsets",
XRotationOffsetKey,
0f,
new ConfigDescription("Adjust the X rotational offset of all Car Camera Modes",
new AcceptableValueRange<float>(-90f, 90f)));
new ConfigDescription("Adjust the X rotational offset of all Car Camera Modes"));

YRotationOffset = Config.Bind<float>("Rotation Offsets",
YRotationOffsetKey,
0f,
new ConfigDescription("Adjust the Y rotational offset of all Car Camera Modes",
new AcceptableValueRange<float>(-90f, 90f)));
new ConfigDescription("Adjust the Y rotational offset of all Car Camera Modes"));

ZRotationOffset = Config.Bind<float>("Rotation Offsets",
ZRotationOffsetKey,
0f,
new ConfigDescription("Adjust the Z rotational offset of all Car Camera Modes",
new AcceptableValueRange<float>(-90f, 90f)));
new ConfigDescription("Adjust the Z rotational offset of all Car Camera Modes"));

DefaultsShortcut = Config.Bind<KeyboardShortcut>("Shortcuts",
DefaultShortcutKey,
Expand Down Expand Up @@ -244,62 +237,59 @@ void Update()
if (EnableRotationShortcut.Value.IsDown())
shortcutsAffectRotation = !shortcutsAffectRotation;

if (IncreaseFOVShortcut.Value.IsDown())
if (IncreaseFOVShortcut.Value.IsPressed())
FOVOffset.Value++;

if (DecreaseFOVShortcut.Value.IsDown())
if (DecreaseFOVShortcut.Value.IsPressed())
FOVOffset.Value--;

if (IncreaseXOffsetShortcut.Value.IsDown())
if (IncreaseXOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
XOffset.Value += 0.25f;
else
XRotationOffset.Value += .5f;
}

if (DecreaseXOffsetShortcut.Value.IsDown())
if (DecreaseXOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
XOffset.Value -= 0.25f;
else
XRotationOffset.Value -= .5f;
}

if (IncreaseYOffsetShortcut.Value.IsDown())
if (IncreaseYOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
YOffset.Value += 0.25f;
else
YRotationOffset.Value += .5f;
}

if (DecreaseYOffsetShortcut.Value.IsDown())
if (DecreaseYOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
YOffset.Value -= 0.25f;
else
YRotationOffset.Value -= .5f;
}

if (IncreaseZOffsetShortcut.Value.IsDown())
if (IncreaseZOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
ZoomOffset.Value += 0.25f;
else
ZRotationOffset.Value += .5f;
}

if (DecreaseZOffsetShortcut.Value.IsDown())
if (DecreaseZOffsetShortcut.Value.IsPressed())
{
if (!shortcutsAffectRotation)
ZoomOffset.Value -= 0.25f;
else
ZRotationOffset.Value -= .5f;
}



}
}

Expand Down

0 comments on commit 11c69f8

Please sign in to comment.