using JNGame.Sync.Entity; using JNGame.Sync.Frame; using UnityEngine; namespace JNGame.Sync.State { /// /// 状态同步 [客户端] /// 客户端负责视图层拿数据层数据渲染 /// 注:客户端无论如何不能有逻辑层 /// 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(); dtTime += (int)(Time.deltaTime * 1000); if (DeltaTime <= dtTime) { dtTime -= DeltaTime; //执行逻辑 OnRunSimulate(); } } /// /// 客户端没有逻辑实体 /// /// public sealed override JNContexts CreateContexts() { return base.CreateContexts(); } /// /// 运行逻辑 /// protected virtual void OnRunSimulate() { Simulate(); } } }