Skip to content

Commit 11c69f8

Browse files
committed
Functional on BepInEx now
Nothing added, it just works.
1 parent 715c32f commit 11c69f8

6 files changed

Lines changed: 98 additions & 83 deletions

File tree

CameraAdditions/CameraAdditions.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@
5555
</Reference>
5656
</ItemGroup>
5757
<ItemGroup>
58-
<Compile Include="Patches\Assembly-CSharp\AbstractCamMode\CamModeLateUpdate.cs" />
5958
<Compile Include="Patches\Assembly-CSharp\CarCamera\BalanceFlyingCamera.cs" />
6059
<Compile Include="Patches\Assembly-CSharp\CarCamera\IncrementCameraModes.cs" />
6160
<Compile Include="Patches\Assembly-CSharp\CarCamera\SetCameraFOV.cs" />
6261
<Compile Include="Patches\Assembly-CSharp\CarCamera\SetUserSelectedCameraModeIndex.cs" />
62+
<Compile Include="Patches\Assembly-CSharp\ChaseCamMode\CamModeLateUpdate.cs" />
63+
<Compile Include="Patches\Assembly-CSharp\CockpitCamMode\CamModeLateUpdate.cs" />
64+
<Compile Include="Patches\Assembly-CSharp\MountedCamMode\CamModeLateUpdate.cs" />
6365
<Compile Include="Patches\Assembly-CSharp\SpectatorFreeCamera\CamModeInitializer.cs" />
6466
<Compile Include="Patches\Assembly-CSharp\WingsGadget\GadgetUpdateLocal.cs" />
6567
<Compile Include="Plugin.cs" />

CameraAdditions/Patches/Assembly-CSharp/AbstractCamMode/CamModeLateUpdate.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using HarmonyLib;
2+
3+
namespace CameraAdditions.Patches
4+
{
5+
[HarmonyPatch(typeof(ChaseCamMode), "CamModeLateUpdate")]
6+
internal static class ChaseCamMode__CamModeLateUpdate
7+
{
8+
[HarmonyPrefix]
9+
internal static void PositionPrefix(ChaseCamMode __instance)
10+
{
11+
float zoomOffset;
12+
//This is to prevent a super glitchy camera when zooming in too far
13+
if (Mod.ZoomOffset.Value < -3f)
14+
zoomOffset = -3f;
15+
else
16+
zoomOffset = Mod.ZoomOffset.Value;
17+
18+
__instance.maxDistanceLowSpeed_ = Mod.Instance.maxDistanceLowSpeed + zoomOffset;
19+
__instance.maxDistanceHighSpeed_ = Mod.Instance.maxDistanceHighSpeed + zoomOffset;
20+
__instance.minDistance_ = Mod.Instance.minDistance + zoomOffset;
21+
__instance.height_ = Mod.Instance.height + (zoomOffset / 4.5f);
22+
23+
if (Mod.LockCameraPosition.Value)
24+
{
25+
__instance.maxDistanceLowSpeed_ = __instance.maxDistanceHighSpeed_;
26+
}
27+
}
28+
29+
[HarmonyPostfix]
30+
internal static void PositionPostfix(ChaseCamMode __instance)
31+
{
32+
__instance.transform.position += __instance.transform.right * Mod.XOffset.Value;
33+
__instance.transform.position += __instance.transform.up * Mod.YOffset.Value;
34+
35+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
36+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
37+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
38+
}
39+
}
40+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using HarmonyLib;
2+
3+
namespace CameraAdditions.Patches
4+
{
5+
[HarmonyPatch(typeof(CockpitCamMode), "CamModeLateUpdate")]
6+
internal static class CockpitCamMode__CamModeLateUpdate
7+
{
8+
[HarmonyPostfix]
9+
internal static void PositionPostfix(CockpitCamMode __instance)
10+
{
11+
__instance.transform.position += __instance.transform.right * (Mod.XOffset.Value / 10);
12+
__instance.transform.position += __instance.transform.up * (Mod.YOffset.Value / 10);
13+
__instance.transform.position += __instance.transform.forward * (Mod.ZoomOffset.Value / 10);
14+
15+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
16+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
17+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
18+
}
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using HarmonyLib;
2+
3+
namespace CameraAdditions.Patches
4+
{
5+
[HarmonyPatch(typeof(MountedCamMode), "CamModeLateUpdate")]
6+
internal static class MountedCamMode__CamModeLateUpdate
7+
{
8+
[HarmonyPostfix]
9+
internal static void PositionPostfix(CockpitCamMode __instance)
10+
{
11+
__instance.transform.position += __instance.transform.right * (Mod.XOffset.Value / 10);
12+
__instance.transform.position += __instance.transform.up * (Mod.YOffset.Value / 10);
13+
__instance.transform.position += __instance.transform.forward * (Mod.ZoomOffset.Value / 10);
14+
15+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.ZRotationOffset.Value, UnityEngine.Vector3.forward);
16+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.XRotationOffset.Value, UnityEngine.Vector3.right);
17+
__instance.transform.rotation *= UnityEngine.Quaternion.AngleAxis(Mod.YRotationOffset.Value, UnityEngine.Vector3.up);
18+
}
19+
}
20+
}

CameraAdditions/Plugin.cs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ void Awake()
108108
FOVOffset = Config.Bind<int>("General",
109109
FOVOffsetKey,
110110
0,
111-
new ConfigDescription("Adjust the offset of the FOV (Affects all cameras)",
112-
new AcceptableValueRange<int>(-50, 50)));
111+
new ConfigDescription("Adjust the offset of the FOV (Affects all cameras)"));
113112

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

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

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

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

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

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

