public override void Update(float delta) { LastPosition = _position; LastRotation = _rotation; _nextCommand.Id = (ushort)((_nextCommand.Id + 1) % NetworkGeneral.MaxGameSequence); _nextCommand.ServerTick = _lastServerState.Tick; ApplyInput(_nextCommand, delta); if (_predictionPlayerStates.IsFull) { _nextCommand.Id = (ushort)(_lastServerState.LastProcessedCommand + 1); _predictionPlayerStates.FastClear(); } _predictionPlayerStates.Add(_nextCommand); _updateCount++; if (_updateCount == 3) { _updateCount = 0; foreach (var t in _predictionPlayerStates) { _clientLogic.SendPacketSerializable(PacketType.Movement, t, DeliveryMethod.Unreliable); } } base.Update(delta); }
public override void Update(float delta) { LastPosition = _position; LastRotation = _rotation; _nextCommand.Id = (ushort)((_nextCommand.Id + 1) % NetworkGeneral.MaxGameSequence); _nextCommand.ServerTick = _lastServerTick; ApplyInput(_nextCommand, delta); if (_predictionPlayerStates.IsFull) { _nextCommand.Id = _predictionPlayerStates.First.Id; _predictionPlayerStates.FastClear(); } _predictionPlayerStates.Add(_nextCommand); _clientLogic.SendPacketSerializable(PacketType.Movement, _nextCommand, DeliveryMethod.ReliableOrdered); base.Update(delta); }