Update FishNet

This commit is contained in:
2026-04-07 03:11:52 +07:00
parent 9675b7b31d
commit ba7513d478
869 changed files with 3675 additions and 2764 deletions
@@ -10,13 +10,24 @@ namespace FishNet.Managing.Observing.Editing
{
private SerializedProperty _updateHostVisibility;
private SerializedProperty _maximumTimedObserversDuration;
private SerializedProperty _defaultConditions;
private SerializedProperty _defaultConditions
;
private SerializedProperty _useLevelOfDetail;
private SerializedProperty _maximumLevelOfDetailInterval;
private SerializedProperty _levelOfDetailUpdateDuration;
private SerializedProperty _levelOfDetailDistances;
protected virtual void OnEnable()
{
_updateHostVisibility = serializedObject.FindProperty(nameof(_updateHostVisibility));
_maximumTimedObserversDuration = serializedObject.FindProperty(nameof(_maximumTimedObserversDuration));
_defaultConditions = serializedObject.FindProperty(nameof(_defaultConditions));
_useLevelOfDetail = serializedObject.FindProperty(nameof(_useLevelOfDetail));
_maximumLevelOfDetailInterval = serializedObject.FindProperty(nameof(_maximumLevelOfDetailInterval));
_levelOfDetailUpdateDuration = serializedObject.FindProperty(nameof(_levelOfDetailUpdateDuration));
_levelOfDetailDistances = serializedObject.FindProperty(nameof(_levelOfDetailDistances));
}
public override void OnInspectorGUI()
@@ -27,7 +38,7 @@ namespace FishNet.Managing.Observing.Editing
EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour((ObserverManager)target), typeof(ObserverManager), false);
GUI.enabled = true;
EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
EditorGUILayout.LabelField("Observers", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_updateHostVisibility);
@@ -38,8 +49,29 @@ namespace FishNet.Managing.Observing.Editing
EditorGUI.indentLevel--;
EditorGUILayout.LabelField("Level of Detail *", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
if (Application.isPlaying)
GUI.enabled = false;
EditorGUILayout.PropertyField(_useLevelOfDetail);
if (_useLevelOfDetail.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_maximumLevelOfDetailInterval, new GUIContent("Maximum Send Interval"));
EditorGUILayout.PropertyField(_levelOfDetailUpdateDuration, new GUIContent("Recalculation Duration"));
EditorGUILayout.PropertyField(_levelOfDetailDistances);
EditorGUI.indentLevel--;
}
GUI.enabled = true;
EditorGUI.indentLevel--;
serializedObject.ApplyModifiedProperties();
}
}
}
}
#endif
@@ -13,6 +13,6 @@ AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
packageVersion: 4.7.1R
assetPath: Assets/FishNet/Runtime/Managing/Observing/Editor/ObserverManagerEditor.cs
uploadId: 866910
uploadId: 892096
@@ -0,0 +1,19 @@
namespace FishNet.Managing.Observing
{
/// <summary>
/// A configuration which affects the level of detail for a connection.
/// </summary>
public struct LevelOfDetail
{
/// <summary>
/// How often data will send when on this level of detail.
/// </summary>
public ushort SendInterval;
/// <summary>
/// Distance a connection's objects must be within to use this LevelOfDetail.
/// </summary>
public ushort Distance;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 573375ac2883b974c9201b040a432f76
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.7.1R
assetPath: Assets/FishNet/Runtime/Managing/Observing/LevelOfDetail.cs
uploadId: 892096
@@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using FishNet.Connection;
using FishNet.Managing.Timing;
using FishNet.Object;
using FishNet.Utility;
using GameKit.Dependencies.Utilities;
using UnityEngine;
namespace FishNet.Managing.Observing
{
/// <summary>
/// Handles level of detail actions.
/// </summary>
public sealed partial class ObserverManager : MonoBehaviour
{
/// <summary>
/// Most recent LocalTick value on the TimeManager.
/// </summary>
internal uint LocalTick;
[Tooltip("True to enable level of detail.")]
[SerializeField]
private bool _useLevelOfDetail;
/// <summary>
/// The maximum delay between updates when an object is using the highest level of detail.
/// </summary>
[Tooltip("The maximum delay between updates when an object is using the highest level of detail.")]
[Range(MINIMUM_LEVEL_OF_DETAIL_SEND_INTERVAL, MAXIMUM_LEVEL_OF_DETAIL_SEND_INTERVAL)]
[SerializeField]
private float _maximumLevelOfDetailInterval = 2f;
/// <summary>
/// The time it will take to calculate new level of detail values.
/// </summary>
[Tooltip("The time it will take to calculate new level of detail values.")]
[Range(MINIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION, MAXIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION)]
[SerializeField]
private float _levelOfDetailUpdateDuration = 1f;
/// <summary>
/// Distances for each level of detail change. Each distance is an exponential increase. When the largest distance is surpassed the maximum delay is used; while within the first distance standard delays are used.
/// </summary>
[Tooltip("Distances for each level of detail change. Each distance is an exponential increase. When the largest distance is surpassed the maximum delay is used; while within the first distance standard delays are used.")]
[SerializeField]
private List<float> _levelOfDetailDistances = new();
#region Consts.
/// <summary>
/// Minimum time allowed for the maximum level of detail send interval.
/// </summary>
private const float MINIMUM_LEVEL_OF_DETAIL_SEND_INTERVAL = 0.1f;
/// <summary>
/// Maximum time allowed for the maximum level of detail send interval.
/// </summary>
private const float MAXIMUM_LEVEL_OF_DETAIL_SEND_INTERVAL = 15f;
/// <summary>
/// Minimum time which can be used for the level of detail update duration.
/// </summary>
private const float MINIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION = 0.5f;
/// <summary>
/// Maximum time which can be used for the level of detail update duration.
/// </summary>
private const float MAXIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION = 10f;
#endregion
/// <summary>
/// Initializes for level of detail use.
/// </summary>
/// <returns>New UseLevelOfDetail value.</returns>
private bool InitializeLevelOfDetailValues()
{
return false;
}
/// <summary>
/// Updates the duration of how long level of update values should be recalculated.
/// </summary>
public void SetLevelOfDetailRecalculationDuration(float duration) => _levelOfDetailUpdateDuration = Mathf.Clamp(duration, MINIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION, MAXIMUM_LEVEL_OF_DETAIL_UPDATE_DURATION);
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 72fa5d7278196bd4f82ad85cd7d20038
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: bf9191e2e07d29749bca3a1ae44e4bc8, type: 3}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.7.1R
assetPath: Assets/FishNet/Runtime/Managing/Observing/ObserverManager.LevelOfDetail.cs
uploadId: 892096
@@ -1,12 +1,11 @@
using FishNet.Component.Observing;
using FishNet.Connection;
using FishNet.Connection;
using FishNet.Object;
using FishNet.Observing;
using FishNet.Utility;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using FishNet.Managing.Timing;
using UnityEngine;
using UnityEngine.Serialization;
[assembly: InternalsVisibleTo(UtilityConstants.DEMOS_ASSEMBLY_NAME)]
[assembly: InternalsVisibleTo(UtilityConstants.TEST_ASSEMBLY_NAME)]
@@ -18,7 +17,7 @@ namespace FishNet.Managing.Observing
/// </summary>
[DisallowMultipleComponent]
[AddComponentMenu("FishNet/Manager/ObserverManager")]
public sealed class ObserverManager : MonoBehaviour
public sealed partial class ObserverManager : MonoBehaviour
{
#region Serialized.
/// <summary>
@@ -71,7 +70,7 @@ namespace FishNet.Managing.Observing
/// </summary>
private const float MINIMUM_TIMED_OBSERVERS_DURATION = 0.1f;
/// <summary>
/// Maxmimum time allowed for timed observers to rebuild.
/// Maximum time allowed for timed observers to rebuild.
/// </summary>
private const float MAXIMUM_TIMED_OBSERVERS_DURATION = 20f;
#endregion
@@ -85,6 +84,8 @@ namespace FishNet.Managing.Observing
_networkManager = manager;
// Update the current value to itself so it becomes clamped. This is just to protect against the user manually setting it outside clamp somehow.
SetMaximumTimedObserversDuration(MaximumTimedObserversDuration);
_useLevelOfDetail = InitializeLevelOfDetailValues();
}
/// <summary>
@@ -213,5 +214,6 @@ namespace FishNet.Managing.Observing
return result;
}
}
}
@@ -13,6 +13,6 @@ AssetOrigin:
serializedVersion: 1
productId: 207815
packageName: 'FishNet: Networking Evolved'
packageVersion: 4.6.22R
packageVersion: 4.7.1R
assetPath: Assets/FishNet/Runtime/Managing/Observing/ObserverManager.cs
uploadId: 866910
uploadId: 892096