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
@@ -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/Generated/Component/NetworkAnimator/Editor/NetworkAnimatorEditor.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/NetworkAnimator/NetworkAnimator.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/NetworkTransform/Editor/NetworkTransformEditor.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/NetworkTransform/NetworkTransform.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/NetworkTransform/SynchronizedProperty.cs
uploadId: 866910
uploadId: 892096
@@ -1,10 +1,6 @@
using FishNet.Object;
using GameKit.Dependencies.Utilities;
using GameKit.Dependencies.Utilities.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;
using TimeManagerCls = FishNet.Managing.Timing.TimeManager;
@@ -15,15 +11,15 @@ namespace FishNet.Component.Prediction
/// <summary>
/// Called when another collider enters this collider.
/// </summary>
public event Action<Collider> OnEnter;
public event Action<Collider, uint> OnEnter;
/// <summary>
/// Called when another collider stays in this collider.
/// </summary>
public event Action<Collider> OnStay;
public event Action<Collider, uint> OnStay;
/// <summary>
/// Called when another collider exits this collider.
/// </summary>
public event Action<Collider> OnExit;
public event Action<Collider, uint> OnExit;
/// <summary>
/// The colliders on this object.
/// </summary>
@@ -33,66 +29,82 @@ namespace FishNet.Component.Prediction
/// </summary>
private Collider[] _hits;
/// <summary>
/// The history of collider data.
/// Colliders which are entered for a tick, be it stay or for the first time.
/// </summary>
private Dictionary<Collider, CollisionData> _enteredColliders;
private Dictionary<uint, HashSet<Collider>> _enteredColliders;
protected override void Awake()
{
base.Awake();
_enteredColliders = CollectionCaches<Collider, CollisionData>.RetrieveDictionary();
_enteredColliders = CollectionCaches<uint, HashSet<Collider>>.RetrieveDictionary();
_hits = CollectionCaches<Collider>.RetrieveArray();
if (_hits.Length < MaximumSimultaneousHits)
_hits = new Collider[MaximumSimultaneousHits];
}
private void OnDestroy()
public override void OnStopNetwork()
{
CollectionCaches<Collider, CollisionData>.StoreAndDefault(ref _enteredColliders);
base.OnStopNetwork();
StoreEnteredColliders(keepDictionary: true);
_enteredColliders?.Clear();
}
protected override void OnDestroy()
{
base.OnDestroy();
StoreEnteredColliders(keepDictionary: false);
CollectionCaches<Collider>.StoreAndDefault(ref _hits, _hits.Length);
}
/// <summary>
/// Called by the PredictionManager immediately before a reconcile begins.
/// </summary>
protected override void PredictionManager_OnPreReconcile(uint clientTick, uint serverTick)
protected override void PredictionManager_OnPostPhysicsTransformSync(uint clientTick, uint serverTick)
{
/* Remove entries older than the reconcile clientTick, if
* the entry is exited - as in the collider is no longer occupied. */
if (_enteredColliders.Count > 0)
{
List<Collider> entriesToRemove = CollectionCaches<Collider>.RetrieveList();
if (IsStopping)
return;
foreach (KeyValuePair<Collider, CollisionData> kvp in _enteredColliders)
if (clientTick > 0)
{
List<uint> keysToRemove = CollectionCaches<uint>.RetrieveList();
uint maximumTick = clientTick - 2;
foreach (uint enteredTick in _enteredColliders.Keys)
{
uint exitTick = kvp.Value.ExitTick;
if (exitTick != TimeManagerCls.UNSET_TICK && exitTick < clientTick)
entriesToRemove.Add(kvp.Key);
if (enteredTick < maximumTick)
keysToRemove.Add(enteredTick);
}
foreach (Collider entry in entriesToRemove)
_enteredColliders.Remove(entry);
foreach (uint tick in keysToRemove)
{
HashSet<Collider> colliders = _enteredColliders[tick];
CollectionCaches<Collider>.Store(colliders);
CollectionCaches<Collider>.Store(entriesToRemove);
_enteredColliders.Remove(tick);
}
CollectionCaches<uint>.Store(keysToRemove);
}
/* Call base only after removing old entries. This ensures old entries are removed
* before CheckColliders is called. */
base.PredictionManager_OnPreReconcile(clientTick, serverTick);
base.PredictionManager_OnPostPhysicsTransformSync(clientTick, serverTick);
}
/// <summary>
/// Checks for any collider changes;
/// </summary>
protected override void CheckColliders(uint clientTick)
protected override void CheckColliders(uint localTick)
{
// Initial checks failed.
if (!TryPrepareColliderCheck(clientTick))
if (!TryPrepareColliderCheck(localTick))
return;
HashSet<Collider> current = CollectionCaches<Collider>.RetrieveHashSet();
Dictionary<Collider, CollisionData> entered = _enteredColliders;
/* Previous may not be set here if there were
* no collisions during the previous tick. */
@@ -127,79 +139,78 @@ namespace FishNet.Component.Prediction
continue;
current.Add(hit);
}
// Already entered.
if (entered.TryGetValueIL2CPP(hit, out CollisionData collisionData))
/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider> enteredColliders))
{
CollectionCaches<Collider>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}
const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;
_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider> lastEnteredColliders);
/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;
/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
/* If entered tick is beyond the tick being checked then
* that means the collider entered at a later time, and something
* is not aligning. Invoke OnExit and OnEnter again. */
if (collisionData.EnterTick >= clientTick || collisionData.ExitTick != TimeManagerCls.UNSET_TICK)
//Invoke OnEnter for every collider in current.
foreach (Collider c in current)
OnEnter?.Invoke(c, localTick);
}
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
foreach (Collider c in current)
{
OnExit?.Invoke(hit);
OnEnter?.Invoke(hit);
// Also update position in collection.
entered[hit] = new(clientTick);
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
OnEnter?.Invoke(c, localTick);
}
}
// Not yet in entered state.
else
{
OnEnter?.Invoke(hit);
// Also update position in collection.
entered[hit] = new(clientTick);
}
// Always invoke OnStay when collider hits.
OnStay?.Invoke(hit);
}
List<Collider> collidersExited = CollectionCaches<Collider>.RetrieveList();
/* Check to invoke exit on any colliders which are no longer
* in the entered state. */
foreach (Collider c in entered.Keys)
//If current is empty the collection can be stored.
else
{
// Collider was still entered, no need to check exit.
if (current.Contains(c))
continue;
/* Entered tick will be the same as tick if first
* entering for this tick. It's not possible for Unity physics
* to invoke Enter/Exit on the same tick, as it doesn't make sense
* to anyway. When the same tick, continue. */
if (entered[c].EnterTick == clientTick)
continue;
collidersExited.Add(c);
CollectionCaches<Collider>.Store(current);
}
// Invoke for exited and remove from entered.
foreach (Collider c in collidersExited)
/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
{
/* If here then the entered collider was not hit
* this trace. Invoke exit and remove from entered. */
OnExit?.Invoke(c);
if (IsServerStarted)
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider c in lastEnteredColliders)
{
entered.Remove(c);
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
else
{
/* Only re-add if the entered tick is beyond
* the current tick; this would indicate a new enter.
* Otherwise, we are at an exit only. */
uint enteredTick = entered[c].EnterTick;
if (enteredTick > clientTick)
entered[c] = new(entered[c].EnterTick, clientTick);
else
entered.Remove(c);
}
}
CollectionCaches<Collider>.Store(collidersExited);
/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
{
if (lastTick is not unsetLastTick)
_enteredColliders.Remove(lastTick);
}
}
CollectionCaches<Collider>.Store(current);
}
/// <summary>
@@ -274,18 +285,34 @@ namespace FishNet.Component.Prediction
* to get the proper tick to invoke. */
if (invokeOnExit)
{
foreach (KeyValuePair<Collider, CollisionData> kvp in _enteredColliders)
uint largestTick = 0;
foreach (uint tick in _enteredColliders.Keys)
largestTick = Math.Max(tick, largestTick);
if (_enteredColliders.TryGetValueIL2CPP(largestTick, out HashSet<Collider> colliders))
{
/* This indicates an exit has not yet invoked.
* It's possible for an item to invoked an exit and still
* have its state cached for properly executing events during
* a reconcile. */
if (kvp.Value.ExitTick == TimeManagerCls.UNSET_TICK)
OnExit?.Invoke(kvp.Key);
if (colliders != null)
{
foreach (Collider c in colliders)
OnExit?.Invoke(c, TimeManagerCls.UNSET_TICK);
}
}
}
StoreEnteredColliders(keepDictionary: true);
_enteredColliders.Clear();
}
/// <summary>
/// Stores each Collider HashSet within EnteredColliders.
/// </summary>
private void StoreEnteredColliders(bool keepDictionary)
{
foreach (HashSet<Collider> colliders in _enteredColliders.Values)
CollectionCaches<Collider>.Store(colliders);
if (!keepDictionary)
CollectionCaches<uint, HashSet<Collider>>.Store(_enteredColliders);
}
}
}
@@ -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/Generated/Component/Prediction/NetworkCollider.cs
uploadId: 866910
uploadId: 892096
@@ -1,10 +1,6 @@
using FishNet.Managing;
using FishNet.Object;
using GameKit.Dependencies.Utilities;
using GameKit.Dependencies.Utilities.Types;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using TimeManagerCls = FishNet.Managing.Timing.TimeManager;
@@ -15,15 +11,15 @@ namespace FishNet.Component.Prediction
/// <summary>
/// Called when another collider enters this collider.
/// </summary>
public event Action<Collider2D> OnEnter;
public event Action<Collider2D, uint> OnEnter;
/// <summary>
/// Called when another collider stays in this collider.
/// </summary>
public event Action<Collider2D> OnStay;
public event Action<Collider2D, uint> OnStay;
/// <summary>
/// Called when another collider exits this collider.
/// </summary>
public event Action<Collider2D> OnExit;
public event Action<Collider2D, uint> OnExit;
/// <summary>
/// The colliders on this object.
/// </summary>
@@ -33,66 +29,82 @@ namespace FishNet.Component.Prediction
/// </summary>
private Collider2D[] _hits;
/// <summary>
/// The history of collider data.
/// Colliders which are entered for a tick, be it stay or for the first time.
/// </summary>
private Dictionary<Collider2D, CollisionData> _enteredColliders;
private Dictionary<uint, HashSet<Collider2D>> _enteredColliders;
protected override void Awake()
{
base.Awake();
_enteredColliders = CollectionCaches<Collider2D, CollisionData>.RetrieveDictionary();
_enteredColliders = CollectionCaches<uint, HashSet<Collider2D>>.RetrieveDictionary();
_hits = CollectionCaches<Collider2D>.RetrieveArray();
if (_hits.Length < MaximumSimultaneousHits)
_hits = new Collider2D[MaximumSimultaneousHits];
}
private void OnDestroy()
public override void OnStopNetwork()
{
CollectionCaches<Collider2D, CollisionData>.StoreAndDefault(ref _enteredColliders);
base.OnStopNetwork();
StoreEnteredColliders(keepDictionary: true);
_enteredColliders?.Clear();
}
protected override void OnDestroy()
{
base.OnDestroy();
CollectionCaches<uint, HashSet<Collider2D>>.StoreAndDefault(ref _enteredColliders);
CollectionCaches<Collider2D>.StoreAndDefault(ref _hits, _hits.Length);
}
/// <summary>
/// Called by the PredictionManager immediately before a reconcile begins.
/// </summary>
protected override void PredictionManager_OnPreReconcile(uint clientTick, uint serverTick)
protected override void PredictionManager_OnPostPhysicsTransformSync(uint clientTick, uint serverTick)
{
/* Remove entries older than the reconcile clientTick, if
* the entry is exited - as in the collider is no longer occupied. */
if (_enteredColliders.Count > 0)
{
List<Collider2D> entriesToRemove = CollectionCaches<Collider2D>.RetrieveList();
if (IsStopping)
return;
foreach (KeyValuePair<Collider2D, CollisionData> kvp in _enteredColliders)
if (clientTick > 0)
{
List<uint> keysToRemove = CollectionCaches<uint>.RetrieveList();
uint maximumTick = clientTick - 2;
foreach (uint enteredTick in _enteredColliders.Keys)
{
uint exitTick = kvp.Value.ExitTick;
if (exitTick != TimeManagerCls.UNSET_TICK && exitTick < clientTick)
entriesToRemove.Add(kvp.Key);
if (enteredTick < maximumTick)
keysToRemove.Add(enteredTick);
}
foreach (Collider2D entry in entriesToRemove)
_enteredColliders.Remove(entry);
foreach (uint tick in keysToRemove)
{
HashSet<Collider2D> colliders = _enteredColliders[tick];
CollectionCaches<Collider2D>.Store(colliders);
CollectionCaches<Collider2D>.Store(entriesToRemove);
_enteredColliders.Remove(tick);
}
CollectionCaches<uint>.Store(keysToRemove);
}
/* Call base only after removing old entries. This ensures old entries are removed
* before CheckColliders is called. */
base.PredictionManager_OnPreReconcile(clientTick, serverTick);
base.PredictionManager_OnPostPhysicsTransformSync(clientTick, serverTick);
}
/// <summary>
/// Checks for any collider changes;
/// </summary>
protected override void CheckColliders(uint clientTick)
protected override void CheckColliders(uint localTick)
{
// Initial checks failed.
if (!TryPrepareColliderCheck(clientTick))
// Initial checks failed.
if (!TryPrepareColliderCheck(localTick))
return;
HashSet<Collider2D> current = CollectionCaches<Collider2D>.RetrieveHashSet();
Dictionary<Collider2D, CollisionData> entered = _enteredColliders;
/* Previous may not be set here if there were
* no collisions during the previous tick. */
@@ -108,6 +120,7 @@ namespace FishNet.Component.Prediction
if (IsTrigger != col.isTrigger)
continue;
// Number of hits from the checks.
// Number of hits from the checks.
int hits;
if (col is CircleCollider2D circleCollider)
@@ -125,78 +138,78 @@ namespace FishNet.Component.Prediction
continue;
current.Add(hit);
}
// Already entered.
if (entered.TryGetValueIL2CPP(hit, out CollisionData collisionData))
/* If the colliders already exist then the tick is being
* run again, which would indicate this is being run during a reconcile.
*
* Since this key will have its data replaced with current, store the prior collection.*/
if (_enteredColliders.TryGetValueIL2CPP(localTick, out HashSet<Collider2D> enteredColliders))
{
CollectionCaches<Collider2D>.Store(enteredColliders);
_enteredColliders.Remove(localTick);
}
const uint unsetLastTick = uint.MaxValue;
uint lastTick = localTick > 1 ? localTick - 1 : unsetLastTick;
_enteredColliders.TryGetValueIL2CPP(lastTick, out HashSet<Collider2D> lastEnteredColliders);
/* If there are entered colliders then
* update enteredColliders for the tick. */
if (current.Count > 0)
{
_enteredColliders[localTick] = current;
/* If there were no colliders last tick
* then without a doubt enter should be called since
* the collider could not possibly be present already. */
if (lastEnteredColliders == null)
{
/* If entered tick is beyond the tick being checked then
* that means the collider entered at a later time, and something
* is not aligning. Invoke OnExit and OnEnter again. */
if (collisionData.EnterTick >= clientTick || collisionData.ExitTick != TimeManagerCls.UNSET_TICK)
//Invoke OnEnter for every collider in current.
foreach (Collider2D c in current)
OnEnter?.Invoke(c, localTick);
}
/* If the last collection is found then
* check to invoke Enter or Stay. */
else
{
foreach (Collider2D c in current)
{
OnExit?.Invoke(hit);
OnEnter?.Invoke(hit);
// Also update position in collection.
entered[hit] = new(clientTick);
if (lastEnteredColliders.Contains(c))
OnStay?.Invoke(c, localTick);
else
OnEnter?.Invoke(c, localTick);
}
}
// Not yet in entered state.
else
{
OnEnter?.Invoke(hit);
// Also update position in collection.
entered[hit] = new(clientTick);
}
// Always invoke OnStay when collider hits.
OnStay?.Invoke(hit);
}
//If current is empty the collection can be stored.
else
{
CollectionCaches<Collider2D>.Store(current);
}
List<Collider2D> collidersExited = CollectionCaches<Collider2D>.RetrieveList();
/* Check to invoke exit on any colliders which are no longer
* in the entered state. */
foreach (Collider2D c in entered.Keys)
/* Check to invoke OnExit. */
if (lastEnteredColliders != null)
{
// Collider was still entered, no need to check exit.
if (current.Contains(c))
continue;
/* Entered tick will be the same as tick if first
* entering for this tick. It's not possible for Unity physics
* to invoke Enter/Exit on the same tick, as it doesn't make sense
* to anyway. When the same tick, continue. */
if (entered[c].EnterTick == clientTick)
continue;
collidersExited.Add(c);
/* If current does not have the colliders from
* the last tick, then an exit has occurred. */
foreach (Collider2D c in lastEnteredColliders)
{
if (!current.Contains(c))
OnExit?.Invoke(c, localTick);
}
}
// Invoke for exited and remove from entered.
foreach (Collider2D c in collidersExited)
/* If the server is started the lastEnteredColliders can
* be discarded since the server will never reconcile, and
* will never need to check them again. */
if (IsServerStarted)
{
/* If here then the entered collider was not hit
* this trace. Invoke exit and remove from entered. */
OnExit?.Invoke(c);
if (IsServerStarted)
{
entered.Remove(c);
}
else
{
/* Only re-add if the entered tick is beyond
* the current tick; this would indicate a new enter.
* Otherwise, we are at an exit only. */
uint enteredTick = entered[c].EnterTick;
if (enteredTick > clientTick)
entered[c] = new(entered[c].EnterTick, clientTick);
else
entered.Remove(c);
}
// entered.Remove(c);
if (lastTick is not unsetLastTick)
_enteredColliders.Remove(lastTick);
}
}
CollectionCaches<Collider2D>.Store(current);
}
/// <summary>
@@ -260,18 +273,34 @@ namespace FishNet.Component.Prediction
* to get the proper tick to invoke. */
if (invokeOnExit)
{
foreach (KeyValuePair<Collider2D, CollisionData> kvp in _enteredColliders)
uint largestTick = 0;
foreach (uint tick in _enteredColliders.Keys)
largestTick = Math.Max(tick, largestTick);
if (_enteredColliders.TryGetValueIL2CPP(largestTick, out HashSet<Collider2D> colliders))
{
/* This indicates an exit has not yet invoked.
* It's possible for an item to invoked an exit and still
* have its state cached for properly executing events during
* a reconcile. */
if (kvp.Value.ExitTick == TimeManagerCls.UNSET_TICK)
OnExit?.Invoke(kvp.Key);
if (colliders != null)
{
foreach (Collider2D c in colliders)
OnExit?.Invoke(c, TimeManagerCls.UNSET_TICK);
}
}
}
StoreEnteredColliders(keepDictionary: true);
_enteredColliders.Clear();
}
/// <summary>
/// Stores each Collider HashSet within EnteredColliders.
/// </summary>
private void StoreEnteredColliders(bool keepDictionary)
{
foreach (HashSet<Collider2D> colliders in _enteredColliders.Values)
CollectionCaches<Collider2D>.Store(colliders);
if (!keepDictionary)
CollectionCaches<uint, HashSet<Collider2D>>.Store(_enteredColliders);
}
}
}
@@ -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/Generated/Component/Prediction/NetworkCollider2D.cs
uploadId: 866910
uploadId: 892096
@@ -9,32 +9,6 @@ namespace FishNet.Component.Prediction
{
public abstract class NetworkColliderBase : NetworkBehaviour
{
#region Types.
protected struct CollisionData
{
/// <summary>
/// Tick when entering collision.
/// </summary>
public uint EnterTick;
/// <summary>
/// Tick when exiting collision.
/// </summary>
public uint ExitTick;
public CollisionData(uint enterTick) : this()
{
EnterTick = enterTick;
ExitTick = Managing.Timing.TimeManager.UNSET_TICK;
}
public CollisionData(uint enterTick, uint exitTick) : this()
{
EnterTick = enterTick;
ExitTick = exitTick;
}
}
#endregion
/// <summary>
/// True to run collisions for colliders which are triggers, false to run collisions for colliders which are not triggers.
/// </summary>
@@ -76,15 +50,21 @@ namespace FishNet.Component.Prediction
/// </summary>
[HideInInspector]
protected int InteractableLayers;
/// <summary>
/// True if stopping or destroying.
/// </summary>
[HideInInspector]
protected bool IsStopping;
protected virtual void Awake()
{
TryFindColliders(force: true);
;
}
public override void OnStartNetwork()
{
IsStopping = false;
// Events needed by server and client.
TimeManager.OnPostPhysicsSimulation += TimeManager_OnPostPhysicsSimulation;
}
@@ -92,24 +72,33 @@ namespace FishNet.Component.Prediction
public override void OnStartClient()
{
// Events only needed by the client.
PredictionManager.OnPostReconcileSyncTransforms += PredictionManager_OnPreReconcile;
PredictionManager.OnPostPhysicsTransformSync += PredictionManager_OnPostPhysicsTransformSync;
}
public override void OnStopClient()
{
// Events only needed by the client.
PredictionManager.OnPostReconcileSyncTransforms -= PredictionManager_OnPreReconcile;
PredictionManager.OnPostPhysicsTransformSync -= PredictionManager_OnPostPhysicsTransformSync;
}
public override void OnStopNetwork()
{
IsStopping = true;
TimeManager.OnPostPhysicsSimulation -= TimeManager_OnPostPhysicsSimulation;
}
/// <summary>
/// Called by the PredictionManager immediately before a reconcile begins.
/// </summary>
protected virtual void PredictionManager_OnPreReconcile(uint clientTick, uint serverTick)
protected virtual void OnDestroy()
{
IsStopping = true;
if (TimeManager != null)
TimeManager.OnPostPhysicsSimulation -= TimeManager_OnPostPhysicsSimulation;
if (PredictionManager != null)
PredictionManager.OnPostPhysicsTransformSync -= PredictionManager_OnPostPhysicsTransformSync;
}
protected virtual void PredictionManager_OnPostPhysicsTransformSync(uint clientTick, uint serverTick)
{
CheckColliders(clientTick);
}
@@ -120,7 +109,7 @@ namespace FishNet.Component.Prediction
/// This may be useful if you wish to run physics differently for stacked scenes.
private void TimeManager_OnPostPhysicsSimulation(float delta)
{
uint tick = PredictionManager.IsReconciling && !IsServerStarted ? PredictionManager.ClientReplayTick : TimeManager.LocalTick;
uint tick = IsServerStarted || !PredictionManager.IsReconciling ? TimeManager.LocalTick : PredictionManager.ClientReplayTick;
CheckColliders(tick);
}
@@ -130,6 +119,9 @@ namespace FishNet.Component.Prediction
/// <returns>True if collision checking should proceed, false if not.</returns>
protected bool TryPrepareColliderCheck(uint tick)
{
if (IsStopping)
return false;
// Should not be possible as tick always starts on 1.
if (tick == TimeManagerCls.UNSET_TICK)
return false;
@@ -159,7 +151,7 @@ namespace FishNet.Component.Prediction
/// <summary>
/// Implement collider checking logic within this method.
/// </summary>
protected abstract void CheckColliders(uint clientTick);
protected abstract void CheckColliders(uint localTick);
/// <summary>
/// Clears stored collider states.
@@ -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/Generated/Component/Prediction/NetworkColliderBase.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Prediction/NetworkCollision.cs
uploadId: 866910
uploadId: 892096
@@ -1,13 +1,13 @@
using UnityEngine;
namespace FishNet.Component.Prediction
{
public sealed class NetworkCollision2D : NetworkCollider2D
{
protected override void Awake()
{
IsTrigger = false;
base.Awake();
}
}
}
// using UnityEngine;
//
// namespace FishNet.Component.Prediction
// {
// public sealed class NetworkCollision2D : NetworkCollider2D
// {
// protected override void Awake()
// {
// IsTrigger = false;
// base.Awake();
// }
// }
// }
@@ -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/Generated/Component/Prediction/NetworkCollision2D.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Prediction/NetworkTrigger.cs
uploadId: 866910
uploadId: 892096
@@ -1,11 +1,11 @@
namespace FishNet.Component.Prediction
{
public sealed class NetworkTrigger2D : NetworkCollider2D
{
protected override void Awake()
{
IsTrigger = true;
base.Awake();
}
}
}
// namespace FishNet.Component.Prediction
// {
// public sealed class NetworkTrigger2D : NetworkCollider2D
// {
// protected override void Awake()
// {
// IsTrigger = true;
// base.Awake();
// }
// }
// }
@@ -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/Generated/Component/Prediction/NetworkTrigger2D.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Prediction/OfflineRigidbody.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Prediction/RigidbodyPauser.cs
uploadId: 866910
uploadId: 892096
@@ -19,8 +19,8 @@ namespace FishNet.Component.Prediction
public RigidbodyState(Rigidbody rb, AutoPackType rotationPacking = AutoPackType.Packed)
{
Position = rb.transform.position;
Rotation = rb.transform.rotation;
Position = rb.transform.localPosition;
Rotation = rb.transform.localRotation;
IsKinematic = rb.isKinematic;
#if UNITY_6000_1_OR_NEWER
@@ -49,8 +49,8 @@ namespace FishNet.Component.Prediction
public Rigidbody2DState(Rigidbody2D rb, AutoPackType rotationPacking = AutoPackType.Packed)
{
Position = rb.transform.position;
Rotation = rb.transform.rotation;
Position = rb.transform.localPosition;
Rotation = rb.transform.localRotation;
RotationPacking = rotationPacking;
#if UNITY_6000_1_OR_NEWER
@@ -176,8 +176,8 @@ namespace FishNet.Component.Prediction
public static void SetState(this Rigidbody rb, RigidbodyState state)
{
Transform t = rb.transform;
t.position = state.Position;
t.rotation = state.Rotation;
t.localPosition = state.Position;
t.localRotation = state.Rotation;
rb.isKinematic = state.IsKinematic;
if (!state.IsKinematic)
@@ -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/Generated/Component/Prediction/RigidbodyState.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Prediction/RigidbodyType.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Spawning/PlayerSpawner.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Spawning/ServerSpawner.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TakeOwnership/PredictedOwner.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TakeOwnership/PredictedSpawn.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/AdaptiveInterpolationType.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/Editor/MovementSettingsDrawer.Threaded.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/Editor/MovementSettingsDrawer.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/Editor/NetworkTickSmootherEditor.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/Editor/OfflineTickSmootherEditor.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/InitializationSettings.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/MovementSettings.Threaded.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/MovementSettings.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/NetworkTickSmoother.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/OfflineTickSmoother.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/TickSmootherController.Threaded.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/TickSmootherController.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/TickSmoothingManager.Types.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/TickSmoothingManager.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/UniversalTickSmoother.Threaded.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/TickSmoothing/UniversalTickSmoother.cs
uploadId: 866910
uploadId: 892096
@@ -1,9 +1,7 @@
using System;
using FishNet.Editing;
using FishNet.Editing.NetworkProfiler;
using FishNet.Managing;
using FishNet.Managing.Statistic;
using FishNet.Managing.Timing;
using GameKit.Dependencies.Utilities;
using GameKit.Dependencies.Utilities.Types;
using UnityEngine;
@@ -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/Generated/Component/Utility/BandwidthDisplay.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Utility/DefaultScene.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Utility/DetachableNetworkTickSmoother.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Utility/Editor/DetachableNetworkTickSmootherEditor.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Utility/MonoTickSmoother.cs
uploadId: 866910
uploadId: 892096
@@ -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/Generated/Component/Utility/PingDisplay.cs
uploadId: 866910
uploadId: 892096