Skip to content

Commit 638fae8

Browse files
committed
Apply code style and formatting
1 parent daab53a commit 638fae8

File tree

11 files changed

+180
-151
lines changed

11 files changed

+180
-151
lines changed

TABGVR/Patches/AntiCheatBypass.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Reflection;
21
using Epic.OnlineServices.AntiCheatClient;
32
using HarmonyLib;
43
using Landfall;
@@ -8,20 +7,23 @@ namespace TABGVR.Patches;
87
public class AntiCheatBypass
98
{
109
/// <summary>
11-
/// Bypasses the anticheat.<br/>
12-
/// <b>WARNING: THIS KICKS YOU OFF OFFICIAL SERVERS!</b>
10+
/// Bypasses the anticheat.<br />
11+
/// <b>WARNING: THIS KICKS YOU OFF OFFICIAL SERVERS!</b>
1312
/// </summary>
1413
internal static void Bypass()
1514
{
1615
Harmony.CreateAndPatchAll(typeof(AntiCheatBypass), "com.redbigz.AntiCheatBypass");
17-
18-
Plugin.Logger.LogInfo("Just so you know, bypassing the Anti-Cheat cuts you off from official servers. Matchmaking has been disabled for your safety.");
16+
17+
Plugin.Logger.LogInfo(
18+
"Just so you know, bypassing the Anti-Cheat cuts you off from official servers. Matchmaking has been disabled for your safety.");
1919
}
20-
20+
2121
/// <summary>
22-
/// Patches <see cref="ACInterface"/> to disable AC.
22+
/// Patches <see cref="ACInterface" /> to disable AC.
2323
/// </summary>
24-
/// <param name="ACInterface"><see cref="ACInterface"/></param>
24+
/// <param name="ACInterface">
25+
/// <see cref="ACInterface" />
26+
/// </param>
2527
[HarmonyPatch(typeof(Easy_AC_Client), nameof(Easy_AC_Client.SetACInterface))]
2628
[HarmonyPrefix]
2729
private static bool SetACInterface(AntiCheatClientInterface ACInterface)
@@ -31,13 +33,15 @@ private static bool SetACInterface(AntiCheatClientInterface ACInterface)
3133
}
3234

3335
/// <summary>
34-
/// Patches <see cref="MatchmakingHandler"/> to raise a notification if you try to matchmake, as well as blocking the matchmaking process.
36+
/// Patches <see cref="MatchmakingHandler" /> to raise a notification if you try to matchmake, as well as blocking the
37+
/// matchmaking process.
3538
/// </summary>
3639
[HarmonyPatch(typeof(MatchmakingHandler), nameof(MatchmakingHandler.StartSearch))]
3740
[HarmonyPrefix]
3841
private static bool StartSearch()
3942
{
40-
GlobalCanvasSingleton.Instance.UIMessageBox.QueueMessage("Matchmaking disabled due to Anti-Cheat safety. Please use a community server when playing TABGVR.");
43+
GlobalCanvasSingleton.Instance.UIMessageBox.QueueMessage(
44+
"Matchmaking disabled due to Anti-Cheat safety. Please use a community server when playing TABGVR.");
4145
return false;
4246
}
4347
}

