/// <summary> /// Updates the screen if it is currently the active screen. /// </summary> /// <param name="gameTime">The current game time.</param> public override void Update(TickCount gameTime) { ThreadAsserts.IsMainThread(); // Get the current time _currentTime = gameTime; if (UserChar == null) { _userLight.IsEnabled = false; return; } ScreenManager.AudioManager.ListenerPosition = UserChar.Center; // HACK: What a stupid way to make sure the correct inventory and equipped is used... _inventoryForm.Inventory = UserInfo.Inventory; _equippedForm.UserEquipped = UserInfo.Equipped; // Check to hide the shopping form from the user going out of range of the shop owner var shopInfo = ShopForm.ShopInfo; if (shopInfo != null && shopInfo.ShopOwner != null && !GameData.IsValidDistanceToShop(UserChar, shopInfo.ShopOwner)) { ShopForm.HideShop(); } // Update some other goodies World.Update(); _damageTextPool.Update(_currentTime); _guiStatePersister.Update(_currentTime); _emoticonDisplayManager.Update(_currentTime); // Update targeting _characterTargeter.Update(GUIManager); _gameControls.TargetIndex = _characterTargeter.TargetEntityIndex; // Update controls _gameControls.Update(GUIManager, _currentTime); var sock = _socket.RemoteSocket; if (_latencyLabel != null && sock != null && sock.IsConnected) { _latencyLabel.Text = string.Format(_latencyString, sock.AverageLatency < 1 ? "<1" : Math.Round(sock.AverageLatency).ToString()); } _userLight.IsEnabled = true; _userLight.SetCenter(UserChar.Center); // Periodically synchronize the game time if (Socket != null && _nextSyncGameTime < gameTime) { _nextSyncGameTime = gameTime + ClientSettings.Default.Network_SyncGameTimeFrequency; using (var pw = ClientPacket.SynchronizeGameTime()) { Socket.Send(pw, ClientMessageType.System); } } base.Update(gameTime); }