Files
SVSimServer/SVSim.BattleEngine/Engine/NetworkBattleIntervalCheckerBase.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

100 lines
1.7 KiB
C#

using System.Collections;
using Cute;
using UnityEngine;
public class NetworkBattleIntervalCheckerBase
{
protected IEnumerator coroutine;
protected bool isEnd;
private NetworkBattleManagerBase _networkBattleManagerBase;
protected long startTick { get; private set; }
protected bool isStop { get; private set; }
public NetworkBattleIntervalCheckerBase()
{
_networkBattleManagerBase = BattleManagerBase.GetIns() as NetworkBattleManagerBase;
}
public virtual void StartChecker(string log = "")
{
InitTimer();
if (!isEnd)
{
isStop = false;
if (coroutine == null)
{
coroutine = CheckInterval();
BattleCoroutine.GetInstance().StartCoroutine(coroutine);
}
}
}
public void StartCheckerIfNotStarted()
{
if (!IsStarted())
{
StartChecker();
}
}
public virtual void FinishChecker()
{
StopChecker();
}
public virtual void StopChecker()
{
if (coroutine != null)
{
BattleCoroutine.GetInstance().StopCoroutine(coroutine);
coroutine = null;
}
isStop = true;
}
public bool IsStarted()
{
return coroutine != null;
}
public float GetTimeSpanSecondFromStarted()
{
if (IsStarted())
{
return NetworkUtility.GetTimeSpanSecond(startTick);
}
return -1f;
}
protected void InitTimer()
{
startTick = TimeUtil.GetAbsoluteTime().Ticks;
}
private IEnumerator CheckInterval()
{
WaitForSeconds secondWait = new WaitForSeconds(1f);
while (!isEnd)
{
if (!_networkBattleManagerBase.IsStopIntervalCheck)
{
IntervalCheck();
}
yield return secondWait;
}
}
protected virtual void IntervalCheck()
{
}
public void EndTimer()
{
isEnd = true;
}
}