TABGVR/Patches/CameraPatch.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ namespace TABGVR.Patches;
1313
public class CameraPatch
1414
{
1515
/// <summary>
16-
/// Creates VR Camera after <see cref="PlayerCamera"/> starts.
16+
/// Creates VR Camera after <see cref="PlayerCamera" /> starts.
1717
/// </summary>
18-
/// <param name="__instance"><see cref="PlayerCamera"/></param>
18+
/// <param name="__instance">
19+
/// <see cref="PlayerCamera" />
20+
/// </param>
1921
[HarmonyPatch(nameof(PlayerCamera.Start))]
2022
[HarmonyPostfix]
2123
public static void Start(PlayerCamera __instance)
@@ -29,7 +31,7 @@ public static void Start(PlayerCamera __instance)
2931
transform =
3032
{
3133
parent = playerManager.playerRoot.transform.Find("CameraMovement"),
32-
position = __instance.transform.position,
34+
position = __instance.transform.position
3335
},
3436
tag = "MainCamera",
3537
layer = __instance.gameObject.layer

TABGVR/Patches/KinematicsPatch.cs

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
namespace TABGVR.Patches;
99

1010
[HarmonyPatch(typeof(Holding))]
11-
class KinematicsPatch
11+
internal class KinematicsPatch
1212
{
1313
internal static bool _gripAvailable;
1414
internal static bool _gripping;
1515

1616
/// <summary>
17-
/// Sets up hand connection for joint by removing properties that cause issues.
17+
/// Sets up hand connection for joint by removing properties that cause issues.
1818
/// </summary>
1919
/// <param name="joint">Hand Joint</param>
20-
static void SetupConnection(Rigidbody joint)
20+
private static void SetupConnection(Rigidbody joint)
2121
{
2222
// joint.GetComponentInChildren<Collider>().enabled = false;
2323

@@ -38,11 +38,11 @@ static void SetupConnection(Rigidbody joint)
3838
}
3939

4040
/// <summary>
41-
/// Updates <paramref name="joint"/>'s position to <paramref name="controller"/>.
41+
/// Updates <paramref name="joint" />'s position to <paramref name="controller" />.
4242
/// </summary>
4343
/// <param name="joint">Hand Joint</param>
44-
/// <param name="controller">VR Controller made by <see cref="Controllers"/></param>
45-
static void UpdateConnection(Rigidbody joint, GameObject controller)
44+
/// <param name="controller">VR Controller made by <see cref="Controllers" /></param>
45+
private static void UpdateConnection(Rigidbody joint, GameObject controller)
4646
{
4747
var controllerRelativeToGameCamera = controller.transform.position - Controllers.Head.transform.position +
4848
Camera.current.transform.position;
@@ -54,34 +54,35 @@ static void UpdateConnection(Rigidbody joint, GameObject controller)
5454
}
5555

5656
/// <summary>
57-
/// Position left hand to left hand attachment point on gun (handguard) instead of the VR controller to avoid visual weirdness.
57+
/// Position left hand to left hand attachment point on gun (handguard) instead of the VR controller to avoid visual
58+
/// weirdness.
5859
/// </summary>
5960
/// <param name="holding">Holding Script</param>
60-
static void PositionLeftHandToHandguard(Holding holding)
61+
private static void PositionLeftHandToHandguard(Holding holding)
6162
{
6263
holding.leftHand.MovePosition(holding.leftHand.position + holding.heldObject.leftHandPos.position -
6364
holding.leftHand.transform.GetChild(0).position);
6465
}
6566

6667
/// <summary>
67-
/// Sets up hands for VR IK after Holding.Start.
68+
/// Sets up hands for VR IK after Holding.Start.
6869
/// </summary>
6970
/// <param name="__instance">Holding Script</param>
7071
[HarmonyPatch(nameof(Holding.Start))]
7172
[HarmonyPostfix]
72-
static void StartPostfix(Holding __instance)
73+
private static void StartPostfix(Holding __instance)
7374
{
7475
SetupConnection(__instance.rightHand);
7576
SetupConnection(__instance.leftHand);
7677
}
7778

7879
/// <summary>
79-
/// Runs aiming and positioning for arms and guns after Holding.Update.
80+
/// Runs aiming and positioning for arms and guns after Holding.Update.
8081
/// </summary>
8182
/// <param name="__instance">Holding Script</param>
8283
[HarmonyPatch(nameof(Holding.Update))]
8384
[HarmonyPostfix]
84-
static void UpdatePostfix(Holding __instance)
85+
private static void UpdatePostfix(Holding __instance)
8586
{
8687
if (!Controllers.LeftHand || !Controllers.RightHand || !Controllers.Head) return;
8788
if (__instance.player != global::Player.localPlayer) return;
@@ -107,7 +108,10 @@ static void UpdatePostfix(Holding __instance)
107108
{
108109
if (_gripAvailable) _gripping = true;
109110
}
110-
else _gripping = false;
111+
else
112+
{
113+
_gripping = false;
114+
}
111115

112116
// look at left controller if gripping, or else just use the right controller rotation
113117
heldObject.gameObject.transform.rotation = _gripping
@@ -116,8 +120,8 @@ static void UpdatePostfix(Holding __instance)
116120
: Controllers.RightHand.transform.rotation *
117121
Quaternion.Euler(90f + rightHold.localRotation.x, rightHold.localRotation.y, 0f);
118122

119-
var toMove = (Controllers.RightHandFromGameCamera +
120-
heldObject.gameObject.transform.position - rightHold.position);
123+
var toMove = Controllers.RightHandFromGameCamera +
124+
heldObject.gameObject.transform.position - rightHold.position;
121125

122126
var rigidBody = heldObject.GetComponent<Rigidbody>();
123127

@@ -128,21 +132,27 @@ static void UpdatePostfix(Holding __instance)
128132

129133
heldObject.transform.position = toMove;
130134
}
131-
else _gripping = false;
135+
else
136+
{
137+
_gripping = false;
138+
}
132139

133140
if (_gripping) PositionLeftHandToHandguard(__instance);
134141
else UpdateConnection(__instance.leftHand, Controllers.LeftHand);
135142
}
136143

137144
/// <summary>
138-
/// Cancels Holding.ReachForPoint from running.
145+
/// Cancels Holding.ReachForPoint from running.
139146
/// </summary>
140147
[HarmonyPatch(nameof(Holding.ReachForPoint))]
141148
[HarmonyPrefix]
142-
static bool ReachForPointCanceller() => false;
149+
private static bool ReachForPointCanceller()
150+
{
151+
return false;
152+
}
143153

144154
/// <summary>
145-
/// Method that does nothing.
155+
/// Method that does nothing.
146156
/// </summary>
147157
/// <returns>IEnumerator that breaks on start</returns>
148158
private static IEnumerator DoNothing()
@@ -151,9 +161,11 @@ private static IEnumerator DoNothing()
151161
}
152162

