mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix(NetworkTransform): Separate ResetState (#3738)
We should not have hijacked Unity's callback for runtime resets.
This commit is contained in:
parent
ac050a804d
commit
b885db3703
@ -311,9 +311,9 @@ public void RpcTeleport(Vector3 destination, Quaternion rotation)
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
void RpcReset()
|
||||
void RpcResetState()
|
||||
{
|
||||
Reset();
|
||||
ResetState();
|
||||
}
|
||||
|
||||
// common Teleport code for client->server and server->client
|
||||
@ -367,7 +367,7 @@ protected virtual void OnTeleport(Vector3 destination, Quaternion rotation)
|
||||
// -> maybe add destination as first entry?
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
public virtual void ResetState()
|
||||
{
|
||||
// disabled objects aren't updated anymore.
|
||||
// so let's clear the buffers.
|
||||
@ -375,9 +375,14 @@ public virtual void Reset()
|
||||
clientSnapshots.Clear();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
ResetState();
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
Reset();
|
||||
ResetState();
|
||||
|
||||
if (NetworkServer.active)
|
||||
NetworkIdentity.clientAuthorityCallback += OnClientAuthorityChanged;
|
||||
@ -385,7 +390,7 @@ protected virtual void OnEnable()
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
Reset();
|
||||
ResetState();
|
||||
|
||||
if (NetworkServer.active)
|
||||
NetworkIdentity.clientAuthorityCallback -= OnClientAuthorityChanged;
|
||||
@ -403,8 +408,8 @@ void OnClientAuthorityChanged(NetworkConnectionToClient conn, NetworkIdentity id
|
||||
|
||||
if (syncDirection == SyncDirection.ClientToServer)
|
||||
{
|
||||
Reset();
|
||||
RpcReset();
|
||||
ResetState();
|
||||
RpcResetState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,9 +402,9 @@ static void RewriteHistory(
|
||||
// reset state for next session.
|
||||
// do not ever call this during a session (i.e. after teleport).
|
||||
// calling this will break delta compression.
|
||||
public override void Reset()
|
||||
public override void ResetState()
|
||||
{
|
||||
base.Reset();
|
||||
base.ResetState();
|
||||
|
||||
// reset delta
|
||||
lastSerializedPosition = Vector3Long.zero;
|
||||
|
@ -346,7 +346,7 @@ protected virtual void OnClientToServerSync(Vector3? position, Quaternion? rotat
|
||||
double timeIntervalCheck = bufferResetMultiplier * sendIntervalMultiplier * NetworkClient.sendInterval;
|
||||
|
||||
if (serverSnapshots.Count > 0 && serverSnapshots.Values[serverSnapshots.Count - 1].remoteTime + timeIntervalCheck < timestamp)
|
||||
Reset();
|
||||
ResetState();
|
||||
}
|
||||
|
||||
AddSnapshot(serverSnapshots, connectionToClient.remoteTimeStamp + timeStampAdjustment + offset, position, rotation, scale);
|
||||
@ -401,7 +401,7 @@ protected virtual void OnServerToClientSync(Vector3? position, Quaternion? rotat
|
||||
double timeIntervalCheck = bufferResetMultiplier * sendIntervalMultiplier * NetworkServer.sendInterval;
|
||||
|
||||
if (clientSnapshots.Count > 0 && clientSnapshots.Values[clientSnapshots.Count - 1].remoteTime + timeIntervalCheck < timestamp)
|
||||
Reset();
|
||||
ResetState();
|
||||
}
|
||||
|
||||
AddSnapshot(clientSnapshots, NetworkClient.connection.remoteTimeStamp + timeStampAdjustment + offset, position, rotation, scale);
|
||||
|
Loading…
Reference in New Issue
Block a user