private void OnUpdateRemotePlayer(ref UpdateRemotePlayer p) { RemotePlayer player; if (remotePlayers.TryGetValue(p.Index, out player)) { player.UpdateFromServer(ref p); } }
public void UpdateFromServer(ref UpdateRemotePlayer p) { Vector3 pos = p.Pos; pos.X += p.Speed.X * p.SenderConnection.AverageRoundtripTime * 0.5f; pos.Y += p.Speed.Y * p.SenderConnection.AverageRoundtripTime * 0.5f; Transform.Pos = pos; speedX = p.Speed.X; speedY = p.Speed.Y; if (currentAnimationState != p.AnimState) { SetAnimation(p.AnimState); } renderer.AnimTime = p.AnimTime; isFacingLeft = p.IsFacingLeft; }