using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Scened; using FishNet.Managing.Timing; using FishNet.Transporting; using GameKit.Utilities; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; using UnityEngine.SceneManagement; namespace FishNet.Component.ColliderRollback { public class RollbackManager : MonoBehaviour { #region Types. [System.Serializable, System.Flags] //Remove on 2024/01/01, replace with PhysicsType that is not part of RollbackManager. public enum PhysicsType : byte { TwoDimensional = 1, ThreeDimensional = 2, Both = 4 } #endregion #region Internal. /// /// Cached value for bounding box layermask. /// internal int? BoundingBoxLayerNumber { get { if (_boundingBoxLayerNumber == null) { for (int i = 0; i < 32; i++) { if ((1 << i) == BoundingBoxLayer.value) { _boundingBoxLayerNumber = i; break; } } } return _boundingBoxLayerNumber; } } private int? _boundingBoxLayerNumber; #endregion #region Serialized. /// /// /// [Tooltip("Layer to use when creating and checking against bounding boxes. This should be different from any layer used.")] [SerializeField] private LayerMask _boundingBoxLayer = 0; /// /// Layer to use when creating and checking against bounding boxes. This should be different from any layer used. /// internal LayerMask BoundingBoxLayer => _boundingBoxLayer; /// /// /// [Tooltip("Maximum time in the past colliders can be rolled back to.")] [SerializeField] private float _maximumRollbackTime = 1.25f; /// /// Maximum time in the past colliders can be rolled back to. /// internal float MaximumRollbackTime => _maximumRollbackTime; /// /// /// [Tooltip("Interpolation value for the NetworkTransforms or objects being rolled back.")] [Range(0, 250)] [SerializeField] internal ushort Interpolation = 2; #endregion /// /// Initializes this script for use. /// /// internal void InitializeOnce_Internal(NetworkManager manager) { } /// /// Rolls back all colliders. /// /// Precise tick received from the client. /// Type of physics to rollback; this is often what your casts will use. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. [Obsolete("Use Rollback(PreciseTick, RollbackPhysicsType, bool)")] //Remove on 2024/01/01. public void Rollback(PreciseTick pt, PhysicsType physicsType, bool asOwner = false) { } /// /// Rolls back all colliders. /// /// Precise tick received from the client. /// Type of physics to rollback; this is often what your casts will use. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. public void Rollback(PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false) { } /// /// Rolls back all colliders. /// /// Precise tick received from the client. /// Type of physics to rollback; this is often what your casts will use. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Rollback(Scene scene, PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false) { } /// /// Rolls back all colliders. /// /// Precise tick received from the client. /// Type of physics to rollback; this is often what your casts will use. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. public void Rollback(int sceneHandle, PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false) { } /// /// Rolls back all 3d colliders hit by a test cast against bounding boxes. /// /// Ray origin. /// Direction to cast. /// Distance of cast. /// Precise tick received from the client. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. public void Rollback(Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false) { } /// /// Rolls back all 3d colliders hit by a test cast against bounding boxes. /// /// Ray origin. /// Direction to cast. /// Distance of cast. /// Precise tick received from the client. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Rollback(Scene scene, Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false) { } /// /// Rolls back all 3d colliders hit by a test cast against bounding boxes. /// /// Ray origin. /// Direction to cast. /// Distance of cast. /// Precise tick received from the client. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. public void Rollback(int sceneHandle, Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false) { } /// /// Rolls back all 3d colliders hit by a test cast against bounding boxes. /// /// Ray origin. /// Direction to cast. /// Distance of cast. /// Precise tick received from the client. /// True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost. public void Rollback(Vector2 origin, Vector2 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false) { } /// /// Returns all ColliderRollback objects back to their original position. /// public void Return() { } } }