From a00db9fe8535429adee19092a3f842867ce494aa Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Sat, 21 Sep 2024 07:23:23 -0400 Subject: [PATCH] breaking: Removed old obsoletes (#3900) --- Assets/Mirror/Components/Experimental.meta | 8 - .../Experimental/NetworkLerpRigidbody.cs | 97 ----- .../Experimental/NetworkLerpRigidbody.cs.meta | 11 - .../Experimental/NetworkRigidbody.cs | 354 ------------------ .../Experimental/NetworkRigidbody.cs.meta | 11 - .../Experimental/NetworkRigidbody2D.cs | 351 ----------------- .../Experimental/NetworkRigidbody2D.cs.meta | 11 - .../NetworkTransform/NetworkTransform.cs | 10 - .../NetworkTransform/NetworkTransform.cs.meta | 11 - .../NetworkTransform/NetworkTransformChild.cs | 12 - .../NetworkTransformChild.cs.meta | 11 - Assets/Mirror/Core/NetworkClient.cs | 17 - Assets/Mirror/Core/NetworkIdentity.cs | 9 - Assets/Mirror/Core/NetworkManager.cs | 62 --- Assets/Mirror/Core/NetworkReaderPooled.cs | 5 +- Assets/Mirror/Core/NetworkWriterPooled.cs | 5 +- Assets/Mirror/Core/SyncDictionary.cs | 8 - Assets/Mirror/Core/SyncList.cs | 8 - Assets/Mirror/Core/SyncSet.cs | 13 - .../ConcurrentNetworkWriterPooled.cs | 3 +- .../Scripts/MatchController.cs | 4 - .../SyncCollections/SyncDictionaryTest.cs | 97 ----- .../SyncCollections/SyncListStructTest.cs | 6 +- .../Editor/SyncCollections/SyncListTest.cs | 85 +---- .../Editor/SyncCollections/SyncSetTest.cs | 36 -- 25 files changed, 16 insertions(+), 1229 deletions(-) delete mode 100644 Assets/Mirror/Components/Experimental.meta delete mode 100644 Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs delete mode 100644 Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs.meta delete mode 100644 Assets/Mirror/Components/Experimental/NetworkRigidbody.cs delete mode 100644 Assets/Mirror/Components/Experimental/NetworkRigidbody.cs.meta delete mode 100644 Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs delete mode 100644 Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs.meta delete mode 100644 Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs delete mode 100644 Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs.meta delete mode 100644 Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs delete mode 100644 Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs.meta diff --git a/Assets/Mirror/Components/Experimental.meta b/Assets/Mirror/Components/Experimental.meta deleted file mode 100644 index 57cce382b..000000000 --- a/Assets/Mirror/Components/Experimental.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bfbf2a1f2b300c5489dcab219ef2846e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs deleted file mode 100644 index f3be8c894..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using UnityEngine; - -namespace Mirror.Experimental -{ - [AddComponentMenu("")] - [HelpURL("https://mirror-networking.gitbook.io/docs/components/network-lerp-rigidbody")] - [Obsolete("Use the new NetworkRigidbodyReliable/Unreliable component with Snapshot Interpolation instead.")] - public class NetworkLerpRigidbody : NetworkBehaviour - { - [Header("Settings")] - [SerializeField] internal Rigidbody target = null; - - [Tooltip("How quickly current velocity approaches target velocity")] - [SerializeField] float lerpVelocityAmount = 0.5f; - - [Tooltip("How quickly current position approaches target position")] - [SerializeField] float lerpPositionAmount = 0.5f; - - [Tooltip("Set to true if moves come from owner client, set to false if moves always come from server")] - [SerializeField] bool clientAuthority = false; - - double nextSyncTime; - - [SyncVar()] - Vector3 targetVelocity; - - [SyncVar()] - Vector3 targetPosition; - - /// - /// Ignore value if is host or client with Authority - /// - bool IgnoreSync => isServer || ClientWithAuthority; - - bool ClientWithAuthority => clientAuthority && isOwned; - - protected override void OnValidate() - { - base.OnValidate(); - Reset(); - } - - public virtual void Reset() - { - if (target == null) - target = GetComponent(); - - syncDirection = SyncDirection.ClientToServer; - } - - void Update() - { - if (isServer) - SyncToClients(); - else if (ClientWithAuthority) - SendToServer(); - } - - void SyncToClients() - { - targetVelocity = target.velocity; - targetPosition = target.position; - } - - void SendToServer() - { - double now = NetworkTime.localTime; // Unity 2019 doesn't have Time.timeAsDouble yet - if (now > nextSyncTime) - { - nextSyncTime = now + syncInterval; - CmdSendState(target.velocity, target.position); - } - } - - [Command] - void CmdSendState(Vector3 velocity, Vector3 position) - { - target.velocity = velocity; - target.position = position; - targetVelocity = velocity; - targetPosition = position; - } - - void FixedUpdate() - { - if (IgnoreSync) { return; } - - target.velocity = Vector3.Lerp(target.velocity, targetVelocity, lerpVelocityAmount); - target.position = Vector3.Lerp(target.position, targetPosition, lerpPositionAmount); - // add velocity to position as position would have moved on server at that velocity - target.position += target.velocity * Time.fixedDeltaTime; - - // TODO does this also need to sync acceleration so and update velocity? - } - } -} diff --git a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs.meta b/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs.meta deleted file mode 100644 index 35ef1fec2..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkLerpRigidbody.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7f032128052c95a46afb0ddd97d994cc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs deleted file mode 100644 index e99f6ed3d..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs +++ /dev/null @@ -1,354 +0,0 @@ -using System; -using UnityEngine; - -namespace Mirror.Experimental -{ - [AddComponentMenu("")] - [HelpURL("https://mirror-networking.gitbook.io/docs/components/network-rigidbody")] - [Obsolete("Use the new NetworkRigidbodyReliable/Unreliable component with Snapshot Interpolation instead.")] - public class NetworkRigidbody : NetworkBehaviour - { - [Header("Settings")] - [SerializeField] internal Rigidbody target = null; - - [Tooltip("Set to true if moves come from owner client, set to false if moves always come from server")] - public bool clientAuthority = false; - - [Header("Velocity")] - [Tooltip("Syncs Velocity every SyncInterval")] - [SerializeField] bool syncVelocity = true; - - [Tooltip("Set velocity to 0 each frame (only works if syncVelocity is false")] - [SerializeField] bool clearVelocity = false; - - [Tooltip("Only Syncs Value if distance between previous and current is great than sensitivity")] - [SerializeField] float velocitySensitivity = 0.1f; - - [Header("Angular Velocity")] - [Tooltip("Syncs AngularVelocity every SyncInterval")] - [SerializeField] bool syncAngularVelocity = true; - - [Tooltip("Set angularVelocity to 0 each frame (only works if syncAngularVelocity is false")] - [SerializeField] bool clearAngularVelocity = false; - - [Tooltip("Only Syncs Value if distance between previous and current is great than sensitivity")] - [SerializeField] float angularVelocitySensitivity = 0.1f; - - /// - /// Values sent on client with authority after they are sent to the server - /// - readonly ClientSyncState previousValue = new ClientSyncState(); - - protected override void OnValidate() - { - base.OnValidate(); - Reset(); - } - - public virtual void Reset() - { - if (target == null) - target = GetComponent(); - - syncDirection = SyncDirection.ClientToServer; - } - - #region Sync vars - - [SyncVar(hook = nameof(OnVelocityChanged))] - Vector3 velocity; - - [SyncVar(hook = nameof(OnAngularVelocityChanged))] - Vector3 angularVelocity; - - [SyncVar(hook = nameof(OnIsKinematicChanged))] - bool isKinematic; - - [SyncVar(hook = nameof(OnUseGravityChanged))] - bool useGravity; - - [SyncVar(hook = nameof(OnuDragChanged))] - float drag; - - [SyncVar(hook = nameof(OnAngularDragChanged))] - float angularDrag; - - /// - /// Ignore value if is host or client with Authority - /// - /// - bool IgnoreSync => isServer || ClientWithAuthority; - - bool ClientWithAuthority => clientAuthority && isOwned; - - void OnVelocityChanged(Vector3 _, Vector3 newValue) - { - if (IgnoreSync) - return; - - target.velocity = newValue; - } - - void OnAngularVelocityChanged(Vector3 _, Vector3 newValue) - { - if (IgnoreSync) - return; - - target.angularVelocity = newValue; - } - - void OnIsKinematicChanged(bool _, bool newValue) - { - if (IgnoreSync) - return; - - target.isKinematic = newValue; - } - - void OnUseGravityChanged(bool _, bool newValue) - { - if (IgnoreSync) - return; - - target.useGravity = newValue; - } - - void OnuDragChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.drag = newValue; - } - - void OnAngularDragChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.angularDrag = newValue; - } - - #endregion - - internal void Update() - { - if (isServer) - SyncToClients(); - else if (ClientWithAuthority) - SendToServer(); - } - - internal void FixedUpdate() - { - if (clearAngularVelocity && !syncAngularVelocity) - target.angularVelocity = Vector3.zero; - - if (clearVelocity && !syncVelocity) - target.velocity = Vector3.zero; - } - - /// - /// Updates sync var values on server so that they sync to the client - /// - [Server] - void SyncToClients() - { - // only update if they have changed more than Sensitivity - - Vector3 currentVelocity = syncVelocity ? target.velocity : default; - Vector3 currentAngularVelocity = syncAngularVelocity ? target.angularVelocity : default; - - bool velocityChanged = syncVelocity && ((previousValue.velocity - currentVelocity).sqrMagnitude > velocitySensitivity * velocitySensitivity); - bool angularVelocityChanged = syncAngularVelocity && ((previousValue.angularVelocity - currentAngularVelocity).sqrMagnitude > angularVelocitySensitivity * angularVelocitySensitivity); - - if (velocityChanged) - { - velocity = currentVelocity; - previousValue.velocity = currentVelocity; - } - - if (angularVelocityChanged) - { - angularVelocity = currentAngularVelocity; - previousValue.angularVelocity = currentAngularVelocity; - } - - // other rigidbody settings - isKinematic = target.isKinematic; - useGravity = target.useGravity; - drag = target.drag; - angularDrag = target.angularDrag; - } - - /// - /// Uses Command to send values to server - /// - [Client] - void SendToServer() - { - if (!isOwned) - { - Debug.LogWarning("SendToServer called without authority"); - return; - } - - SendVelocity(); - SendRigidBodySettings(); - } - - [Client] - void SendVelocity() - { - double now = NetworkTime.localTime; // Unity 2019 doesn't have Time.timeAsDouble yet - if (now < previousValue.nextSyncTime) - return; - - Vector3 currentVelocity = syncVelocity ? target.velocity : default; - Vector3 currentAngularVelocity = syncAngularVelocity ? target.angularVelocity : default; - - bool velocityChanged = syncVelocity && ((previousValue.velocity - currentVelocity).sqrMagnitude > velocitySensitivity * velocitySensitivity); - bool angularVelocityChanged = syncAngularVelocity && ((previousValue.angularVelocity - currentAngularVelocity).sqrMagnitude > angularVelocitySensitivity * angularVelocitySensitivity); - - // if angularVelocity has changed it is likely that velocity has also changed so just sync both values - // however if only velocity has changed just send velocity - if (angularVelocityChanged) - { - CmdSendVelocityAndAngular(currentVelocity, currentAngularVelocity); - previousValue.velocity = currentVelocity; - previousValue.angularVelocity = currentAngularVelocity; - } - else if (velocityChanged) - { - CmdSendVelocity(currentVelocity); - previousValue.velocity = currentVelocity; - } - - - // only update syncTime if either has changed - if (angularVelocityChanged || velocityChanged) - previousValue.nextSyncTime = now + syncInterval; - } - - [Client] - void SendRigidBodySettings() - { - // These shouldn't change often so it is ok to send in their own Command - if (previousValue.isKinematic != target.isKinematic) - { - CmdSendIsKinematic(target.isKinematic); - previousValue.isKinematic = target.isKinematic; - } - if (previousValue.useGravity != target.useGravity) - { - CmdSendUseGravity(target.useGravity); - previousValue.useGravity = target.useGravity; - } - if (previousValue.drag != target.drag) - { - CmdSendDrag(target.drag); - previousValue.drag = target.drag; - } - if (previousValue.angularDrag != target.angularDrag) - { - CmdSendAngularDrag(target.angularDrag); - previousValue.angularDrag = target.angularDrag; - } - } - - /// - /// Called when only Velocity has changed on the client - /// - [Command] - void CmdSendVelocity(Vector3 velocity) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.velocity = velocity; - target.velocity = velocity; - } - - /// - /// Called when angularVelocity has changed on the client - /// - [Command] - void CmdSendVelocityAndAngular(Vector3 velocity, Vector3 angularVelocity) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - if (syncVelocity) - { - this.velocity = velocity; - target.velocity = velocity; - } - - this.angularVelocity = angularVelocity; - target.angularVelocity = angularVelocity; - } - - [Command] - void CmdSendIsKinematic(bool isKinematic) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.isKinematic = isKinematic; - target.isKinematic = isKinematic; - } - - [Command] - void CmdSendUseGravity(bool useGravity) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.useGravity = useGravity; - target.useGravity = useGravity; - } - - [Command] - void CmdSendDrag(float drag) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.drag = drag; - target.drag = drag; - } - - [Command] - void CmdSendAngularDrag(float angularDrag) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.angularDrag = angularDrag; - target.angularDrag = angularDrag; - } - - /// - /// holds previously synced values - /// - public class ClientSyncState - { - /// - /// Next sync time that velocity will be synced, based on syncInterval. - /// - public double nextSyncTime; - public Vector3 velocity; - public Vector3 angularVelocity; - public bool isKinematic; - public bool useGravity; - public float drag; - public float angularDrag; - } - } -} diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs.meta b/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs.meta deleted file mode 100644 index 1610f0a73..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83392ae5c1b731446909f252fd494ae4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs deleted file mode 100644 index 3209dfe4c..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs +++ /dev/null @@ -1,351 +0,0 @@ -using System; -using UnityEngine; - -namespace Mirror.Experimental -{ - [AddComponentMenu("")] - [HelpURL("https://mirror-networking.gitbook.io/docs/components/network-rigidbody")] - [Obsolete("Use the new NetworkRigidbodyReliable/Unreliable 2D component with Snapshot Interpolation instead.")] - public class NetworkRigidbody2D : NetworkBehaviour - { - [Header("Settings")] - [SerializeField] internal Rigidbody2D target = null; - - [Tooltip("Set to true if moves come from owner client, set to false if moves always come from server")] - public bool clientAuthority = false; - - [Header("Velocity")] - [Tooltip("Syncs Velocity every SyncInterval")] - [SerializeField] bool syncVelocity = true; - - [Tooltip("Set velocity to 0 each frame (only works if syncVelocity is false")] - [SerializeField] bool clearVelocity = false; - - [Tooltip("Only Syncs Value if distance between previous and current is great than sensitivity")] - [SerializeField] float velocitySensitivity = 0.1f; - - [Header("Angular Velocity")] - [Tooltip("Syncs AngularVelocity every SyncInterval")] - [SerializeField] bool syncAngularVelocity = true; - - [Tooltip("Set angularVelocity to 0 each frame (only works if syncAngularVelocity is false")] - [SerializeField] bool clearAngularVelocity = false; - - [Tooltip("Only Syncs Value if distance between previous and current is great than sensitivity")] - [SerializeField] float angularVelocitySensitivity = 0.1f; - - /// - /// Values sent on client with authority after they are sent to the server - /// - readonly ClientSyncState previousValue = new ClientSyncState(); - - protected override void OnValidate() - { - base.OnValidate(); - Reset(); - } - - public virtual void Reset() - { - if (target == null) - target = GetComponent(); - - syncDirection = SyncDirection.ClientToServer; - } - - #region Sync vars - - [SyncVar(hook = nameof(OnVelocityChanged))] - Vector2 velocity; - - [SyncVar(hook = nameof(OnAngularVelocityChanged))] - float angularVelocity; - - [SyncVar(hook = nameof(OnIsKinematicChanged))] - bool isKinematic; - - [SyncVar(hook = nameof(OnGravityScaleChanged))] - float gravityScale; - - [SyncVar(hook = nameof(OnuDragChanged))] - float drag; - - [SyncVar(hook = nameof(OnAngularDragChanged))] - float angularDrag; - - /// - /// Ignore value if is host or client with Authority - /// - bool IgnoreSync => isServer || ClientWithAuthority; - - bool ClientWithAuthority => clientAuthority && isOwned; - - void OnVelocityChanged(Vector2 _, Vector2 newValue) - { - if (IgnoreSync) - return; - - target.velocity = newValue; - } - - void OnAngularVelocityChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.angularVelocity = newValue; - } - - void OnIsKinematicChanged(bool _, bool newValue) - { - if (IgnoreSync) - return; - - target.isKinematic = newValue; - } - - void OnGravityScaleChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.gravityScale = newValue; - } - - void OnuDragChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.drag = newValue; - } - - void OnAngularDragChanged(float _, float newValue) - { - if (IgnoreSync) - return; - - target.angularDrag = newValue; - } - - #endregion - - internal void Update() - { - if (isServer) - SyncToClients(); - else if (ClientWithAuthority) - SendToServer(); - } - - internal void FixedUpdate() - { - if (clearAngularVelocity && !syncAngularVelocity) - target.angularVelocity = 0f; - - if (clearVelocity && !syncVelocity) - target.velocity = Vector2.zero; - } - - /// - /// Updates sync var values on server so that they sync to the client - /// - [Server] - void SyncToClients() - { - // only update if they have changed more than Sensitivity - - Vector2 currentVelocity = syncVelocity ? target.velocity : default; - float currentAngularVelocity = syncAngularVelocity ? target.angularVelocity : default; - - bool velocityChanged = syncVelocity && ((previousValue.velocity - currentVelocity).sqrMagnitude > velocitySensitivity * velocitySensitivity); - bool angularVelocityChanged = syncAngularVelocity && ((previousValue.angularVelocity - currentAngularVelocity) > angularVelocitySensitivity); - - if (velocityChanged) - { - velocity = currentVelocity; - previousValue.velocity = currentVelocity; - } - - if (angularVelocityChanged) - { - angularVelocity = currentAngularVelocity; - previousValue.angularVelocity = currentAngularVelocity; - } - - // other rigidbody settings - isKinematic = target.isKinematic; - gravityScale = target.gravityScale; - drag = target.drag; - angularDrag = target.angularDrag; - } - - /// - /// Uses Command to send values to server - /// - [Client] - void SendToServer() - { - if (!isOwned) - { - Debug.LogWarning("SendToServer called without authority"); - return; - } - - SendVelocity(); - SendRigidBodySettings(); - } - - [Client] - void SendVelocity() - { - float now = Time.time; - if (now < previousValue.nextSyncTime) - return; - - Vector2 currentVelocity = syncVelocity ? target.velocity : default; - float currentAngularVelocity = syncAngularVelocity ? target.angularVelocity : default; - - bool velocityChanged = syncVelocity && ((previousValue.velocity - currentVelocity).sqrMagnitude > velocitySensitivity * velocitySensitivity); - bool angularVelocityChanged = syncAngularVelocity && previousValue.angularVelocity != currentAngularVelocity;//((previousValue.angularVelocity - currentAngularVelocity).sqrMagnitude > angularVelocitySensitivity * angularVelocitySensitivity); - - // if angularVelocity has changed it is likely that velocity has also changed so just sync both values - // however if only velocity has changed just send velocity - if (angularVelocityChanged) - { - CmdSendVelocityAndAngular(currentVelocity, currentAngularVelocity); - previousValue.velocity = currentVelocity; - previousValue.angularVelocity = currentAngularVelocity; - } - else if (velocityChanged) - { - CmdSendVelocity(currentVelocity); - previousValue.velocity = currentVelocity; - } - - // only update syncTime if either has changed - if (angularVelocityChanged || velocityChanged) - previousValue.nextSyncTime = now + syncInterval; - } - - [Client] - void SendRigidBodySettings() - { - // These shouldn't change often so it is ok to send in their own Command - if (previousValue.isKinematic != target.isKinematic) - { - CmdSendIsKinematic(target.isKinematic); - previousValue.isKinematic = target.isKinematic; - } - if (previousValue.gravityScale != target.gravityScale) - { - CmdChangeGravityScale(target.gravityScale); - previousValue.gravityScale = target.gravityScale; - } - if (previousValue.drag != target.drag) - { - CmdSendDrag(target.drag); - previousValue.drag = target.drag; - } - if (previousValue.angularDrag != target.angularDrag) - { - CmdSendAngularDrag(target.angularDrag); - previousValue.angularDrag = target.angularDrag; - } - } - - /// - /// Called when only Velocity has changed on the client - /// - [Command] - void CmdSendVelocity(Vector2 velocity) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.velocity = velocity; - target.velocity = velocity; - } - - /// - /// Called when angularVelocity has changed on the client - /// - [Command] - void CmdSendVelocityAndAngular(Vector2 velocity, float angularVelocity) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - if (syncVelocity) - { - this.velocity = velocity; - target.velocity = velocity; - } - this.angularVelocity = angularVelocity; - target.angularVelocity = angularVelocity; - } - - [Command] - void CmdSendIsKinematic(bool isKinematic) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.isKinematic = isKinematic; - target.isKinematic = isKinematic; - } - - [Command] - void CmdChangeGravityScale(float gravityScale) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.gravityScale = gravityScale; - target.gravityScale = gravityScale; - } - - [Command] - void CmdSendDrag(float drag) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.drag = drag; - target.drag = drag; - } - - [Command] - void CmdSendAngularDrag(float angularDrag) - { - // Ignore messages from client if not in client authority mode - if (!clientAuthority) - return; - - this.angularDrag = angularDrag; - target.angularDrag = angularDrag; - } - - /// - /// holds previously synced values - /// - public class ClientSyncState - { - /// - /// Next sync time that velocity will be synced, based on syncInterval. - /// - public float nextSyncTime; - public Vector2 velocity; - public float angularVelocity; - public bool isKinematic; - public float gravityScale; - public float drag; - public float angularDrag; - } - } -} diff --git a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs.meta b/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs.meta deleted file mode 100644 index df466bd09..000000000 --- a/Assets/Mirror/Components/Experimental/NetworkRigidbody2D.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ab2cbc52526ea384ba280d13cd1a57b9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs deleted file mode 100644 index 9e6a30e42..000000000 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using UnityEngine; - -namespace Mirror -{ - // DEPRECATED 2023-06-15 - [AddComponentMenu("")] - [Obsolete("NetworkTransform was renamed to NetworkTransformUnreliable.\nYou can easily swap the component's script by going into the Unity Inspector debug mode:\n1. Click the vertical dots on the top right in the Inspector tab.\n2. Find your NetworkTransform component\n3. Drag NetworkTransformUnreliable into the 'Script' field in the Inspector.\n4. Find the three dots and return to Normal mode.")] - public class NetworkTransform : NetworkTransformUnreliable {} -} diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs.meta b/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs.meta deleted file mode 100644 index a569990f7..000000000 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransform.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2f74aedd71d9a4f55b3ce499326d45fb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs b/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs deleted file mode 100644 index a844d9d84..000000000 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs +++ /dev/null @@ -1,12 +0,0 @@ -// A component to synchronize the position of child transforms of networked objects. -// There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the recieved values. -using System; -using UnityEngine; - -namespace Mirror -{ - // Deprecated 2022-10-25 - [AddComponentMenu("")] - [Obsolete("NetworkTransformChild is not needed anymore. The .target is now exposed in NetworkTransform itself. Note you can open the Inspector in debug view and replace the source script instead of reassigning everything.")] - public class NetworkTransformChild : NetworkTransform {} -} diff --git a/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs.meta b/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs.meta deleted file mode 100644 index ae36756d1..000000000 --- a/Assets/Mirror/Components/NetworkTransform/NetworkTransformChild.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 734b48bea0b204338958ee3d885e11f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Mirror/Core/NetworkClient.cs b/Assets/Mirror/Core/NetworkClient.cs index 2aff2d47b..666765384 100644 --- a/Assets/Mirror/Core/NetworkClient.cs +++ b/Assets/Mirror/Core/NetworkClient.cs @@ -565,23 +565,6 @@ public static void RegisterHandler(Action handler, bool requireAuthen handlers[msgType] = NetworkMessages.WrapHandler((Action)HandlerWrapped, requireAuthentication, exceptionsDisconnect); } - // Deprecated 2024-01-21 - [Obsolete("Use ReplaceHandler without the NetworkConnection parameter instead. This version is obsolete and will be removed soon.")] - public static void ReplaceHandler(Action handler, bool requireAuthentication = true) - where T : struct, NetworkMessage - { - // we use the same WrapHandler function for server and client. - // so let's wrap it to ignore the NetworkConnection parameter. - // it's not needed on client. it's always NetworkClient.connection. - ushort msgType = NetworkMessageId.Id; - - // register Id <> Type in lookup for debugging. - NetworkMessages.Lookup[msgType] = typeof(T); - - void HandlerWrapped(NetworkConnection _, T value) => handler(_, value); - handlers[msgType] = NetworkMessages.WrapHandler((Action)HandlerWrapped, requireAuthentication, exceptionsDisconnect); - } - /// Replace a handler for a particular message type. Should require authentication by default. // RegisterHandler throws a warning (as it should) if a handler is assigned twice // Use of ReplaceHandler makes it clear the user intended to replace the handler diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index 746dd483d..9856769d5 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -207,15 +207,6 @@ internal set [FormerlySerializedAs("visible")] public Visibility visibility = Visibility.Default; - // Deprecated 2024-01-21 - [HideInInspector] - [Obsolete("Deprecated - Use .visibility instead. This will be removed soon.")] - public Visibility visible - { - get => visibility; - set => visibility = value; - } - // broadcasting serializes all entities around a player for each player. // we don't want to serialize one entity twice in the same tick. // so we cache the last serialization and remember the timestamp so we diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 301587904..c3969569b 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -42,22 +42,6 @@ public class NetworkManager : MonoBehaviour [FormerlySerializedAs("serverTickRate")] public int sendRate = 60; - // Deprecated 2023-11-25 - // Using SerializeField and HideInInspector to self-correct for being - // replaced by headlessStartMode. This can be removed in the future. - // See OnValidate() for how we handle this. - [Obsolete("Deprecated - Use headlessStartMode instead.")] - [FormerlySerializedAs("autoStartServerBuild"), SerializeField, HideInInspector] - public bool autoStartServerBuild = true; - - // Deprecated 2023-11-25 - // Using SerializeField and HideInInspector to self-correct for being - // replaced by headlessStartMode. This can be removed in the future. - // See OnValidate() for how we handle this. - [Obsolete("Deprecated - Use headlessStartMode instead.")] - [FormerlySerializedAs("autoConnectClientBuild"), SerializeField, HideInInspector] - public bool autoConnectClientBuild; - // client send rate follows server send rate to avoid errors for now /// Client Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE. // [Tooltip("Client broadcasts 'sendRate' times per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")] @@ -181,24 +165,6 @@ public class NetworkManager : MonoBehaviour // virtual so that inheriting classes' OnValidate() can call base.OnValidate() too public virtual void OnValidate() { -#pragma warning disable 618 - // autoStartServerBuild and autoConnectClientBuild are now obsolete, but to avoid - // a breaking change we'll set headlessStartMode to what the user had set before. - // - // headlessStartMode defaults to DoNothing, so if the user had neither of these - // set, then it will remain as DoNothing, and if they set headlessStartMode to - // any selection in the inspector it won't get changed back. - if (autoStartServerBuild) - headlessStartMode = HeadlessStartOptions.AutoStartServer; - else if (autoConnectClientBuild) - headlessStartMode = HeadlessStartOptions.AutoStartClient; - - // Setting both to false here prevents this code from fighting with user - // selection in the inspector, and they're both SerialisedField's. - autoStartServerBuild = false; - autoConnectClientBuild = false; -#pragma warning restore 618 - // always >= 0 maxConnections = Mathf.Max(maxConnections, 0); @@ -400,11 +366,6 @@ void SetupClient() { InitializeSingleton(); -#pragma warning disable 618 - // Remove when OnConnectionQualityChanged is removed. - NetworkClient.onConnectionQualityChanged += OnConnectionQualityChanged; -#pragma warning restore 618 - // apply settings before initializing anything NetworkClient.exceptionsDisconnect = exceptionsDisconnect; // NetworkClient.sendRate = clientSendRate; @@ -672,11 +633,6 @@ public void StopClient() // NetworkManager.OnClientDisconnect NetworkClient.Disconnect(); -#pragma warning disable 618 - // Remove when OnConnectionQualityChanged is removed. - NetworkClient.onConnectionQualityChanged -= OnConnectionQualityChanged; -#pragma warning restore 618 - // UNET invoked OnDisconnected cleanup immediately. // let's keep it for now, in case any projects depend on it. // TODO simply remove this in the future. @@ -1435,24 +1391,6 @@ public virtual void OnClientConnect() /// Called on clients when disconnected from a server. public virtual void OnClientDisconnect() { } - // Deprecated 2023-12-05 - /// Deprecated: NetworkClient handles this now. - [Obsolete("NetworkClient handles this now.")] - public virtual void CalculateConnectionQuality() - { - // Moved to NetworkClient - } - - // Deprecated 2023-12-05 - /// Deprecated: NetworkClient handles this now. - [Obsolete("This will be removed. Subscribe to NetworkClient.onConnectionQualityChanged in your own code")] - public virtual void OnConnectionQualityChanged(ConnectionQuality previous, ConnectionQuality current) - { - // logging the change is very useful to track down user's lag reports. - // we want to include as much detail as possible for debugging. - //Debug.Log($"[Mirror] Connection Quality changed from {previous} to {current}:\n rtt={(NetworkTime.rtt * 1000):F1}ms\n rttVar={(NetworkTime.rttVariance * 1000):F1}ms\n bufferTime={(NetworkClient.bufferTime * 1000):F1}ms"); - } - /// Called on client when transport raises an exception. public virtual void OnClientError(TransportError error, string reason) { } diff --git a/Assets/Mirror/Core/NetworkReaderPooled.cs b/Assets/Mirror/Core/NetworkReaderPooled.cs index 53489045a..150870195 100644 --- a/Assets/Mirror/Core/NetworkReaderPooled.cs +++ b/Assets/Mirror/Core/NetworkReaderPooled.cs @@ -1,12 +1,9 @@ -// "NetworkReaderPooled" instead of "PooledNetworkReader" to group files, for -// easier IDE workflow and more elegant code. using System; namespace Mirror { /// Pooled NetworkReader, automatically returned to pool when using 'using' - // TODO make sealed again after removing obsolete NetworkReaderPooled! - public class NetworkReaderPooled : NetworkReader, IDisposable + public sealed class NetworkReaderPooled : NetworkReader, IDisposable { internal NetworkReaderPooled(byte[] bytes) : base(bytes) {} internal NetworkReaderPooled(ArraySegment segment) : base(segment) {} diff --git a/Assets/Mirror/Core/NetworkWriterPooled.cs b/Assets/Mirror/Core/NetworkWriterPooled.cs index 5ac371db8..963ce33a8 100644 --- a/Assets/Mirror/Core/NetworkWriterPooled.cs +++ b/Assets/Mirror/Core/NetworkWriterPooled.cs @@ -1,12 +1,9 @@ -// "NetworkWriterPooled" instead of "PooledNetworkWriter" to group files, for -// easier IDE workflow and more elegant code. using System; namespace Mirror { /// Pooled NetworkWriter, automatically returned to pool when using 'using' - // TODO make sealed again after removing obsolete NetworkWriterPooled! - public class NetworkWriterPooled : NetworkWriter, IDisposable + public sealed class NetworkWriterPooled : NetworkWriter, IDisposable { public void Dispose() => NetworkWriterPool.Return(this); } diff --git a/Assets/Mirror/Core/SyncDictionary.cs b/Assets/Mirror/Core/SyncDictionary.cs index 3cf73f519..b07d6e058 100644 --- a/Assets/Mirror/Core/SyncDictionary.cs +++ b/Assets/Mirror/Core/SyncDictionary.cs @@ -26,10 +26,6 @@ public class SyncIDictionary : SyncObject, IDictionaryThis is called before the data is cleared public Action OnClear; - // Deprecated 2024-03-22 - [Obsolete("Use individual Actions, which pass OLD values where appropriate, instead.")] - public Action Callback; - protected readonly IDictionary objects; public SyncIDictionary(IDictionary objects) @@ -343,10 +339,6 @@ void AddOperation(Operation op, TKey key, TValue item, TValue oldItem, bool chec OnChange?.Invoke(op, default, default); break; } - -#pragma warning disable CS0618 // Type or member is obsolete - Callback?.Invoke(op, key, item); -#pragma warning restore CS0618 // Type or member is obsolete } public IEnumerator> GetEnumerator() => objects.GetEnumerator(); diff --git a/Assets/Mirror/Core/SyncList.cs b/Assets/Mirror/Core/SyncList.cs index 6f4952e4e..25ca1a9b8 100644 --- a/Assets/Mirror/Core/SyncList.cs +++ b/Assets/Mirror/Core/SyncList.cs @@ -38,10 +38,6 @@ public enum Operation : byte /// This is called before the list is cleared so the list can be iterated public Action OnClear; - // Deprecated 2024-03-23 - [Obsolete("Use individual Actions, which pass OLD values where appropriate, instead.")] - public Action Callback; - readonly IList objects; readonly IEqualityComparer comparer; @@ -133,10 +129,6 @@ void AddOperation(Operation op, int itemIndex, T oldItem, T newItem, bool checkA OnChange?.Invoke(op, itemIndex, default); break; } - -#pragma warning disable CS0618 // Type or member is obsolete - Callback?.Invoke(op, itemIndex, oldItem, newItem); -#pragma warning restore CS0618 // Type or member is obsolete } public override void OnSerializeAll(NetworkWriter writer) diff --git a/Assets/Mirror/Core/SyncSet.cs b/Assets/Mirror/Core/SyncSet.cs index 3d19b0e89..52517b87d 100644 --- a/Assets/Mirror/Core/SyncSet.cs +++ b/Assets/Mirror/Core/SyncSet.cs @@ -23,10 +23,6 @@ public class SyncSet : SyncObject, ISet /// This is called BEFORE the data is cleared public Action OnClear; - // Deprecated 2024-03-22 - [Obsolete("Use individual Actions, which pass OLD value where appropriate, instead.")] - public Action Callback; - protected readonly ISet objects; public int Count => objects.Count; @@ -116,23 +112,14 @@ void AddOperation(Operation op, T oldItem, T newItem, bool checkAccess) case Operation.OP_ADD: OnAdd?.Invoke(newItem); OnChange?.Invoke(op, newItem); -#pragma warning disable CS0618 // Type or member is obsolete - Callback?.Invoke(op, newItem); -#pragma warning restore CS0618 // Type or member is obsolete break; case Operation.OP_REMOVE: OnRemove?.Invoke(oldItem); OnChange?.Invoke(op, oldItem); -#pragma warning disable CS0618 // Type or member is obsolete - Callback?.Invoke(op, oldItem); -#pragma warning restore CS0618 // Type or member is obsolete break; case Operation.OP_CLEAR: OnClear?.Invoke(); OnChange?.Invoke(op, default); -#pragma warning disable CS0618 // Type or member is obsolete - Callback?.Invoke(op, default); -#pragma warning restore CS0618 // Type or member is obsolete break; } } diff --git a/Assets/Mirror/Core/Threading/ConcurrentNetworkWriterPooled.cs b/Assets/Mirror/Core/Threading/ConcurrentNetworkWriterPooled.cs index ccb1e47bc..4baa7df7c 100644 --- a/Assets/Mirror/Core/Threading/ConcurrentNetworkWriterPooled.cs +++ b/Assets/Mirror/Core/Threading/ConcurrentNetworkWriterPooled.cs @@ -3,8 +3,7 @@ namespace Mirror { /// Pooled (not threadsafe) NetworkWriter used from Concurrent pool (thread safe). Automatically returned to concurrent pool when using 'using' - // TODO make sealed again after removing obsolete NetworkWriterPooled! - public class ConcurrentNetworkWriterPooled : NetworkWriter, IDisposable + public sealed class ConcurrentNetworkWriterPooled : NetworkWriter, IDisposable { public void Dispose() => ConcurrentNetworkWriterPool.Return(this); } diff --git a/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchController.cs b/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchController.cs index ef115a7ea..b674d1ef3 100644 --- a/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchController.cs +++ b/Assets/Mirror/Examples/MultipleMatches/Scripts/MatchController.cs @@ -58,10 +58,6 @@ IEnumerator AddPlayersToMatchController() public override void OnStartClient() { -#pragma warning disable CS0618 // Type or member is obsolete - matchPlayerData.Callback = UpdateWins; -#pragma warning restore CS0618 // Type or member is obsolete - canvasGroup.alpha = 1f; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; diff --git a/Assets/Mirror/Tests/Editor/SyncCollections/SyncDictionaryTest.cs b/Assets/Mirror/Tests/Editor/SyncCollections/SyncDictionaryTest.cs index da0ebecdc..0909f7ea1 100644 --- a/Assets/Mirror/Tests/Editor/SyncCollections/SyncDictionaryTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncCollections/SyncDictionaryTest.cs @@ -80,19 +80,6 @@ public void CurlyBracesConstructor() public void TestAdd() { // Adds a new entry with index of 4 using .Add method -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); - Assert.That(key, Is.EqualTo(4)); - Assert.That(item, Is.EqualTo("yay")); - Assert.That(clientSyncDictionary[key], Is.EqualTo("yay")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnAdd = (key) => { @@ -105,7 +92,6 @@ public void TestAdd() SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); Assert.That(clientSyncDictionary.ContainsKey(4)); Assert.That(clientSyncDictionary[4], Is.EqualTo("yay")); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); } @@ -113,17 +99,6 @@ public void TestAdd() public void TestClear() { // Verifies that the clear method works and that the data is still present for the Callback. -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_CLEAR)); - Assert.That(clientSyncDictionary.Count, Is.EqualTo(3)); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnClear = () => { @@ -134,7 +109,6 @@ public void TestClear() serverSyncDictionary.Clear(); SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); Assert.That(serverSyncDictionary, Is.EquivalentTo(new SyncDictionary())); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); } @@ -142,20 +116,6 @@ public void TestClear() public void TestSet() { // Overwrites an existing entry -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_SET)); - Assert.That(key, Is.EqualTo(1)); - Assert.That(item, Is.EqualTo("yay")); - Assert.That(clientSyncDictionary[key], Is.EqualTo("yay")); - - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnSet = (key, oldItem) => { @@ -169,7 +129,6 @@ public void TestSet() SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); Assert.That(clientSyncDictionary.ContainsKey(1)); Assert.That(clientSyncDictionary[1], Is.EqualTo("yay")); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); } @@ -177,20 +136,6 @@ public void TestSet() public void TestBareSet() { // Adds a new entry with index of 4 without using .Add method -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); - Assert.That(key, Is.EqualTo(4)); - Assert.That(item, Is.EqualTo("yay")); - Assert.That(clientSyncDictionary[key], Is.EqualTo("yay")); - - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnAdd = (key) => { @@ -203,7 +148,6 @@ public void TestBareSet() SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); Assert.That(clientSyncDictionary.ContainsKey(4)); Assert.That(clientSyncDictionary[4], Is.EqualTo("yay")); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); } @@ -268,20 +212,6 @@ public void TestContains() [Test] public void CallbackTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); - Assert.That(key, Is.EqualTo(3)); - Assert.That(item, Is.EqualTo("yay")); - Assert.That(clientSyncDictionary[key], Is.EqualTo("yay")); - - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnAdd = (key) => { @@ -301,7 +231,6 @@ public void CallbackTest() serverSyncDictionary.Add(3, "yay"); SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -309,19 +238,6 @@ public void CallbackTest() [Test] public void ServerCallbackTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - serverSyncDictionary.Callback = (op, key, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_ADD)); - Assert.That(key, Is.EqualTo(3)); - Assert.That(item, Is.EqualTo("yay")); - Assert.That(serverSyncDictionary[key], Is.EqualTo("yay")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; serverSyncDictionary.OnAdd = (key) => { @@ -340,7 +256,6 @@ public void ServerCallbackTest() }; serverSyncDictionary[3] = "yay"; - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -348,17 +263,6 @@ public void ServerCallbackTest() [Test] public void CallbackRemoveTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncDictionary.Callback = (op, key, item) => - { - called = true; - Assert.That(op, Is.EqualTo(SyncDictionary.Operation.OP_REMOVE)); - Assert.That(key, Is.EqualTo(1)); - Assert.That(item, Is.EqualTo("World")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncDictionary.OnRemove = (key, oldItem) => { @@ -379,7 +283,6 @@ public void CallbackRemoveTest() serverSyncDictionary.Remove(1); SerializeDeltaTo(serverSyncDictionary, clientSyncDictionary); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } diff --git a/Assets/Mirror/Tests/Editor/SyncCollections/SyncListStructTest.cs b/Assets/Mirror/Tests/Editor/SyncCollections/SyncListStructTest.cs index 63ba7cbe4..17295cc9c 100644 --- a/Assets/Mirror/Tests/Editor/SyncCollections/SyncListStructTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncCollections/SyncListStructTest.cs @@ -47,17 +47,15 @@ public void OldValueShouldNotBeNewValue() player.item.price = 15; serverList[0] = player; -#pragma warning disable 618 // Type or member is obsolete bool callbackCalled = false; - clientList.Callback = (SyncList.Operation op, int itemIndex, TestPlayer oldItem, TestPlayer newItem) => + clientList.OnChange = (SyncList.Operation op, int itemIndex, TestPlayer oldItem) => { Assert.That(op == SyncList.Operation.OP_SET, Is.True); Assert.That(itemIndex, Is.EqualTo(0)); Assert.That(oldItem.item.price, Is.EqualTo(10)); - Assert.That(newItem.item.price, Is.EqualTo(15)); + Assert.That(clientList[itemIndex].item.price, Is.EqualTo(15)); callbackCalled = true; }; -#pragma warning restore 618 // Type or member is obsolete SyncListTest.SerializeDeltaTo(serverList, clientList); Assert.IsTrue(callbackCalled); diff --git a/Assets/Mirror/Tests/Editor/SyncCollections/SyncListTest.cs b/Assets/Mirror/Tests/Editor/SyncCollections/SyncListTest.cs index 845865387..8c60071e5 100644 --- a/Assets/Mirror/Tests/Editor/SyncCollections/SyncListTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncCollections/SyncListTest.cs @@ -97,16 +97,14 @@ public void TestAddRange() [Test] public void TestClear() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_CLEAR)); Assert.That(clientSyncList.Count, Is.EqualTo(3)); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnClear = () => @@ -125,17 +123,15 @@ public void TestClear() [Test] public void TestInsert() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_INSERT)); Assert.That(index, Is.EqualTo(0)); - Assert.That(newItem, Is.EqualTo("yay")); + Assert.That(clientSyncList[index], Is.EqualTo("yay")); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnInsert = (index) => @@ -162,18 +158,16 @@ public void TestInsertRange() [Test] public void TestSet() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_SET)); Assert.That(index, Is.EqualTo(1)); Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo("yay")); + Assert.That(clientSyncList[index], Is.EqualTo("yay")); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnSet = (index, oldItem) => @@ -194,18 +188,16 @@ public void TestSet() [Test] public void TestSetNull() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_SET)); Assert.That(index, Is.EqualTo(1)); Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo(null)); + Assert.That(clientSyncList[index], Is.EqualTo(null)); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnSet = (index, oldItem) => @@ -222,12 +214,8 @@ public void TestSetNull() Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); -#pragma warning disable 618 // Type or member is obsolete - // clear callback so we don't get called again - clientSyncList.Callback = null; -#pragma warning restore 618 // Type or member is obsolete - // clear handlers so we don't get called again + clientSyncList.OnChange = null; clientSyncList.OnSet = null; serverSyncList[1] = "yay"; @@ -238,18 +226,15 @@ public void TestSetNull() [Test] public void TestRemoveAll() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); Assert.That(index, Is.EqualTo(0)); Assert.That(oldItem, Is.Not.EqualTo("!")); - Assert.That(newItem, Is.EqualTo(default(string))); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnRemove = (index, item) => @@ -278,18 +263,15 @@ public void TestRemoveAllNone() [Test] public void TestRemoveAt() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); Assert.That(index, Is.EqualTo(1)); Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo(default(string))); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnRemove = (index, oldItem) => @@ -309,18 +291,15 @@ public void TestRemoveAt() [Test] public void TestRemove() { -#pragma warning disable 618 // Type or member is obsolete bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => + clientSyncList.OnChange = (op, index, oldItem) => { called = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); Assert.That(index, Is.EqualTo(1)); Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo(default(string))); }; -#pragma warning restore 618 // Type or member is obsolete bool actionCalled = false; clientSyncList.OnRemove = (index, oldItem) => @@ -442,19 +421,6 @@ public void SyncListFloatTest() [Test] public void CallbackTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncList.Operation.OP_ADD)); - Assert.That(index, Is.EqualTo(3)); - Assert.That(oldItem, Is.EqualTo(default(string))); - Assert.That(newItem, Is.EqualTo("yay")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncList.OnAdd = (index) => { @@ -475,7 +441,6 @@ public void CallbackTest() serverSyncList.Add("yay"); SerializeDeltaTo(serverSyncList, clientSyncList); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -483,18 +448,6 @@ public void CallbackTest() [Test] public void CallbackRemoveTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); - Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo(default(string))); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncList.OnRemove = (index, oldItem) => { @@ -509,12 +462,10 @@ public void CallbackRemoveTest() changeActionCalled = true; Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); Assert.That(index, Is.EqualTo(1)); - Assert.That(oldItem, Is.EqualTo("World")); }; serverSyncList.Remove("World"); SerializeDeltaTo(serverSyncList, clientSyncList); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -522,19 +473,6 @@ public void CallbackRemoveTest() [Test] public void CallbackRemoveAtTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncList.Callback = (op, index, oldItem, newItem) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncList.Operation.OP_REMOVEAT)); - Assert.That(index, Is.EqualTo(1)); - Assert.That(oldItem, Is.EqualTo("World")); - Assert.That(newItem, Is.EqualTo(default(string))); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncList.OnRemove = (index, oldItem) => { @@ -554,7 +492,6 @@ public void CallbackRemoveAtTest() serverSyncList.RemoveAt(1); SerializeDeltaTo(serverSyncList, clientSyncList); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } diff --git a/Assets/Mirror/Tests/Editor/SyncCollections/SyncSetTest.cs b/Assets/Mirror/Tests/Editor/SyncCollections/SyncSetTest.cs index 5fdb10122..b554ca5a5 100644 --- a/Assets/Mirror/Tests/Editor/SyncCollections/SyncSetTest.cs +++ b/Assets/Mirror/Tests/Editor/SyncCollections/SyncSetTest.cs @@ -93,17 +93,6 @@ public void TestRemove() [Test] public void TestClear() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncSet.Callback = (op, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncHashSet.Operation.OP_CLEAR)); - Assert.That(clientSyncSet.Count, Is.EqualTo(3)); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncSet.OnClear = () => { @@ -122,7 +111,6 @@ public void TestClear() serverSyncSet.Clear(); SerializeDeltaTo(serverSyncSet, clientSyncSet); Assert.That(clientSyncSet, Is.EquivalentTo(new string[] { })); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -141,17 +129,6 @@ public void TestMultSync() [Test] public void CallbackTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncSet.Callback = (op, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncHashSet.Operation.OP_ADD)); - Assert.That(item, Is.EqualTo("yay")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncSet.OnAdd = (item) => { @@ -169,7 +146,6 @@ public void CallbackTest() serverSyncSet.Add("yay"); SerializeDeltaTo(serverSyncSet, clientSyncSet); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); } @@ -177,17 +153,6 @@ public void CallbackTest() [Test] public void CallbackRemoveTest() { -#pragma warning disable 618 // Type or member is obsolete - bool called = false; - clientSyncSet.Callback = (op, item) => - { - called = true; - - Assert.That(op, Is.EqualTo(SyncHashSet.Operation.OP_REMOVE)); - Assert.That(item, Is.EqualTo("World")); - }; -#pragma warning restore 618 // Type or member is obsolete - bool actionCalled = false; clientSyncSet.OnRemove = (oldItem) => { @@ -205,7 +170,6 @@ public void CallbackRemoveTest() serverSyncSet.Remove("World"); SerializeDeltaTo(serverSyncSet, clientSyncSet); - Assert.That(called, Is.True); Assert.That(actionCalled, Is.True); Assert.That(changeActionCalled, Is.True); }