diff --git a/QNetWeaver/NetworkBehaviourProcessor.cs b/QNetWeaver/NetworkBehaviourProcessor.cs index b6973206..7f4eb714 100644 --- a/QNetWeaver/NetworkBehaviourProcessor.cs +++ b/QNetWeaver/NetworkBehaviourProcessor.cs @@ -1898,7 +1898,7 @@ namespace QNetWeaver CheckForHookFunction(fd, out var methodDefinition2); if (methodDefinition2 != null) { - + ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.NetworkServerGetLocalClientActive)); ilprocessor.Append(ilprocessor.Create(OpCodes.Brfalse, noOperatorInstruction)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); diff --git a/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs b/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs index 59003661..bc50442e 100644 --- a/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs +++ b/QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs @@ -72,15 +72,15 @@ namespace QSB.Animation.NPC.Patches playerToUse = QSBPlayerManager.GetClosestPlayerToWorldPoint(__instance.transform.position, true); } - var localPosition = playerToUse != null - ? ____animator.transform.InverseTransformPoint(playerToUse.CameraBody.transform.position) + var localPosition = playerToUse != null + ? ____animator.transform.InverseTransformPoint(playerToUse.CameraBody.transform.position) : Vector3.zero; var targetWeight = ___headTrackingWeight; if (___lookOnlyWhenTalking) { - if (!____inConversation - || qsbObj.GetPlayersInHeadZone().Count == 0 + if (!____inConversation + || qsbObj.GetPlayersInHeadZone().Count == 0 || !qsbObj.GetPlayersInHeadZone().Contains(playerToUse)) { targetWeight *= 0; @@ -88,7 +88,7 @@ namespace QSB.Animation.NPC.Patches } else { - if (qsbObj.GetPlayersInHeadZone().Count == 0 + if (qsbObj.GetPlayersInHeadZone().Count == 0 || !qsbObj.GetPlayersInHeadZone().Contains(playerToUse)) { targetWeight *= 0; diff --git a/QSB/Animation/NPC/WorldObjects/NpcAnimController.cs b/QSB/Animation/NPC/WorldObjects/NpcAnimController.cs index 9ffd5343..835d3fc6 100644 --- a/QSB/Animation/NPC/WorldObjects/NpcAnimController.cs +++ b/QSB/Animation/NPC/WorldObjects/NpcAnimController.cs @@ -14,10 +14,10 @@ namespace QSB.Animation.NPC.WorldObjects public abstract CharacterDialogueTree GetDialogueTree(); - public virtual void StartConversation() + public virtual void StartConversation() => QSBWorldSync.RaiseEvent(GetDialogueTree(), "OnStartConversation"); - public virtual void EndConversation() + public virtual void EndConversation() => QSBWorldSync.RaiseEvent(GetDialogueTree(), "OnEndConversation"); public abstract bool InConversation(); diff --git a/QSB/Animation/NPC/WorldObjects/QSBCharacterAnimController.cs b/QSB/Animation/NPC/WorldObjects/QSBCharacterAnimController.cs index 150d0493..56f4b6bd 100644 --- a/QSB/Animation/NPC/WorldObjects/QSBCharacterAnimController.cs +++ b/QSB/Animation/NPC/WorldObjects/QSBCharacterAnimController.cs @@ -8,7 +8,7 @@ namespace QSB.Animation.NPC.WorldObjects { private readonly List _playersInHeadZone = new List(); - public List GetPlayersInHeadZone() + public List GetPlayersInHeadZone() => _playersInHeadZone; public void AddPlayerToHeadZone(PlayerInfo player) @@ -18,7 +18,7 @@ namespace QSB.Animation.NPC.WorldObjects return; } - _playersInHeadZone.Add(player); + _playersInHeadZone.Add(player); } public void RemovePlayerFromHeadZone(PlayerInfo player) @@ -31,10 +31,10 @@ namespace QSB.Animation.NPC.WorldObjects _playersInHeadZone.Remove(player); } - public override CharacterDialogueTree GetDialogueTree() + public override CharacterDialogueTree GetDialogueTree() => AttachedObject.GetValue("_dialogueTree"); - public override bool InConversation() + public override bool InConversation() => AttachedObject.GetValue("_inConversation"); } } diff --git a/QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs b/QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs index df5a00d7..94b3d5b4 100644 --- a/QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs +++ b/QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs @@ -16,7 +16,7 @@ namespace QSB.Animation.Player.Thrusters public Vector3 LocalAcceleration => _localAcceleration; public bool IsThrusting => _isThrusting; - public void Init(ThrusterModel model) + public void Init(ThrusterModel model) => _thrusterModel = model; public void Update() diff --git a/QSB/ElevatorSync/Patches/ElevatorPatches.cs b/QSB/ElevatorSync/Patches/ElevatorPatches.cs index 8ce5a270..f1665b1a 100644 --- a/QSB/ElevatorSync/Patches/ElevatorPatches.cs +++ b/QSB/ElevatorSync/Patches/ElevatorPatches.cs @@ -17,7 +17,7 @@ namespace QSB.ElevatorSync.Patches QSBEventManager.FireEvent(EventNames.QSBStartLift, id, isGoingUp); } - public override void DoPatches() + public override void DoPatches() => Postfix(nameof(Elevator_StartLift)); } } \ No newline at end of file diff --git a/QSB/Inputs/QSBInputManager.cs b/QSB/Inputs/QSBInputManager.cs index 2f9c0557..840ffeb0 100644 --- a/QSB/Inputs/QSBInputManager.cs +++ b/QSB/Inputs/QSBInputManager.cs @@ -51,7 +51,7 @@ namespace QSB.Inputs public static QSBInputManager Instance { get; private set; } - public void Start() + public void Start() => Instance = this; public bool InputsEnabled { get; private set; } = true; diff --git a/QSB/Patches/QSBPatch.cs b/QSB/Patches/QSBPatch.cs index 7c5fd46a..a6fab6d4 100644 --- a/QSB/Patches/QSBPatch.cs +++ b/QSB/Patches/QSBPatch.cs @@ -4,7 +4,6 @@ using OWML.Utils; using QSB.Utility; using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; namespace QSB.Patches @@ -35,10 +34,10 @@ namespace QSB.Patches QSBCore.Helper.HarmonyHelper.EmptyMethod(method); } - public void Prefix(string patchName) + public void Prefix(string patchName) => DoPrefixPostfix(true, patchName); - public void Postfix(string patchName) + public void Postfix(string patchName) => DoPrefixPostfix(false, patchName); private void DoPrefixPostfix(bool isPrefix, string patchName) diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index cd315439..92753e81 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -14,12 +14,9 @@ using QSB.Patches; using QSB.Player; using QSB.Player.TransformSync; using QSB.PoolSync; -using QSB.ProbeSync.TransformSync; using QSB.QuantumSync; -using QSB.QuantumSync.WorldObjects; using QSB.SectorSync; using QSB.ShipSync; -using QSB.ShipSync.TransformSync; using QSB.StatueSync; using QSB.TimeSync; using QSB.TranslationSync; @@ -27,9 +24,6 @@ using QSB.Utility; using QSB.WorldSync; using QuantumUNET; using QuantumUNET.Components; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; using UnityEngine; /* diff --git a/QSB/QuantumSync/Patches/ClientQuantumPatches.cs b/QSB/QuantumSync/Patches/ClientQuantumPatches.cs index a510704e..a25933d4 100644 --- a/QSB/QuantumSync/Patches/ClientQuantumPatches.cs +++ b/QSB/QuantumSync/Patches/ClientQuantumPatches.cs @@ -16,7 +16,7 @@ namespace QSB.QuantumSync.Patches public static void QuantumMoon_Start(QuantumMoon __instance) => __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { -1 }); - public static bool QuantumMoon_ChangeQuantumState() + public static bool QuantumMoon_ChangeQuantumState() => false; } } \ No newline at end of file diff --git a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs index 7e4c8d26..49427de1 100644 --- a/QSB/QuantumSync/Patches/ServerQuantumPatches.cs +++ b/QSB/QuantumSync/Patches/ServerQuantumPatches.cs @@ -87,7 +87,7 @@ namespace QSB.QuantumSync.Patches } // If there are players in the shrine and the shrine is not lit - if(inShrinePlayers.Count() != 0 && !shrineLit) + if (inShrinePlayers.Count() != 0 && !shrineLit) { __result = false; return false; diff --git a/QSB/SectorSync/QSBSectorManager.cs b/QSB/SectorSync/QSBSectorManager.cs index 895981c7..6658e595 100644 --- a/QSB/SectorSync/QSBSectorManager.cs +++ b/QSB/SectorSync/QSBSectorManager.cs @@ -31,8 +31,8 @@ namespace QSB.SectorSync continue; } - if ((sync as QNetworkBehaviour).HasAuthority - && sync.AttachedObject.gameObject.activeInHierarchy + if ((sync as QNetworkBehaviour).HasAuthority + && sync.AttachedObject.gameObject.activeInHierarchy && sync.IsReady) { CheckTransformSyncSector(sync); diff --git a/QSB/SectorSync/SectorSync.cs b/QSB/SectorSync/SectorSync.cs index 65795145..6d8b52e6 100644 --- a/QSB/SectorSync/SectorSync.cs +++ b/QSB/SectorSync/SectorSync.cs @@ -92,7 +92,7 @@ namespace QSB.SectorSync } var numSectorsCurrentlyIn = SectorList.Count(x => x.ShouldSyncTo(_targetType)); - + var listToCheck = numSectorsCurrentlyIn == 0 ? QSBWorldSync.GetWorldObjects().Where(x => !x.IsFakeSector && x.Type != Sector.Name.Unnamed) : SectorList; @@ -149,7 +149,7 @@ namespace QSB.SectorSync return 0f; } - + public static float GetRelativeVelocity(QSBSector sector, OWRigidbody rigidbody) { var sectorRigidBody = sector.AttachedObject.GetOWRigidbody(); diff --git a/QSB/ShipSync/Events/FlyShipEvent.cs b/QSB/ShipSync/Events/FlyShipEvent.cs index 6d2e017b..d44aa0b0 100644 --- a/QSB/ShipSync/Events/FlyShipEvent.cs +++ b/QSB/ShipSync/Events/FlyShipEvent.cs @@ -53,8 +53,8 @@ namespace QSB.ShipSync.Events private void SetCurrentFlyer(bool isFlying, uint id) { - ShipManager.Instance.CurrentFlyer = isFlying - ? id + ShipManager.Instance.CurrentFlyer = isFlying + ? id : uint.MaxValue; if (QSBCore.IsServer) diff --git a/QSB/ShipSync/Events/FunnelEnableEvent.cs b/QSB/ShipSync/Events/FunnelEnableEvent.cs index ac7498fd..c7cae686 100644 --- a/QSB/ShipSync/Events/FunnelEnableEvent.cs +++ b/QSB/ShipSync/Events/FunnelEnableEvent.cs @@ -20,7 +20,7 @@ namespace QSB.ShipSync.Events AboutId = LocalPlayerId }; - public override void OnReceiveRemote(bool server, PlayerMessage message) + public override void OnReceiveRemote(bool server, PlayerMessage message) => ShipManager.Instance.ShipTractorBeam.ActivateTractorBeam(); } } diff --git a/QSB/ShipSync/Events/HatchEvent.cs b/QSB/ShipSync/Events/HatchEvent.cs index a6d27d5b..d1dcb503 100644 --- a/QSB/ShipSync/Events/HatchEvent.cs +++ b/QSB/ShipSync/Events/HatchEvent.cs @@ -8,10 +8,10 @@ namespace QSB.ShipSync.Events { public override QSB.Events.EventType Type => QSB.Events.EventType.OpenHatch; - public override void SetupListener() + public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBHatchState, Handler); - public override void CloseListener() + public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBHatchState, Handler); private void Handler(bool open) => SendEvent(CreateMessage(open)); diff --git a/QSB/ShipSync/Patches/ShipPatches.cs b/QSB/ShipSync/Patches/ShipPatches.cs index 9f012381..19aa3253 100644 --- a/QSB/ShipSync/Patches/ShipPatches.cs +++ b/QSB/ShipSync/Patches/ShipPatches.cs @@ -73,8 +73,8 @@ namespace QSB.ShipSync.Patches var angle = 2f * Vector3.Angle(____playerCam.transform.forward, __instance.transform.forward); - ____focused = PlayerState.IsInsideShip() - ? angle <= 80 + ____focused = PlayerState.IsInsideShip() + ? angle <= 80 : angle >= 280; __instance.CallBase("UpdateInteractVolume"); diff --git a/QSB/ShipSync/ShipManager.cs b/QSB/ShipSync/ShipManager.cs index 183c11f2..7c20594b 100644 --- a/QSB/ShipSync/ShipManager.cs +++ b/QSB/ShipSync/ShipManager.cs @@ -84,7 +84,7 @@ namespace QSB.ShipSync private void PrintAll(Array array) { - foreach(var item in array) + foreach (var item in array) { DebugLog.DebugWrite($" - {(item as MonoBehaviour).name}"); } diff --git a/QSB/Syncs/IntermediaryTransform.cs b/QSB/Syncs/IntermediaryTransform.cs index 43beae33..967179f4 100644 --- a/QSB/Syncs/IntermediaryTransform.cs +++ b/QSB/Syncs/IntermediaryTransform.cs @@ -9,38 +9,38 @@ namespace QSB.Syncs private Transform _attachedTransform; private Transform _referenceTransform; - public IntermediaryTransform(Transform transform) + public IntermediaryTransform(Transform transform) => _attachedTransform = transform; /// /// Get the world position of this INVISIBLE transform. /// - public Vector3 GetPosition() + public Vector3 GetPosition() => _attachedTransform.position; /// /// Set the world position of this INVISIBLE transform. /// - public void SetPosition(Vector3 worldPos) + public void SetPosition(Vector3 worldPos) => _attachedTransform.position = worldPos; /// /// Get the world rotation of this INVISIBLE transform. /// - public Quaternion GetRotation() + public Quaternion GetRotation() => _attachedTransform.rotation; /// /// Set the world rotation of this INVISIBLE transform. /// - public void SetRotation(Quaternion worldRot) + public void SetRotation(Quaternion worldRot) => _attachedTransform.rotation = worldRot; /// /// Sets the reference transform - what transform this transform is syncing to. /// /// The new reference sector. - public void SetReferenceTransform(Transform transform) + public void SetReferenceTransform(Transform transform) => _referenceTransform = transform; /// @@ -54,7 +54,7 @@ namespace QSB.Syncs DebugLog.DebugWrite($"Error - _referenceTransform has not been set for {_attachedTransform.name}", MessageType.Error); return; } - + SetPosition(_referenceTransform.InverseTransformPoint(worldPosition)); } diff --git a/QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs b/QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs index fed7cf8e..d31d2f98 100644 --- a/QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs +++ b/QSB/Syncs/RigidbodySync/UnparentedBaseRigidbodySync.cs @@ -274,7 +274,7 @@ namespace QSB.Syncs.RigidbodySync return false; } - public float GetVelocityChangeMagnitude() + public float GetVelocityChangeMagnitude() => (_relativeVelocity - _prevVelocity).magnitude; public Vector3 GetRelativeVelocity() @@ -307,7 +307,7 @@ namespace QSB.Syncs.RigidbodySync if (!QSBCore.WorldObjectsReady || !QSBCore.DebugMode || !QSBCore.ShowLinesInDebug - || !IsReady + || !IsReady || ReferenceTransform == null) { return; diff --git a/QSB/Syncs/TransformSync/BaseTransformSync.cs b/QSB/Syncs/TransformSync/BaseTransformSync.cs index 835bedfc..c081f2db 100644 --- a/QSB/Syncs/TransformSync/BaseTransformSync.cs +++ b/QSB/Syncs/TransformSync/BaseTransformSync.cs @@ -40,8 +40,8 @@ namespace QSB.Syncs.TransformSync return uint.MaxValue; } - return NetIdentity.RootIdentity != null - ? NetIdentity.RootIdentity.NetId.Value + return NetIdentity.RootIdentity != null + ? NetIdentity.RootIdentity.NetId.Value : AttachedNetId; } } @@ -87,7 +87,7 @@ namespace QSB.Syncs.TransformSync QSBSceneManager.OnSceneLoaded -= OnSceneLoaded; } - private void OnSceneLoaded(OWScene scene, bool isInUniverse) + private void OnSceneLoaded(OWScene scene, bool isInUniverse) => _isInitialized = false; protected virtual void Init() @@ -275,9 +275,9 @@ namespace QSB.Syncs.TransformSync private void OnRenderObject() { - if (!QSBCore.WorldObjectsReady + if (!QSBCore.WorldObjectsReady || !QSBCore.DebugMode - || !QSBCore.ShowLinesInDebug + || !QSBCore.ShowLinesInDebug || !IsReady || ReferenceTransform == null) { diff --git a/QSB/Syncs/TransformSync/UnparentedBaseTransformSync.cs b/QSB/Syncs/TransformSync/UnparentedBaseTransformSync.cs index 6a0fa7e7..a5f5696e 100644 --- a/QSB/Syncs/TransformSync/UnparentedBaseTransformSync.cs +++ b/QSB/Syncs/TransformSync/UnparentedBaseTransformSync.cs @@ -230,10 +230,10 @@ namespace QSB.Syncs.TransformSync private void OnRenderObject() { - if (!QSBCore.WorldObjectsReady - || !QSBCore.DebugMode - || !QSBCore.ShowLinesInDebug - || !IsReady + if (!QSBCore.WorldObjectsReady + || !QSBCore.DebugMode + || !QSBCore.ShowLinesInDebug + || !IsReady || ReferenceTransform == null) { return; diff --git a/QSB/TimeSync/Patches/TimePatches.cs b/QSB/TimeSync/Patches/TimePatches.cs index 26725dce..2195dc8e 100644 --- a/QSB/TimeSync/Patches/TimePatches.cs +++ b/QSB/TimeSync/Patches/TimePatches.cs @@ -6,10 +6,10 @@ namespace QSB.TimeSync.Patches { public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect; - public override void DoPatches() + public override void DoPatches() => Prefix(nameof(PlayerCameraEffectController_OnStartOfTimeLoop)); - public static bool PlayerCameraEffectController_OnStartOfTimeLoop() + public static bool PlayerCameraEffectController_OnStartOfTimeLoop() => false; } } diff --git a/QSB/TimeSync/WakeUpSync.cs b/QSB/TimeSync/WakeUpSync.cs index 19f3b10f..c2dac083 100644 --- a/QSB/TimeSync/WakeUpSync.cs +++ b/QSB/TimeSync/WakeUpSync.cs @@ -107,7 +107,7 @@ namespace QSB.TimeSync } } - private void SendServerTime() + private void SendServerTime() => QSBEventManager.FireEvent(EventNames.QSBServerTime, _serverTime, PlayerData.LoadLoopCount()); public void OnClientReceiveMessage(ServerTimeMessage message) @@ -225,7 +225,7 @@ namespace QSB.TimeSync } } - private void WakeUp() + private void WakeUp() => Locator.GetPlayerCamera().GetComponent().Invoke("WakeUp"); public void Update() diff --git a/QSB/Utility/DebugGUI.cs b/QSB/Utility/DebugGUI.cs index ad8e62a9..ce1e5efe 100644 --- a/QSB/Utility/DebugGUI.cs +++ b/QSB/Utility/DebugGUI.cs @@ -1,9 +1,9 @@ -using QSB.Player.TransformSync; -using QSB.Player; +using QSB.Player; +using QSB.Player.TransformSync; using QSB.ProbeSync.TransformSync; using QSB.QuantumSync; -using QSB.ShipSync.TransformSync; using QSB.ShipSync; +using QSB.ShipSync.TransformSync; using QSB.TimeSync; using QSB.WorldSync; using System.Linq; diff --git a/QSB/Utility/Extensions.cs b/QSB/Utility/Extensions.cs index 89c0e7de..a8b864a3 100644 --- a/QSB/Utility/Extensions.cs +++ b/QSB/Utility/Extensions.cs @@ -100,7 +100,7 @@ namespace QSB.Utility // OW - public static Vector3 GetRelativeAngularVelocity(this OWRigidbody baseBody, OWRigidbody relativeBody) + public static Vector3 GetRelativeAngularVelocity(this OWRigidbody baseBody, OWRigidbody relativeBody) => baseBody.GetAngularVelocity() - relativeBody.GetAngularVelocity(); } } diff --git a/QSB/WorldSync/WorldObjectManager.cs b/QSB/WorldSync/WorldObjectManager.cs index 3f5dbf41..b25d7476 100644 --- a/QSB/WorldSync/WorldObjectManager.cs +++ b/QSB/WorldSync/WorldObjectManager.cs @@ -21,7 +21,7 @@ namespace QSB.WorldSync _managers.Remove(this); } - private void OnSceneLoaded(OWScene scene, bool inUniverse) + private void OnSceneLoaded(OWScene scene, bool inUniverse) => AllReady = false; public static void Rebuild(OWScene scene) diff --git a/QuantumUNET/Components/QNetworkIdentity.cs b/QuantumUNET/Components/QNetworkIdentity.cs index a36f015e..e70666ae 100644 --- a/QuantumUNET/Components/QNetworkIdentity.cs +++ b/QuantumUNET/Components/QNetworkIdentity.cs @@ -37,7 +37,7 @@ namespace QuantumUNET.Components set => m_LocalPlayerAuthority = value; } - public QNetworkBehaviour[] GetNetworkBehaviours() + public QNetworkBehaviour[] GetNetworkBehaviours() => m_NetworkBehaviours; public void SetRootIdentity(QNetworkIdentity newRoot) diff --git a/QuantumUNET/Components/QNetworkTransform.cs b/QuantumUNET/Components/QNetworkTransform.cs index a0f31e98..6c29851c 100644 --- a/QuantumUNET/Components/QNetworkTransform.cs +++ b/QuantumUNET/Components/QNetworkTransform.cs @@ -200,10 +200,10 @@ namespace QuantumUNET.Components return rotation; } - public override int GetNetworkChannel() + public override int GetNetworkChannel() => 1; - public override float GetNetworkSendInterval() + public override float GetNetworkSendInterval() => SendInterval; } } \ No newline at end of file diff --git a/QuantumUNET/QNetworkClient.cs b/QuantumUNET/QNetworkClient.cs index 7dd1f3da..42cac309 100644 --- a/QuantumUNET/QNetworkClient.cs +++ b/QuantumUNET/QNetworkClient.cs @@ -450,16 +450,16 @@ namespace QuantumUNET } } - Block_10: + Block_10: GenerateConnectError(b); return; - Block_11: + Block_11: GenerateDataError(b); return; - Block_17: + Block_17: QLog.Log($"MaxEventsPerFrame hit ({500})"); - Block_19: - IL_2C6: + Block_19: + IL_2C6: if (m_Connection != null && m_AsyncConnect == ConnectState.Connected) { m_Connection.FlushChannels();