Files
SVSimServer/SVSim.BattleEngine/Engine/DisconnectToLoseChecker.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

115 lines
2.5 KiB
C#

using System;
using Cute;
using UnityEngine;
using Wizard;
public class DisconnectToLoseChecker : NetworkBattleIntervalCheckerBase
{
private const float DISCONNECT_LOSE_INTERVAL = 125f;
private const float DISCONNECT_CHECK_INTERVAL = 65f;
private const float DISCONNECT_INTERVAL = 10f;
private const float SOCKET_REPLACE_INTERVAL = 50f;
private bool _isAlreadyTriedSocketReplace;
private bool _isSocketOpenDisconnectLog;
public event Action OnDisconnectLose;
public event Action OnBeforeDisconnectLose;
public event Action OnDisconnectCheck;
public bool IsDisconnect()
{
if (!base.isStop && ((float)GetDisconnectTime() >= 10f || Application.internetReachability == NetworkReachability.NotReachable))
{
LocalLog.SetDisconnectLog("IsDisconnect time" + GetDisconnectTime() + "internetReachability" + Application.internetReachability);
return true;
}
return false;
}
public bool IsSelfDisconnectLose()
{
if (IsSelfDisConnectOnTimeout() || ToolboxGame.RealTimeNetworkAgent.IsReceiveSelfDisconnect)
{
return true;
}
return false;
}
public bool IsSelfDisConnectOnTimeout()
{
if ((float)GetDisconnectTime() >= 125f)
{
return true;
}
return false;
}
private bool IsSelfDisconnectLoseCheck()
{
if ((float)GetDisconnectTime() >= 65f)
{
return true;
}
return false;
}
public override void StopChecker()
{
base.StopChecker();
}
public override void StartChecker(string log = "")
{
if (!IsSelfDisconnectLose())
{
if (IsSelfDisconnectLoseCheck())
{
this.OnDisconnectCheck.Call();
}
base.StartChecker();
}
if (_isAlreadyTriedSocketReplace)
{
if (this.OnBeforeDisconnectLose != null)
{
LocalLog.AccumulateLastTraceLog("SocketReplace Success");
}
_isAlreadyTriedSocketReplace = false;
}
}
protected override void IntervalCheck()
{
base.IntervalCheck();
if (!_isAlreadyTriedSocketReplace && (float)GetDisconnectTime() >= 50f)
{
if (!_isSocketOpenDisconnectLog && ToolboxGame.RealTimeNetworkAgent != null && ToolboxGame.RealTimeNetworkAgent.IsOpen())
{
_isSocketOpenDisconnectLog = true;
}
_isAlreadyTriedSocketReplace = true;
if (this.OnBeforeDisconnectLose != null)
{
this.OnBeforeDisconnectLose.Call();
}
}
if (IsSelfDisconnectLose())
{
this.OnDisconnectLose.Call();
StopChecker();
}
}
public int GetDisconnectTime()
{
return NetworkUtility.GetTimeSpanSecond(base.startTick);
}
}