153163
/// <summary>
154-
/// Cancels Holding.HoldWeaponStill from running.
164+
/// Cancels Holding.HoldWeaponStill from running.
155165
/// </summary>
156-
/// <param name="__result"><see cref="DoNothing"/></param>
166+
/// <param name="__result">
167+
/// <see cref="DoNothing" />
168+
/// </param>
157169
[HarmonyPatch(nameof(Holding.HoldweaponStill))]
158170
[HarmonyPrefix]
159171
private static bool HoldWeaponStillCanceller(ref IEnumerator __result)
@@ -163,9 +175,12 @@ private static bool HoldWeaponStillCanceller(ref IEnumerator __result)
163175
}
164176

165177
/// <summary>
166-
/// Cancels PlayerIKHandler.LateUpdate from running.
178+
/// Cancels PlayerIKHandler.LateUpdate from running.
167179
/// </summary>
168180
[HarmonyPatch(typeof(PlayerIKHandler), nameof(PlayerIKHandler.LateUpdate))]
169181
[HarmonyPrefix]
170-
static bool IKCanceller() => false;
182+
private static bool IKCanceller()
183+
{
184+
return false;
185+
}
171186
}

TABGVR/Patches/PlayerPatch.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ public class PlayerPatch
1111
private static Transform _rotationTarget;
1212
private static PlayerManager _playerManager;
1313

