/// <summary> /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> private void ScanTimerElapsed(object sender, ElapsedEventArgs e) { if (this._isScanning) { return; } this._isScanning = true; double refresh = 250; if (double.TryParse(Settings.Default.ChatLogWorkerRefresh.ToString(CultureInfo.InvariantCulture), out refresh)) { this._scanTimer.Interval = refresh; Func <bool> scanner = delegate { ChatLogResult readResult = Reader.GetChatLog(this._previousArrayIndex, this._previousOffset); this._previousArrayIndex = readResult.PreviousArrayIndex; this._previousOffset = readResult.PreviousOffset; foreach (ChatLogItem chatLogItem in readResult.ChatLogItems) { AppViewModel.Instance.ChatHistory.Add(chatLogItem); AppContextHelper.Instance.RaiseChatLogItemReceived(chatLogItem); } this._isScanning = false; return(true); }; scanner.BeginInvoke(delegate { }, scanner); } }
public bool UpdateChat() { ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; if (readResult.ChatLogItems.Count > 0) { foreach (var item in readResult.ChatLogItems) { ChatCode code = (ChatCode)int.Parse(item.Code, System.Globalization.NumberStyles.HexNumber); //ProcessChatMsg(readResult.ChatLogItems[i]); if ((int)code < 0x9F) // Skips battle log { if (code == ChatCode.GilReceive || code == ChatCode.Gather || code == ChatCode.FieldAttack || code == ChatCode.EmoteCustom) { continue; } ChatQueue.q.Add(item); } } return(true); } return(false); }
private async Task ChatReader() { int _previousArrayIndex = 0; int _previousOffset = 0; while (_KeepWorking && _KeepReading) { try { ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); var chatLogEntries = readResult.ChatLogItems; _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; if (readResult.ChatLogItems.Count > 0) { for (int i = 0; i < readResult.ChatLogItems.Count; i++) { ProcessChatMsg(readResult.ChatLogItems[i]); } } } catch (Exception e) { Logger.WriteLog(Convert.ToString(e)); } await Task.Delay(GlobalSettings.MemoryReaderDelay); } }
private void ScanTimerElapsed(object sender, ElapsedEventArgs e) { if (this._isScanning) { return; } // this._scanTimer.Interval = Settings.Default.ChatLogWorkerTiming; this._isScanning = true; ChatLogResult result = this._memoryHandler.Reader.GetChatLog(this._previousArrayIndex, this._previousOffset); this._previousArrayIndex = result.PreviousArrayIndex; this._previousOffset = result.PreviousOffset; while (!result.ChatLogItems.IsEmpty) { if (result.ChatLogItems.TryDequeue(out ChatLogItem chatLogItem)) { EventHost.Instance.RaiseNewChatLogItemEvent(this._memoryHandler, chatLogItem); } } this._isScanning = false; }
void ClearMessagesList(ChatLogResult chatLogResult, ChatLogResult previousPanelResults, ChatLogResult panelResult) { bool messgaesDeleted = false; bool previousCount = previousPanelResults.ChatLogItems.Count > 0 && chatLogResult.ChatLogItems.Count > 0; try { for (int i = 0; i < previousPanelResults.ChatLogItems.Count; i++) { var pvPanel = previousPanelResults.ChatLogItems[i]; var panel = chatLogResult.ChatLogItems.FirstOrDefault(x => Reader.CheckChatEquality(x, pvPanel)); if (panel != null) { if (panelResult.ChatLogItems.FirstOrDefault(x => Reader.CheckChatEquality(x, panel)) == null) { chatLogResult.ChatLogItems.Remove(panel); } int rmCount = previousPanelResults.ChatLogItems.RemoveAll(x => Reader.CheckChatEquality(x, panel)); messgaesDeleted = true; if (rmCount > 0) { i = 0; } } } if (previousCount) { if (messgaesDeleted == false) { DirectTextsMissedCount++; } else { DirectTextsMissedCount = 0; } } if (previousPanelResults.ChatLogItems.Count > 200) { int startPos = 0; int count = previousPanelResults.ChatLogItems.Count / 2; previousPanelResults.ChatLogItems.RemoveRange(startPos, count); } previousPanelResults.ChatLogItems.AddRange(panelResult.ChatLogItems); } catch (Exception e) { Logger.WriteLog(e); } }
void ClearMessagesList(ChatLogResult chatLogResult, ChatLogResult previousPanelResults, ChatLogResult panelResult) { bool messgaesDeleted = false; bool previousCount = previousPanelResults.ChatLogItems.Count > 0 && chatLogResult.ChatLogItems.Count > 0; for (int i = 0; i < previousPanelResults.ChatLogItems.Count; i++) { var pvPanel = previousPanelResults.ChatLogItems[i]; var panel = chatLogResult.ChatLogItems.FirstOrDefault(x => Helper.IsStringLettersEqual(x.Line, pvPanel.Line)); if (panel != null) { if (panelResult.ChatLogItems.FirstOrDefault(x => Helper.IsStringLettersEqual(x.Line, panel.Line)) == null) { chatLogResult.ChatLogItems.Remove(panel); } var rmCount = previousPanelResults.ChatLogItems.RemoveAll(x => Helper.IsStringLettersEqual(x.Line, panel.Line)); messgaesDeleted = true; if (i - rmCount > -2) { i = i - rmCount; } } } if (previousCount) { if (messgaesDeleted == false) { DirectTextsMissedCount++; } else { DirectTextsMissedCount = 0; } } if (previousPanelResults.ChatLogItems.Count > 200) { int startPos = 0; int count = previousPanelResults.ChatLogItems.Count / 2; previousPanelResults.ChatLogItems.RemoveRange(startPos, count); } previousPanelResults.ChatLogItems.AddRange(panelResult.ChatLogItems); }
private async void WatchChatLog(CancellationToken cancelToken) { while (true) { if (cancelToken.IsCancellationRequested) { break; } ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); var chatLogEntries = readResult.ChatLogItems; _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; // only trigger the following code if the most recent chatlogs contain chat from certain linkshells, or private messages if (chatLogEntries.Count > 0) { foreach (var chatEntry in chatLogEntries) { // change this dictionary to whichever one we store our desired watch codes with - this one has all of them if (settingsHelper._chatCodesWatchingDictionary.Contains(chatEntry.Code)) { LogChatEntry(chatEntry); // need to use this whenever we're referencing UI elements from other threads Application.Current.Dispatcher.Invoke(() => { if (chkbxToastNotification.IsChecked == true) { notificationHelper.ToastNotifyUser(chatEntry); } if (chkbxSoundNotification.IsChecked == true) { notificationHelper.SoundNotifyUser(); } }); } } } await Task.Delay(2000); } }
private async Task ChatReader() { int _previousArrayIndex = 0; int _previousOffset = 0; ChatLogResult previousPanelResults = new ChatLogResult(); while (_KeepWorking && _KeepReading) { try { ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; if (_UseDirectReadingInternal && _UseDirectReading) { var directDialog = Reader.GetDirectDialog(); readResult.ChatLogItems.AddRange(directDialog.ChatLogItems); ClearMessagesList(readResult, previousPanelResults, directDialog); } if (DirectTextsMissedCount > GlobalSettings.MaxСonsecutiveNotFromLogSentences) { _UseDirectReadingInternal = false; } var chatLogEntries = readResult.ChatLogItems; if (readResult.ChatLogItems.Count > 0) { for (int i = 0; i < readResult.ChatLogItems.Count; i++) { ProcessChatMsg(readResult.ChatLogItems[i]); } } } catch (Exception e) { Logger.WriteLog(Convert.ToString(e)); } await Task.Delay(GlobalSettings.MemoryReaderDelay); } }
public static ChatLogResult GetDirectDialog() { var result = new ChatLogResult(); var dialogPanel = GetDialogPanel(); var cutsceneText = GetCutsceneText(); //var cutsceneText = new ChatLogItem(); var dialogRepeat = CheckRepetition(DialogPanelsLog, dialogPanel); var cutsceneRepeat = CheckRepetition(CutScenesLog, cutsceneText); if (CheckChatEquality(dialogPanel, cutsceneText)) { if (dialogPanel.Bytes != null && dialogRepeat == false) { if (!CheckRepetition(DirectDialogLog, dialogPanel)) { result.ChatLogItems.Add(dialogPanel); } } } else { if (dialogPanel != null && dialogPanel.Bytes != null && dialogRepeat == false) { if (!CheckRepetition(DirectDialogLog, dialogPanel)) { result.ChatLogItems.Add(dialogPanel); } } if (cutsceneText != null && cutsceneText.Bytes != null && cutsceneRepeat == false) { if (!CheckRepetition(DirectDialogLog, cutsceneText)) { result.ChatLogItems.Add(cutsceneText); } } } return(result); }
// ChatLogReaderException public List <Sharlayan.Core.ChatLogItem> Query() { _chatlogException = false; Sharlayan.MemoryHandler.Instance.ExceptionEvent += ResetChatlogProcessorOnException; ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); Sharlayan.MemoryHandler.Instance.ExceptionEvent -= ResetChatlogProcessorOnException; if (_chatlogException) { Reset(); } else { _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; } return(readResult.ChatLogItems); }
private void ScanTimerElapsed(object sender, ElapsedEventArgs e) { if (this._isScanning) { return; } this._scanTimer.Interval = Settings.Default.ChatLogWorkerTiming; this._isScanning = true; ChatLogResult result = this._memoryHandler.Reader.GetChatLog(this._previousArrayIndex, this._previousOffset); this._previousArrayIndex = result.PreviousArrayIndex; this._previousOffset = result.PreviousOffset; while (!result.ChatLogItems.IsEmpty) { if (result.ChatLogItems.TryDequeue(out ChatLogItem chatLogItem)) { EventHost.Instance.RaiseNewChatLogItemEvent(this._memoryHandler, chatLogItem); if (AppViewModel.Instance.ChatHistory.TryGetValue(chatLogItem.PlayerCharacterName, out List <ChatLogItem> chatLogItems)) { chatLogItems.Add(chatLogItem); } else { AppViewModel.Instance.ChatHistory.TryAdd( chatLogItem.PlayerCharacterName, new List <ChatLogItem> { chatLogItem, }); } } } this._isScanning = false; }
public static async Task <ChatLogResult> GetChatLog(int previousArrayIndex = 0, int previousOffset = 0) { var result = new ChatLogResult(); if (!CanGetChatLog() || !MemoryHandler.Instance.IsAttached) { return(result); } ChatLogReader.PreviousArrayIndex = previousArrayIndex; ChatLogReader.PreviousOffset = previousOffset; var chatPointerMap = (IntPtr)Scanner.Instance.Locations[Signatures.ChatLogKey]; if (chatPointerMap.ToInt64() <= 20) { return(result); } List <List <byte> > buffered = new List <List <byte> >(); try { ChatLogReader.Indexes.Clear(); ChatLogReader.ChatLogPointers = new ChatLogPointers { LineCount = (uint)MemoryHandler.Instance.GetPlatformUInt(chatPointerMap), OffsetArrayStart = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayStart), OffsetArrayPos = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayPos), OffsetArrayEnd = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.OffsetArrayEnd), LogStart = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogStart), LogNext = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogNext), LogEnd = MemoryHandler.Instance.GetPlatformUInt(chatPointerMap, MemoryHandler.Instance.Structures.ChatLogPointers.LogEnd) }; ChatLogReader.EnsureArrayIndexes(); var currentArrayIndex = (ChatLogReader.ChatLogPointers.OffsetArrayPos - ChatLogReader.ChatLogPointers.OffsetArrayStart) / 4; if (ChatLogReader.ChatLogFirstRun) { ChatLogReader.ChatLogFirstRun = false; ChatLogReader.PreviousOffset = ChatLogReader.Indexes[(int)currentArrayIndex - 1]; ChatLogReader.PreviousArrayIndex = (int)currentArrayIndex - 1; } else { if (currentArrayIndex < ChatLogReader.PreviousArrayIndex) { buffered.AddRange(ChatLogReader.ResolveEntries(ChatLogReader.PreviousArrayIndex, 1000)); ChatLogReader.PreviousOffset = 0; ChatLogReader.PreviousArrayIndex = 0; } if (ChatLogReader.PreviousArrayIndex < currentArrayIndex) { buffered.AddRange(ChatLogReader.ResolveEntries(ChatLogReader.PreviousArrayIndex, (int)currentArrayIndex)); } ChatLogReader.PreviousArrayIndex = (int)currentArrayIndex; } } catch (Exception ex) { MemoryHandler.Instance.RaiseException(Logger, ex, true); } foreach (List <byte> bytes in buffered.Where(b => b.Count > 0)) { try { ChatLogItem chatLogEntry = ChatEntry.Process(bytes.ToArray()); if (Regex.IsMatch(chatLogEntry.Combined, @"[\w\d]{4}::?.+")) { result.ChatLogItems.Add(chatLogEntry); } } catch (Exception ex) { MemoryHandler.Instance.RaiseException(Logger, ex, true); } } result.PreviousArrayIndex = ChatLogReader.PreviousArrayIndex; result.PreviousOffset = ChatLogReader.PreviousOffset; return(result); }
public ChatLogResult GetChatLog(int previousArrayIndex = 0, int previousOffset = 0) { var result = new ChatLogResult(); if (!CanGetChatLog() || !MemoryHandler.IsAttached) { return(result); } _chatLogReader.PreviousArrayIndex = previousArrayIndex; _chatLogReader.PreviousOffset = previousOffset; var chatPointerMap = (IntPtr)Scanner.Locations[Signatures.ChatLogKey]; if (chatPointerMap.ToInt64() <= 20) { return(result); } var buffered = new List <List <byte> >(); try { _chatLogReader.ChatLogPointers = new ChatLogPointers { LineCount = (uint)MemoryHandler.GetPlatformUInt(chatPointerMap), OffsetArrayStart = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.OffsetArrayStart), OffsetArrayPos = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.OffsetArrayPos), OffsetArrayEnd = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.OffsetArrayEnd), LogStart = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.LogStart), LogNext = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.LogNext), LogEnd = MemoryHandler.GetPlatformUInt(chatPointerMap, MemoryHandler.Structures.ChatLogPointers.LogEnd) }; var currentArrayIndex = (_chatLogReader.ChatLogPointers.OffsetArrayPos - _chatLogReader.ChatLogPointers.OffsetArrayStart) / 4; if (_chatLogFirstRun) { _chatLogFirstRun = false; _chatLogReader.EnsureArrayIndexes(); if (currentArrayIndex - 1 > 0 && _chatLogReader.Indexes.Count >= currentArrayIndex - 1) { _chatLogReader.PreviousOffset = _chatLogReader.Indexes[(int)currentArrayIndex - 1]; } else { _chatLogReader.PreviousOffset = 0; _chatLogReader.PreviousArrayIndex = 0; result.PreviousArrayIndex = _chatLogReader.PreviousArrayIndex; result.PreviousOffset = _chatLogReader.PreviousOffset; return(result); // The player is logged out. } _chatLogReader.PreviousArrayIndex = (int)currentArrayIndex - 1; } else { if (currentArrayIndex < _chatLogReader.PreviousArrayIndex) { _chatLogReader.PreviousOffset = 0; _chatLogReader.PreviousArrayIndex = 0; result.PreviousArrayIndex = _chatLogReader.PreviousArrayIndex; result.PreviousOffset = _chatLogReader.PreviousOffset; return(result); // The player logged out. } if (_chatLogReader.PreviousArrayIndex < currentArrayIndex) { buffered.AddRange(_chatLogReader.ResolveEntries(_chatLogReader.PreviousArrayIndex, (int)currentArrayIndex)); } _chatLogReader.PreviousArrayIndex = (int)currentArrayIndex; } } catch (Exception ex) { MemoryHandler?.RaiseException(ex); } foreach (var bytes in buffered.Where(b => b.Count > 0)) { try { var chatLogEntry = ChatEntry.Process(MemoryHandler, bytes.ToArray()); if (Regex.IsMatch(chatLogEntry.Combined, @"[\w\d]{4}::?.+")) { result.ChatLogItems.Add(chatLogEntry); } } catch (Exception ex) { MemoryHandler?.RaiseException(ex); } } result.PreviousArrayIndex = _chatLogReader.PreviousArrayIndex; result.PreviousOffset = _chatLogReader.PreviousOffset; return(result); }
public ChatLogResult GetChatLog(int previousArrayIndex = 0, int previousOffset = 0) { ChatLogResult result = new ChatLogResult(); if (!this.CanGetChatLog() || !this._memoryHandler.IsAttached) { return(result); } this._chatLogReader.PreviousArrayIndex = previousArrayIndex; this._chatLogReader.PreviousOffset = previousOffset; IntPtr chatPointerAddress = this._memoryHandler.Scanner.Locations[Signatures.CHATLOG_KEY]; if (chatPointerAddress.ToInt64() <= 20) { return(result); } List <byte[]> bufferList = new List <byte[]>(); try { this._chatLogReader.ChatLogPointers = new ChatLogPointers { LineCount = this._memoryHandler.GetUInt32(chatPointerAddress), OffsetArrayStart = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.OffsetArrayStart), OffsetArrayPos = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.OffsetArrayPos), OffsetArrayEnd = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.OffsetArrayEnd), LogStart = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.LogStart), LogNext = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.LogNext), LogEnd = this._memoryHandler.GetInt64(chatPointerAddress, this._memoryHandler.Structures.ChatLogPointers.LogEnd), }; long currentArrayIndex = (this._chatLogReader.ChatLogPointers.OffsetArrayPos - this._chatLogReader.ChatLogPointers.OffsetArrayStart) / 4; if (this._chatLogReader.ChatLogFirstRun) { this._chatLogReader.EnsureArrayIndexes(); this._chatLogReader.ChatLogFirstRun = false; this._chatLogReader.PreviousOffset = this._chatLogReader.Indexes[(int)currentArrayIndex - 1]; this._chatLogReader.PreviousArrayIndex = (int)currentArrayIndex - 1; } else { if (currentArrayIndex < this._chatLogReader.PreviousArrayIndex) { IEnumerable <byte[]> bufferEntries = this._chatLogReader.ResolveEntries(this._chatLogReader.PreviousArrayIndex, 1000); bufferList.AddRange(bufferEntries); this._chatLogReader.PreviousOffset = 0; this._chatLogReader.PreviousArrayIndex = 0; } if (this._chatLogReader.PreviousArrayIndex < currentArrayIndex) { IEnumerable <byte[]> bufferEntries = this._chatLogReader.ResolveEntries(this._chatLogReader.PreviousArrayIndex, (int)currentArrayIndex); bufferList.AddRange(bufferEntries); } this._chatLogReader.PreviousArrayIndex = (int)currentArrayIndex; } } catch (Exception ex) { this._memoryHandler.RaiseException(Logger, ex); } foreach (byte[] bytes in bufferList) { if (!bytes.Any()) { continue; } try { ChatLogItem chatLogEntry = ChatEntry.Process(bytes); // assign logged user for this instance to chatLogEntry chatLogEntry.PlayerCharacterName = this._pcWorkerDelegate.CurrentUser?.Name ?? UNRESOLVED; if (Regex.IsMatch(chatLogEntry.Combined, @"[\w\d]{4}::?.+")) { result.ChatLogItems.Enqueue(chatLogEntry); } } catch (Exception ex) { this._memoryHandler.RaiseException(Logger, ex); } } result.PreviousArrayIndex = this._chatLogReader.PreviousArrayIndex; result.PreviousOffset = this._chatLogReader.PreviousOffset; return(result); }
public bool Refresh() { if (ffxivProcess != null) { ffxivProcess.Refresh(); if (ffxivProcess.HasExited) { OnProcessLost?.Invoke(this, EventArgs.Empty); ffxivProcess = null; hasLost = true; Reset(); Console.WriteLine("Exited game"); } if (IsScanning() && !hasScanned) { Console.WriteLine("Scanning..."); while (IsScanning()) { Thread.Sleep(100); } Console.WriteLine("Finished scanning"); OnProcessReady?.Invoke(this, ffxivProcess); hasScanned = true; } } if ((ffxivProcess == null) && hasLost) { OnProcessSeek?.Invoke(this, EventArgs.Empty); hasLost = false; return(false); } if (Reader.CanGetCharacterId()) { string id = Reader.GetCharacterId(); if (!string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(CharacterID) || (!string.IsNullOrEmpty(CharacterID) && !CharacterID.Equals(id))) { CharacterID = id; } } } if (Reader.CanGetPlayerInfo()) { CurrentPlayerResult res = Reader.GetCurrentPlayer(); if (res.CurrentPlayer.Job != currentPlayer.CurrentPlayer.Job) { if (currentPlayer.CurrentPlayer.Job == Sharlayan.Core.Enums.Actor.Job.Unknown) { // Logged in OnCurrentPlayerLogin?.Invoke(this, res); isLoggedIn = true; } else if (res.CurrentPlayer.Job == Sharlayan.Core.Enums.Actor.Job.Unknown) { // Logged out OnCurrentPlayerLogout?.Invoke(this, currentPlayer); isLoggedIn = false; Reset(); } else { OnCurrentPlayerJobChange?.Invoke(this, currentPlayer); } } currentPlayer = res; } if (!isLoggedIn) { return(false); } if (Reader.CanGetPartyMembers()) { PartyResult party2 = Reader.GetPartyMembers(); if (party2.NewPartyMembers.Count > 0 || party2.RemovedPartyMembers.Count > 0) { // Something changed party = party2; OnPartyChanged?.Invoke(this, party2); } int pcount = party.PartyMembers.Count; int pcount2 = party2.PartyMembers.Count; if (!(party is PartyResult) || (party is PartyResult && (pcount != pcount2))) { party = party2; OnPartyChanged?.Invoke(this, party2); } } if (Reader.CanGetPerformance()) { List <uint> changedIds = new List <uint>(); PerformanceResult perf = Reader.GetPerformance(); if (!perf.Performances.IsEmpty && !performance.Performances.IsEmpty) { foreach (KeyValuePair <uint, PerformanceItem> pp in perf.Performances) { if (pp.Value.Status != performance.Performances[pp.Key].Status) { changedIds.Add(pp.Key); } } } if (changedIds.Count > 0) { List <uint> actorIds = new List <uint>(); if (Reader.CanGetActors()) { foreach (ActorItem actor in Reader.GetActors().CurrentPCs.Values) { if (changedIds.Contains(actor.PerformanceID / 2)) { actorIds.Add(actor.ID); } } } if (actorIds.Count > 0) { OnPerformanceChanged?.Invoke(this, actorIds); } } //Update performance = perf; bool r = perf.Performances[0].IsReady(); if (r != performanceReady) { performanceReady = r; OnPerformanceReadyChanged?.Invoke(this, performanceReady); } } logItems.Clear(); if (Reader.CanGetChatLog()) { ChatLogResult readResult = Reader.GetChatLog(_previousArrayIndex, _previousOffset); _previousArrayIndex = readResult.PreviousArrayIndex; _previousOffset = readResult.PreviousOffset; foreach (ChatLogItem item in readResult.ChatLogItems) { logItems.Push(item); completeLog.Add(item); OnChatReceived?.Invoke(this, item); } } if (Reader.CanGetActors()) { int jobsum0 = 0; if (actors != null) { jobsum0 = actors.CurrentPCs.Sum(e => (int)e.Value.Job); } ActorResult actorRes = Reader.GetActors(); if (actors != null) { if (actorRes.CurrentPCs.Count != actors.CurrentPCs.Count) { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } int jobsum1 = actorRes.CurrentPCs.Sum(e => (int)e.Value.Job); if (jobsum0 != jobsum1) { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } } else { actors = actorRes; OnPcChanged?.Invoke(this, actorRes.CurrentPCs.ToDictionary(k => k.Key, k => k.Value as ActorItemBase)); } } return(true); }