private void Predict(ServerFrame frame, bool isNeedGenSnap = true) { ProcessInputQueue(frame); _world.Predict(isNeedGenSnap); var tick = _world.Tick; cmdBuffer.SetClientTick(tick); SetHashCode(); //清理无用 snapshot if (isNeedGenSnap && tick % FrameBuffer.SnapshotFrameInterval == 0) { _world.CleanUselessSnapshot(System.Math.Min(cmdBuffer.nextTickToCheck - 1, _world.Tick)); } }
public void Update(float elapsedMilliseconds) { if (!Running) { return; } _accumulatedTime += elapsedMilliseconds; while (_accumulatedTime >= _tickDt) { lock (_localCommandBuffer) { _commandQueue.Enqueue(new Input(_world.Tick, LocalActorId, _localCommandBuffer.ToArray())); _localCommandBuffer.Clear(); ProcessInputQueue(); _world.Predict(); } _accumulatedTime -= _tickDt; } }