mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
66 lines
1.6 KiB
C#
66 lines
1.6 KiB
C#
|
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();
|
|||
|
dtTime += (int)(Time.deltaTime * 1000);
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|