修改操作方式为 坦克式运动
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
fileFormatVersion: 2
|
||||
guid: 3dc7b1ecbad541ea86a9d700dd5148e0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -87,9 +87,10 @@ namespace Network.NetworkApplication
|
||||
if (sessionManager.State == ConnectionState.Disconnected)
|
||||
{
|
||||
sessionManager.NotifyTransportConnected();
|
||||
return;
|
||||
}
|
||||
|
||||
sessionManager.NotifyInboundActivity();
|
||||
sessionManager.NotifyTransportActivity();
|
||||
}
|
||||
|
||||
public void NotifyTransportConnected(IPEndPoint remoteEndPoint)
|
||||
|
||||
@@ -60,7 +60,8 @@ namespace Network.NetworkApplication
|
||||
SyncSequenceTracker syncSequenceTracker = null,
|
||||
Func<int, ITransport> transportFactory = null,
|
||||
ServerAuthoritativeMovementConfiguration authoritativeMovement = null,
|
||||
ServerAuthoritativeCombatConfiguration authoritativeCombat = null)
|
||||
ServerAuthoritativeCombatConfiguration authoritativeCombat = null,
|
||||
IAuthoritativeMovementWorldValidator authoritativeMovementWorldValidator = null)
|
||||
{
|
||||
ValidateDualPortConfiguration(reliablePort, syncPort);
|
||||
|
||||
@@ -86,7 +87,8 @@ namespace Network.NetworkApplication
|
||||
deliveryPolicyResolver,
|
||||
syncSequenceTracker,
|
||||
authoritativeMovement,
|
||||
authoritativeCombat);
|
||||
authoritativeCombat,
|
||||
authoritativeMovementWorldValidator ?? PermissiveAuthoritativeMovementWorldValidator.Instance);
|
||||
}
|
||||
|
||||
public static Task<ServerRuntimeHandle> StartServerRuntimeAsync(ServerRuntimeConfiguration configuration)
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace Network.NetworkApplication
|
||||
{
|
||||
public sealed class SessionManager
|
||||
{
|
||||
private readonly Func<DateTimeOffset> utcNowProvider;
|
||||
private DateTimeOffset? lastLivenessUtc;
|
||||
private DateTimeOffset? lastAcceptedLivenessUtc;
|
||||
private DateTimeOffset? lastTransportActivityUtc;
|
||||
private DateTimeOffset? lastHeartbeatSentUtc;
|
||||
private DateTimeOffset? nextReconnectAtUtc;
|
||||
|
||||
@@ -24,7 +25,9 @@ namespace Network.NetworkApplication
|
||||
|
||||
public SessionReconnectPolicy ReconnectPolicy { get; }
|
||||
|
||||
public DateTimeOffset? LastLivenessUtc => lastLivenessUtc;
|
||||
public DateTimeOffset? LastLivenessUtc => lastAcceptedLivenessUtc;
|
||||
|
||||
public DateTimeOffset? LastTransportActivityUtc => lastTransportActivityUtc;
|
||||
|
||||
public DateTimeOffset? LastHeartbeatSentUtc => lastHeartbeatSentUtc;
|
||||
|
||||
@@ -70,13 +73,18 @@ namespace Network.NetworkApplication
|
||||
public void NotifyTransportConnected()
|
||||
{
|
||||
var now = utcNowProvider();
|
||||
lastLivenessUtc = now;
|
||||
lastTransportActivityUtc = now;
|
||||
lastHeartbeatSentUtc = null;
|
||||
nextReconnectAtUtc = null;
|
||||
LastFailureReason = null;
|
||||
TransitionTo(ConnectionState.TransportConnected, SessionEventKind.TransportConnected, now);
|
||||
}
|
||||
|
||||
public void NotifyTransportActivity()
|
||||
{
|
||||
lastTransportActivityUtc = utcNowProvider();
|
||||
}
|
||||
|
||||
public void NotifyLoginStarted()
|
||||
{
|
||||
TransitionTo(ConnectionState.LoginPending, SessionEventKind.LoginStarted, utcNowProvider());
|
||||
@@ -85,7 +93,8 @@ namespace Network.NetworkApplication
|
||||
public void NotifyLoginSucceeded()
|
||||
{
|
||||
var now = utcNowProvider();
|
||||
lastLivenessUtc = now;
|
||||
lastTransportActivityUtc = now;
|
||||
lastAcceptedLivenessUtc = now;
|
||||
LastFailureReason = null;
|
||||
TransitionTo(ConnectionState.LoggedIn, SessionEventKind.LoginSucceeded, now);
|
||||
}
|
||||
@@ -105,7 +114,8 @@ namespace Network.NetworkApplication
|
||||
public void NotifyHeartbeatReceived()
|
||||
{
|
||||
var now = utcNowProvider();
|
||||
lastLivenessUtc = now;
|
||||
lastTransportActivityUtc = now;
|
||||
lastAcceptedLivenessUtc = now;
|
||||
if (lastHeartbeatSentUtc.HasValue)
|
||||
{
|
||||
LastRoundTripTime = now - lastHeartbeatSentUtc.Value;
|
||||
@@ -116,7 +126,9 @@ namespace Network.NetworkApplication
|
||||
|
||||
public void NotifyInboundActivity()
|
||||
{
|
||||
lastLivenessUtc = utcNowProvider();
|
||||
var now = utcNowProvider();
|
||||
lastTransportActivityUtc = now;
|
||||
lastAcceptedLivenessUtc = now;
|
||||
}
|
||||
|
||||
public void NotifyTransportDisconnected(string reason = null)
|
||||
@@ -152,17 +164,18 @@ namespace Network.NetworkApplication
|
||||
|
||||
private bool ShouldTimeout(DateTimeOffset now)
|
||||
{
|
||||
if (State != ConnectionState.TransportConnected && State != ConnectionState.LoginPending && State != ConnectionState.LoggedIn)
|
||||
switch (State)
|
||||
{
|
||||
return false;
|
||||
case ConnectionState.TransportConnected:
|
||||
case ConnectionState.LoginPending:
|
||||
return lastTransportActivityUtc.HasValue &&
|
||||
now - lastTransportActivityUtc.Value >= ReconnectPolicy.HeartbeatTimeout;
|
||||
case ConnectionState.LoggedIn:
|
||||
return lastAcceptedLivenessUtc.HasValue &&
|
||||
now - lastAcceptedLivenessUtc.Value >= ReconnectPolicy.HeartbeatTimeout;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lastLivenessUtc.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return now - lastLivenessUtc.Value >= ReconnectPolicy.HeartbeatTimeout;
|
||||
}
|
||||
|
||||
private void TransitionTo(
|
||||
|
||||
Reference in New Issue
Block a user