From 256830e55785805620096b9d50b6c0851c93588a Mon Sep 17 00:00:00 2001 From: Mister_Nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 29 Oct 2021 23:00:13 +0100 Subject: [PATCH] cleanup --- .../NPC/Patches/CharacterAnimationPatches.cs | 3 +-- .../WorldObjects/QSBSolanumAnimController.cs | 2 +- .../NPC/WorldObjects/QSBTravelerController.cs | 4 +--- QSB/ConversationSync/CameraFacingBillboard.cs | 2 +- QSB/DeathSync/Patches/DeathPatches.cs | 5 +---- QSB/FrequencySync/Patches/FrequencyPatches.cs | 4 ++-- QSB/ItemSync/Patches/ItemPatches.cs | 2 +- QSB/Menus/MenuManager.cs | 4 ++-- QSB/Patches/QSBPatch.cs | 5 +---- QSB/Patches/QSBPatchManager.cs | 1 - .../Patches/ServerQuantumPatches.cs | 18 ++++++++-------- .../QSBMultiStateQuantumObject.cs | 3 +-- QSB/ShipSync/Patches/ShipPatches.cs | 21 ++++++------------- QSB/Syncs/IntermediaryTransform.cs | 1 - .../Rigidbodies/SectoredRigidbodySync.cs | 4 ++-- QSB/Syncs/SyncBase.cs | 5 +---- QSB/Utility/DebugGUI.cs | 1 - QSB/Utility/Events/DebugEvent.cs | 5 +---- QSB/WorldSync/QSBWorldSync.cs | 1 - QSB/WorldSync/WorldObjectManager.cs | 2 +- 20 files changed, 32 insertions(+), 61 deletions(-) diff --git a/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs b/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs index f6993145..f521a7b1 100644 --- a/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs +++ b/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs @@ -8,7 +8,6 @@ using QSB.Player; using QSB.Utility; using QSB.WorldSync; using System.Linq; -using System.Reflection; using UnityEngine; namespace QSB.Animation.NPC.Patches @@ -108,7 +107,7 @@ namespace QSB.Animation.NPC.Patches var qsbObj = QSBWorldSync.GetWorldFromUnity(__instance); var playersInHeadZone = qsbObj.GetPlayersInHeadZone(); - Transform targetCamera = playersInHeadZone == null || playersInHeadZone.Count == 0 + var targetCamera = playersInHeadZone == null || playersInHeadZone.Count == 0 ? __instance._playerCameraTransform : QSBPlayerManager.GetClosestPlayerToWorldPoint(playersInHeadZone, __instance.transform.position).CameraBody.transform; diff --git a/QSB/Animation/NPC/WorldObjects/QSBSolanumAnimController.cs b/QSB/Animation/NPC/WorldObjects/QSBSolanumAnimController.cs index 5b1cba12..b4e127de 100644 --- a/QSB/Animation/NPC/WorldObjects/QSBSolanumAnimController.cs +++ b/QSB/Animation/NPC/WorldObjects/QSBSolanumAnimController.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace QSB.Animation.NPC.WorldObjects { - class QSBSolanumAnimController : WorldObject + internal class QSBSolanumAnimController : WorldObject { private readonly List _playersInHeadZone = new List(); diff --git a/QSB/Animation/NPC/WorldObjects/QSBTravelerController.cs b/QSB/Animation/NPC/WorldObjects/QSBTravelerController.cs index 9914aa3c..52700584 100644 --- a/QSB/Animation/NPC/WorldObjects/QSBTravelerController.cs +++ b/QSB/Animation/NPC/WorldObjects/QSBTravelerController.cs @@ -1,6 +1,4 @@ -using OWML.Utils; - -namespace QSB.Animation.NPC.WorldObjects +namespace QSB.Animation.NPC.WorldObjects { internal class QSBTravelerController : NpcAnimController { diff --git a/QSB/ConversationSync/CameraFacingBillboard.cs b/QSB/ConversationSync/CameraFacingBillboard.cs index 74b0630c..55e3ce0d 100644 --- a/QSB/ConversationSync/CameraFacingBillboard.cs +++ b/QSB/ConversationSync/CameraFacingBillboard.cs @@ -22,7 +22,7 @@ public class CameraFacingBillboard : MonoBehaviour UpdateRotation(); } - void LateUpdate() + private void LateUpdate() => UpdateRotation(); private void UpdateRotation() diff --git a/QSB/DeathSync/Patches/DeathPatches.cs b/QSB/DeathSync/Patches/DeathPatches.cs index 28c9ddfe..9a768393 100644 --- a/QSB/DeathSync/Patches/DeathPatches.cs +++ b/QSB/DeathSync/Patches/DeathPatches.cs @@ -209,10 +209,7 @@ namespace QSB.DeathSync.Patches [HarmonyPostfix] [HarmonyPatch(typeof(DeathManager), nameof(DeathManager.KillPlayer))] - public static void DeathManager_KillPlayer_Postfix(DeathType deathType) - { - QSBEventManager.FireEvent(EventNames.QSBPlayerDeath, deathType); - } + public static void DeathManager_KillPlayer_Postfix(DeathType deathType) => QSBEventManager.FireEvent(EventNames.QSBPlayerDeath, deathType); [HarmonyPostfix] [HarmonyPatch(typeof(ShipDamageController), nameof(ShipDamageController.Awake))] diff --git a/QSB/FrequencySync/Patches/FrequencyPatches.cs b/QSB/FrequencySync/Patches/FrequencyPatches.cs index a7ad6a5a..029a5b17 100644 --- a/QSB/FrequencySync/Patches/FrequencyPatches.cs +++ b/QSB/FrequencySync/Patches/FrequencyPatches.cs @@ -11,12 +11,12 @@ namespace QSB.FrequencySync.Patches [HarmonyPostfix] [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IdentifyFrequency))] - static void IdentifyFrequencyEvent(SignalFrequency ____frequency) + public static void IdentifyFrequencyEvent(SignalFrequency ____frequency) => QSBEventManager.FireEvent(EventNames.QSBIdentifyFrequency, ____frequency); [HarmonyPostfix] [HarmonyPatch(typeof(AudioSignal), nameof(AudioSignal.IdentifySignal))] - static void IdentifySignalEvent(SignalName ____name) + public static void IdentifySignalEvent(SignalName ____name) => QSBEventManager.FireEvent(EventNames.QSBIdentifySignal, ____name); } } diff --git a/QSB/ItemSync/Patches/ItemPatches.cs b/QSB/ItemSync/Patches/ItemPatches.cs index d515a122..95274a00 100644 --- a/QSB/ItemSync/Patches/ItemPatches.cs +++ b/QSB/ItemSync/Patches/ItemPatches.cs @@ -70,7 +70,7 @@ namespace QSB.ItemSync.Patches sector = sectorGroup.GetSector(); if (sector == null && sectorGroup is SectorCullGroup) { - SectorProxy controllingProxy = (sectorGroup as SectorCullGroup).GetControllingProxy(); + var controllingProxy = (sectorGroup as SectorCullGroup).GetControllingProxy(); if (controllingProxy != null) { sector = controllingProxy.GetSector(); diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs index b2077ad5..c0a0fa3d 100644 --- a/QSB/Menus/MenuManager.cs +++ b/QSB/Menus/MenuManager.cs @@ -5,7 +5,7 @@ using UnityEngine.UI; namespace QSB.Menus { - class MenuManager : MonoBehaviour + internal class MenuManager : MonoBehaviour { public static MenuManager Instance; @@ -27,7 +27,7 @@ namespace QSB.Menus QSBNetworkManager.Instance.OnClientErrorThrown += OnClientError; } - void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isUniverse) + private void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isUniverse) { if (isUniverse) { diff --git a/QSB/Patches/QSBPatch.cs b/QSB/Patches/QSBPatch.cs index bf1f7af5..1841ab15 100644 --- a/QSB/Patches/QSBPatch.cs +++ b/QSB/Patches/QSBPatch.cs @@ -6,9 +6,6 @@ namespace QSB.Patches { public abstract QSBPatchTypes Type { get; } - public void DoPatches(Harmony instance) - { - instance.PatchAll(GetType()); - } + public void DoPatches(Harmony instance) => instance.PatchAll(GetType()); } } \ No newline at end of file diff --git a/QSB/Patches/QSBPatchManager.cs b/QSB/Patches/QSBPatchManager.cs index c0bb40f6..996d70aa 100644 --- a/QSB/Patches/QSBPatchManager.cs +++ b/QSB/Patches/QSBPatchManager.cs @@ -1,6 +1,5 @@ using HarmonyLib; using OWML.Common; -using OWML.Utils; using QSB.Animation.NPC.Patches; using QSB.Animation.Patches; using QSB.CampfireSync.Patches; diff --git a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs index bce27264..d332a500 100644 --- a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs +++ b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs @@ -73,12 +73,12 @@ namespace QSB.QuantumSync.Patches return false; } - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { - FindStateAndOrbit(__instance, out int stateIndex, out int orbitIndex); + FindStateAndOrbit(__instance, out var stateIndex, out var orbitIndex); + + GetTargetPosition(__instance, stateIndex, orbitIndex, out var orbitRadius, out var bodyToOrbit, out var targetPosition, out var onUnitSphere); - GetTargetPosition(__instance, stateIndex, orbitIndex, out float orbitRadius, out OWRigidbody bodyToOrbit, out Vector3 targetPosition, out Vector3 onUnitSphere); - if (!Physics.CheckSphere(targetPosition, __instance._sphereCheckRadius, OWLayerMask.physicalMask) || __instance._collapseToIndex != -1) { __instance._visibilityTracker.transform.position = targetPosition; @@ -139,7 +139,7 @@ namespace QSB.QuantumSync.Patches : __instance.GetRandomStateIndex(); orbitIndex = -1; - for (int j = 0; j < __instance._orbits.Length; j++) + for (var j = 0; j < __instance._orbits.Length; j++) { if (__instance._orbits[j].GetStateIndex() == stateIndex) { @@ -163,11 +163,11 @@ namespace QSB.QuantumSync.Patches } __instance._visibilityTracker.transform.localPosition = Vector3.zero; __instance._constantForceDetector.AddConstantVolume(bodyToOrbit.GetAttachedGravityVolume(), true, true); - Vector3 bodyVelocity = bodyToOrbit.GetVelocity(); + var bodyVelocity = bodyToOrbit.GetVelocity(); if (__instance._useInitialMotion) { - InitialMotion component = bodyToOrbit.GetComponent(); + var component = bodyToOrbit.GetComponent(); bodyVelocity = (component != null) ? component.GetInitVelocity() : Vector3.zero; @@ -182,7 +182,7 @@ namespace QSB.QuantumSync.Patches __instance._collapseToIndex = -1; foundNewPosition = true; - for (int k = 0; k < __instance._stateSkipCounts.Length; k++) + for (var k = 0; k < __instance._stateSkipCounts.Length; k++) { __instance._stateSkipCounts[k] = (k == __instance._stateIndex) ? 0 @@ -207,7 +207,7 @@ namespace QSB.QuantumSync.Patches __instance._referenceFrameVolume.gameObject.SetActive(__instance._stateIndex != 5); __instance._moonBody.SetIsTargetable(__instance._stateIndex != 5); - for (int l = 0; l < __instance._deactivateAtEye.Length; l++) + for (var l = 0; l < __instance._deactivateAtEye.Length; l++) { __instance._deactivateAtEye[l].SetActive(__instance._stateIndex != 5); } diff --git a/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs b/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs index 021fa8ea..65e82d62 100644 --- a/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs +++ b/QSB/QuantumSync/WorldObjects/QSBMultiStateQuantumObject.cs @@ -1,5 +1,4 @@ -using OWML.Utils; -using QSB.Utility; +using QSB.Utility; using QSB.WorldSync; using System.Collections.Generic; using System.Linq; diff --git a/QSB/ShipSync/Patches/ShipPatches.cs b/QSB/ShipSync/Patches/ShipPatches.cs index 0d3c5c9a..da558a15 100644 --- a/QSB/ShipSync/Patches/ShipPatches.cs +++ b/QSB/ShipSync/Patches/ShipPatches.cs @@ -55,10 +55,7 @@ namespace QSB.ShipSync.Patches [HarmonyReversePatch] [HarmonyPatch(typeof(SingleInteractionVolume), nameof(SingleInteractionVolume.UpdateInteractVolume))] - public static void SingleInteractionVolume_UpdateInteractVolume_Stub(object instance) - { - throw new NotImplementedException(); - } + public static void SingleInteractionVolume_UpdateInteractVolume_Stub(object instance) => throw new NotImplementedException(); [HarmonyPrefix] [HarmonyPatch(typeof(InteractZone), nameof(InteractZone.UpdateInteractVolume))] @@ -87,39 +84,33 @@ namespace QSB.ShipSync.Patches ? angle <= 80 : angle >= 280; - SingleInteractionVolume_UpdateInteractVolume_Stub(__instance as SingleInteractionVolume); + SingleInteractionVolume_UpdateInteractVolume_Stub(__instance); return false; } [HarmonyReversePatch] [HarmonyPatch(typeof(ShipComponent), nameof(ShipComponent.OnEnterShip))] - public static void ShipComponent_OnEnterShip_Stub(object instance) - { - throw new NotImplementedException(); - } + public static void ShipComponent_OnEnterShip_Stub(object instance) => throw new NotImplementedException(); [HarmonyPrefix] [HarmonyPatch(typeof(ShipElectricalComponent), nameof(ShipElectricalComponent.OnEnterShip))] public static bool ShipElectricalComponent_OnEnterShip(ShipElectricalComponent __instance) { - ShipComponent_OnEnterShip_Stub(__instance as ShipComponent); + ShipComponent_OnEnterShip_Stub(__instance); return false; } [HarmonyReversePatch] [HarmonyPatch(typeof(ShipComponent), nameof(ShipComponent.OnExitShip))] - public static void ShipComponent_OnExitShip_Stub(object instance) - { - throw new NotImplementedException(); - } + public static void ShipComponent_OnExitShip_Stub(object instance) => throw new NotImplementedException(); [HarmonyPrefix] [HarmonyPatch(typeof(ShipElectricalComponent), nameof(ShipElectricalComponent.OnExitShip))] public static bool ShipElectricalComponent_OnExitShip(ShipElectricalComponent __instance) { - ShipComponent_OnExitShip_Stub(__instance as ShipComponent); + ShipComponent_OnExitShip_Stub(__instance); return false; } diff --git a/QSB/Syncs/IntermediaryTransform.cs b/QSB/Syncs/IntermediaryTransform.cs index f4ec1ae8..48e02708 100644 --- a/QSB/Syncs/IntermediaryTransform.cs +++ b/QSB/Syncs/IntermediaryTransform.cs @@ -1,6 +1,5 @@ using OWML.Common; using QSB.Utility; -using System; using UnityEngine; namespace QSB.Syncs diff --git a/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs b/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs index dba1c782..1af9a39c 100644 --- a/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs +++ b/QSB/Syncs/Sectored/Rigidbodies/SectoredRigidbodySync.cs @@ -126,8 +126,8 @@ namespace QSB.Syncs.Sectored.Rigidbodies return false; } - Vector3 positionToSet = targetPos; - Quaternion rotationToSet = targetRot; + var positionToSet = targetPos; + var rotationToSet = targetRot; if (UseInterpolation) { diff --git a/QSB/Syncs/SyncBase.cs b/QSB/Syncs/SyncBase.cs index 1c98238c..988231d3 100644 --- a/QSB/Syncs/SyncBase.cs +++ b/QSB/Syncs/SyncBase.cs @@ -164,10 +164,7 @@ namespace QSB.Syncs _isInitialized = true; } - protected virtual void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse) - { - _isInitialized = false; - } + protected virtual void OnSceneLoaded(OWScene oldScene, OWScene newScene, bool isInUniverse) => _isInitialized = false; public override void Update() { diff --git a/QSB/Utility/DebugGUI.cs b/QSB/Utility/DebugGUI.cs index d09d0baf..4e4b58d0 100644 --- a/QSB/Utility/DebugGUI.cs +++ b/QSB/Utility/DebugGUI.cs @@ -2,7 +2,6 @@ using QSB.ClientServerStateSync; using QSB.OrbSync.TransformSync; using QSB.Player; -using QSB.ProbeSync.TransformSync; using QSB.Syncs; using QSB.TimeSync; using UnityEngine; diff --git a/QSB/Utility/Events/DebugEvent.cs b/QSB/Utility/Events/DebugEvent.cs index 0cde719a..03669c86 100644 --- a/QSB/Utility/Events/DebugEvent.cs +++ b/QSB/Utility/Events/DebugEvent.cs @@ -18,10 +18,7 @@ namespace QSB.Utility.Events EnumValue = type }; - public override void OnReceiveLocal(bool isHost, EnumMessage message) - { - OnReceiveRemote(isHost, message); - } + public override void OnReceiveLocal(bool isHost, EnumMessage message) => OnReceiveRemote(isHost, message); public override void OnReceiveRemote(bool isHost, EnumMessage message) { diff --git a/QSB/WorldSync/QSBWorldSync.cs b/QSB/WorldSync/QSBWorldSync.cs index a73c9df3..ed30a1c3 100644 --- a/QSB/WorldSync/QSBWorldSync.cs +++ b/QSB/WorldSync/QSBWorldSync.cs @@ -4,7 +4,6 @@ using QSB.OrbSync.WorldObjects; using QSB.Utility; using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using UnityEngine; diff --git a/QSB/WorldSync/WorldObjectManager.cs b/QSB/WorldSync/WorldObjectManager.cs index f5fbfb36..8bb38da7 100644 --- a/QSB/WorldSync/WorldObjectManager.cs +++ b/QSB/WorldSync/WorldObjectManager.cs @@ -79,7 +79,7 @@ namespace QSB.WorldSync worldObject.PostInit(); } } - + protected abstract void RebuildWorldObjects(OWScene scene); } }