14-
14+
1515
/// <summary>
16-
/// Adds <see cref="VRControls"/> and <see cref="RotationTargetDriver"/> on local <see cref="Player"/>.
16+
/// Adds <see cref="VRControls" /> and <see cref="RotationTargetDriver" /> on local <see cref="Player" />.
1717
/// </summary>
1818
/// <param name="__instance"></param>
1919
[HarmonyPatch(nameof(global::Player.Start))]
2020
[HarmonyPostfix]
2121
public static void Start(global::Player __instance)
2222
{
23-
_playerManager = new(__instance.gameObject);
23+
_playerManager = new PlayerManager(__instance.gameObject);
2424

2525
if (!_playerManager.playerIsClient) return; // run the rest if we are the player
2626

TABGVR/Player/Controllers.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@
22
using UnityEngine;
33
using UnityEngine.SpatialTracking;
44
using UnityEngine.XR;
5-
using UnityEngine.XR.Interaction.Toolkit;
65

76
namespace TABGVR.Player;
87

98
public static class Controllers
109
{
1110
public static GameObject LeftHand, RightHand, Head;
1211

12+
13+
/// <summary>
14+
/// <see cref="InputDevice" />s of each hand.
15+
/// </summary>
16+
public static InputDevice LeftHandXR, RightHandXR;
17+
1318
/// <summary>
14-
/// Left hand Vector3 in relative space.
19+
/// Left hand Vector3 in relative space.
1520
/// </summary>
1621
public static Vector3 LeftHandFromGameCamera =>
1722
LeftHand.transform.position - Head.transform.position + Camera.current.transform.position;
1823

1924
/// <summary>
20-
/// Right hand Vector3 in relative space.
25+
/// Right hand Vector3 in relative space.
2126
/// </summary>
2227
public static Vector3 RightHandFromGameCamera =>
2328
RightHand.transform.position - Head.transform.position + Camera.current.transform.position;
2429

25-
26-
/// <summary>
27-
/// <see cref="InputDevice"/>s of each hand.
28-
/// </summary>
29-
public static InputDevice LeftHandXR, RightHandXR;
30-
3130
/// <summary>
32-
/// Sets up VR Controllers.
31+
/// Sets up VR Controllers.
3332
/// </summary>
3433
public static void Setup()
3534
{

TABGVR/Player/Mundanities/Grenades.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace TABGVR.Player.Mundanities;
55
public class Grenades
66
{
77
/// <summary>
8-
/// Selected Grenade.
8+
/// Selected Grenade.
99
/// </summary>
1010
[CanBeNull]
1111
public static Grenade SelectedGrenade =>

TABGVR/Player/PlayerManager.cs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,46 @@ namespace TABGVR.Player;
44

55
public class PlayerManager
66
{
7-
public GameObject playerRoot;
8-
public global::Player player;
7+
public static PlayerManager LocalPlayer;
8+
public Camera cameraComponent;
99

1010
public GameObject cameraObject;
11-
public Camera cameraComponent;
11+
public global::Player player;
1212

1313
public bool playerIsClient;
14-
15-
public static PlayerManager LocalPlayer;
14+
public GameObject playerRoot;
1615

1716
public PlayerManager(GameObject root)
1817
{
1918
playerRoot = root;
20-
19+
2120
player = root.GetComponent<global::Player>();
2221
playerIsClient = player == global::Player.localPlayer; // i think this works
23-
22+
2423
cameraObject = playerRoot.transform.FindChildRecursive("Main Camera").gameObject;
2524
cameraComponent = cameraObject.GetComponent<Camera>();
2625

2726
if (playerIsClient) LocalPlayer = this;
2827
}
2928

3029
/// <summary>
31-
/// Creates PlayerManager from game camera.
30+
/// Creates PlayerManager from game camera.
3231
/// </summary>
33-
/// <param name="camera">Player's <see cref="Camera"/></param>
34-
/// <returns><see cref="PlayerManager"/></returns>
35-
public static PlayerManager FromCamera(Camera camera) => new(camera.transform
36-
.parent // Pivot
37-
.parent // PositionShake
38-
.parent // RotationShake
39-
.parent // CameraPhysics
40-
.parent // CameraRotationY
41-
.parent // CameraRotationX
42-
.parent // CameraMovement
43-
.parent // Player
44-
.gameObject);
32+
/// <param name="camera">Player's <see cref="Camera" /></param>
33+
/// <returns>
34+
/// <see cref="PlayerManager" />
35+
/// </returns>
36+
public static PlayerManager FromCamera(Camera camera)
37+
{
38+
return new PlayerManager(camera.transform
39+
.parent // Pivot
40+
.parent // PositionShake
41+
.parent // RotationShake
42+
.parent // CameraPhysics
43+
.parent // CameraRotationY
44+
.parent // CameraRotationX
45+
.parent // CameraMovement
46+
.parent // Player
47+
.gameObject);
48+
}
4549
}

0 commit comments

Comments
 (0)