2024-08-17 14:27:18 +08:00
|
|
|
|
using JNGame.Sync.Entity;
|
|
|
|
|
using JNGame.Sync.Frame;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace JNGame.Sync.State
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 状态同步 [客户端]
|
|
|
|
|
/// 客户端负责视图层拿数据层数据渲染
|
|
|
|
|
/// 注:客户端无论如何不能有逻辑层
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class JNSStateClientService : JNSyncDefaultService
|
|
|
|
|
{
|
|
|
|
|
//是否开始
|
|
|
|
|
private bool _isStart = false;
|
|
|
|
|
public bool IsStart => _isStart;
|
|
|
|
|
public override bool IsStartGame => IsStart;
|
|
|
|
|
public override int DeltaTime => 1000 / 15;
|
|
|
|
|
|
|
|
|
|
//累计待处理时间
|
|
|
|
|
protected int dtTime;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
_isStart = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Execute()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
|
|
|
|
|
if (paused) return;
|
|
|
|
|
#endif
|
|
|
|
|
if (!IsStart) return;
|
|
|
|
|
base.Execute();
|
2024-09-12 18:06:22 +08:00
|
|
|
|
dtTime += TickTime;
|
2024-08-17 14:27:18 +08:00
|
|
|
|
if (DeltaTime <= dtTime)
|
|
|
|
|
{
|
|
|
|
|
dtTime -= DeltaTime;
|
|
|
|
|
//执行逻辑
|
|
|
|
|
OnRunSimulate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 客户端没有逻辑实体
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public sealed override JNContexts CreateContexts()
|
|
|
|
|
{
|
|
|
|
|
return base.CreateContexts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 运行逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual void OnRunSimulate()
|
|
|
|
|
{
|
|
|
|
|
Simulate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|