Add StickGame Assets
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using FishNet.Object;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FishNet.Component.ColliderRollback
|
||||
{
|
||||
|
||||
public class ColliderRollback : NetworkBehaviour
|
||||
{
|
||||
#region Types.
|
||||
internal enum BoundingBoxType
|
||||
{
|
||||
/// <summary>
|
||||
/// Disable this feature.
|
||||
/// </summary>
|
||||
Disabled,
|
||||
/// <summary>
|
||||
/// Manually specify the dimensions of a bounding box.
|
||||
/// </summary>
|
||||
Manual,
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serialized.
|
||||
/// <summary>
|
||||
/// How to configure the bounding box check.
|
||||
/// </summary>
|
||||
[Tooltip("How to configure the bounding box check.")]
|
||||
[SerializeField]
|
||||
private BoundingBoxType _boundingBox = BoundingBoxType.Disabled;
|
||||
/// <summary>
|
||||
/// Physics type to generate a bounding box for.
|
||||
/// </summary>
|
||||
[Tooltip("Physics type to generate a bounding box for.")]
|
||||
[SerializeField]
|
||||
private RollbackPhysicsType _physicsType = RollbackPhysicsType.Physics;
|
||||
/// <summary>
|
||||
/// Size for the bounding box. This is only used when BoundingBox is set to Manual.
|
||||
/// </summary>
|
||||
[Tooltip("Size for the bounding box.. This is only used when BoundingBox is set to Manual.")]
|
||||
[SerializeField]
|
||||
private Vector3 _boundingBoxSize = new Vector3(3f, 3f, 3f);
|
||||
/// <summary>
|
||||
/// Objects holding colliders which can rollback.
|
||||
/// </summary>
|
||||
[Tooltip("Objects holding colliders which can rollback.")]
|
||||
[SerializeField]
|
||||
private GameObject[] _colliderParents = new GameObject[0];
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01a271dd97d875347b0cea860df29a9d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: bf9191e2e07d29749bca3a1ae44e4bc8, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using static FishNet.Component.ColliderRollback.ColliderRollback;
|
||||
|
||||
namespace FishNet.Component.ColliderRollback
|
||||
{
|
||||
|
||||
[CustomEditor(typeof(ColliderRollback), true)]
|
||||
[CanEditMultipleObjects]
|
||||
public class ColliderRollbackEditor : Editor
|
||||
{
|
||||
private SerializedProperty _boundingBox;
|
||||
private SerializedProperty _physicsType;
|
||||
private SerializedProperty _boundingBoxSize;
|
||||
private SerializedProperty _colliderParents;
|
||||
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_boundingBox = serializedObject.FindProperty(nameof(_boundingBox));
|
||||
_physicsType = serializedObject.FindProperty(nameof(_physicsType));
|
||||
_boundingBoxSize = serializedObject.FindProperty(nameof(_boundingBoxSize));
|
||||
_colliderParents = serializedObject.FindProperty(nameof(_colliderParents));
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
ColliderRollback nob = (ColliderRollback)target;
|
||||
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour(nob), typeof(ColliderRollback), false);
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.PropertyField(_boundingBox, new GUIContent("Bounding Box (experimental)"));
|
||||
if ((BoundingBoxType)_boundingBox.intValue != BoundingBoxType.Disabled)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_physicsType);
|
||||
EditorGUILayout.PropertyField(_boundingBoxSize);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
EditorGUILayout.PropertyField(_colliderParents);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0fd7d7c980dbbc49b3ab071b1974d33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,213 @@
|
||||
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.
|
||||
/// <summary>
|
||||
/// Cached value for bounding box layermask.
|
||||
/// </summary>
|
||||
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.
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Tooltip("Layer to use when creating and checking against bounding boxes. This should be different from any layer used.")]
|
||||
[SerializeField]
|
||||
private LayerMask _boundingBoxLayer = 0;
|
||||
/// <summary>
|
||||
/// Layer to use when creating and checking against bounding boxes. This should be different from any layer used.
|
||||
/// </summary>
|
||||
internal LayerMask BoundingBoxLayer => _boundingBoxLayer;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Tooltip("Maximum time in the past colliders can be rolled back to.")]
|
||||
[SerializeField]
|
||||
private float _maximumRollbackTime = 1.25f;
|
||||
/// <summary>
|
||||
/// Maximum time in the past colliders can be rolled back to.
|
||||
/// </summary>
|
||||
internal float MaximumRollbackTime => _maximumRollbackTime;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Tooltip("Interpolation value for the NetworkTransforms or objects being rolled back.")]
|
||||
[Range(0, 250)]
|
||||
[SerializeField]
|
||||
internal ushort Interpolation = 2;
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this script for use.
|
||||
/// </summary>
|
||||
/// <param name="manager"></param>
|
||||
internal void InitializeOnce_Internal(NetworkManager manager)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all colliders.
|
||||
/// </summary>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="physicsType">Type of physics to rollback; this is often what your casts will use.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
[Obsolete("Use Rollback(PreciseTick, RollbackPhysicsType, bool)")] //Remove on 2024/01/01.
|
||||
public void Rollback(PreciseTick pt, PhysicsType physicsType, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all colliders.
|
||||
/// </summary>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="physicsType">Type of physics to rollback; this is often what your casts will use.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
public void Rollback(PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all colliders.
|
||||
/// </summary>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="physicsType">Type of physics to rollback; this is often what your casts will use.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Rollback(Scene scene, PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Rolls back all colliders.
|
||||
/// </summary>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="physicsType">Type of physics to rollback; this is often what your casts will use.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
public void Rollback(int sceneHandle, PreciseTick pt, RollbackPhysicsType physicsType, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all 3d colliders hit by a test cast against bounding boxes.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray origin.</param>
|
||||
/// <param name="normalizedDirection">Direction to cast.</param>
|
||||
/// <param name="distance">Distance of cast.</param>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
public void Rollback(Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all 3d colliders hit by a test cast against bounding boxes.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray origin.</param>
|
||||
/// <param name="normalizedDirection">Direction to cast.</param>
|
||||
/// <param name="distance">Distance of cast.</param>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Rollback(Scene scene, Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Rolls back all 3d colliders hit by a test cast against bounding boxes.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray origin.</param>
|
||||
/// <param name="normalizedDirection">Direction to cast.</param>
|
||||
/// <param name="distance">Distance of cast.</param>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
public void Rollback(int sceneHandle, Vector3 origin, Vector3 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rolls back all 3d colliders hit by a test cast against bounding boxes.
|
||||
/// </summary>
|
||||
/// <param name="origin">Ray origin.</param>
|
||||
/// <param name="normalizedDirection">Direction to cast.</param>
|
||||
/// <param name="distance">Distance of cast.</param>
|
||||
/// <param name="pt">Precise tick received from the client.</param>
|
||||
/// <param name="asOwner">True if IsOwner of the object the raycast is for. This can be ignored and only provides more accurate results for clientHost.</param>
|
||||
public void Rollback(Vector2 origin, Vector2 normalizedDirection, float distance, PreciseTick pt, bool asOwner = false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all ColliderRollback objects back to their original position.
|
||||
/// </summary>
|
||||
public void Return()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b185516acd802904383e2a5f1a666750
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: bf9191e2e07d29749bca3a1ae44e4bc8, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace FishNet.Component.ColliderRollback
|
||||
{
|
||||
/// <summary>
|
||||
/// Which physics to apply after rolling back colliders.
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public enum RollbackPhysicsType
|
||||
{
|
||||
Physics = 1,
|
||||
Physics2D = 2,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82b31e74d64a0c44d8fa2f3b6b08ebca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user