161154
DefaultsShortcut = Config.Bind<KeyboardShortcut>("Shortcuts",
162155
DefaultShortcutKey,
@@ -244,62 +237,59 @@ void Update()
244237
if (EnableRotationShortcut.Value.IsDown())
245238
shortcutsAffectRotation = !shortcutsAffectRotation;
246239

247-
if (IncreaseFOVShortcut.Value.IsDown())
240+
if (IncreaseFOVShortcut.Value.IsPressed())
248241
FOVOffset.Value++;
249242

250-
if (DecreaseFOVShortcut.Value.IsDown())
243+
if (DecreaseFOVShortcut.Value.IsPressed())
251244
FOVOffset.Value--;
252245

253-
if (IncreaseXOffsetShortcut.Value.IsDown())
246+
if (IncreaseXOffsetShortcut.Value.IsPressed())
254247
{
255248
if (!shortcutsAffectRotation)
256249
XOffset.Value += 0.25f;
257250
else
258251
XRotationOffset.Value += .5f;
259252
}
260253

261-
if (DecreaseXOffsetShortcut.Value.IsDown())
254+
if (DecreaseXOffsetShortcut.Value.IsPressed())
262255
{
263256
if (!shortcutsAffectRotation)
264257
XOffset.Value -= 0.25f;
265258
else
266259
XRotationOffset.Value -= .5f;
267260
}
268261

269-
if (IncreaseYOffsetShortcut.Value.IsDown())
262+
if (IncreaseYOffsetShortcut.Value.IsPressed())
270263
{
271264
if (!shortcutsAffectRotation)
272265
YOffset.Value += 0.25f;
273266
else
274267
YRotationOffset.Value += .5f;
275268
}
276269

277-
if (DecreaseYOffsetShortcut.Value.IsDown())
270+
if (DecreaseYOffsetShortcut.Value.IsPressed())
278271
{
279272
if (!shortcutsAffectRotation)
280273
YOffset.Value -= 0.25f;
281274
else
282275
YRotationOffset.Value -= .5f;
283276
}
284277

285-
if (IncreaseZOffsetShortcut.Value.IsDown())
278+
if (IncreaseZOffsetShortcut.Value.IsPressed())
286279
{
287280
if (!shortcutsAffectRotation)
288281
ZoomOffset.Value += 0.25f;
289282
else
290283
ZRotationOffset.Value += .5f;
291284
}
292285

293-
if (DecreaseZOffsetShortcut.Value.IsDown())
286+
if (DecreaseZOffsetShortcut.Value.IsPressed())
294287
{
295288
if (!shortcutsAffectRotation)
296289
ZoomOffset.Value -= 0.25f;
297290
else
298291
ZRotationOffset.Value -= .5f;
299292
}
300-
301-
302-
303293
}
304294
}
305295

0 commit comments

Comments
 (0)