private void OnLogFileUpdateEvent(IEnumerable <string> newLines) { Match deadRegex = null; foreach (string line in newLines) { Interaction interaction = null; if (Regex.IsMatch(line, EnumsAndConstants.MeleeRegex)) { interaction = new MeleeInteraction(line); } else if (Regex.IsMatch(line, EnumsAndConstants.SpellRegex)) { interaction = new SpellInteraction(line); } else if (Regex.IsMatch(line, EnumsAndConstants.PetAttackRegex) && !string.IsNullOrEmpty(EnumsAndConstants.PetAttackRegex)) { interaction = new PetMeleeInteraction(line); } if (interaction != null) { if (_currentOpponent == null) { StartNewFight(interaction); } else if (interaction.OpponentName == _currentOpponent) { UpdateCurrentFight(interaction); } } else { deadRegex = Regex.Match(line, EnumsAndConstants.MyKillshotRegex); if (!deadRegex.Success) { deadRegex = Regex.Match(line, EnumsAndConstants.OtherKillshotRegex); } if (!deadRegex.Success) { deadRegex = Regex.Match(line, EnumsAndConstants.DiedRegex); } if (deadRegex.Success && deadRegex.Groups[1].Value == _currentOpponent) { Thread.Sleep(2000); if (OnBattleUpdateEvent != null) { OnBattleUpdateEvent.Invoke(new List <CombatantFightInfo>() { _individualFightInfo }); } ClearBattle(); } } } }
//thread wakes up and notifies all listeners of updates to _fightInfo private void BattleUpdater() { while (true) { if (_fightOngoing && OnBattleUpdateEvent != null) { if (_raidFightInfo != null) { OnBattleUpdateEvent.Invoke(_raidFightInfo); //notify subscribers } else { OnBattleUpdateEvent.Invoke(new List <CombatantFightInfo>() { _individualFightInfo }); } } Thread.Sleep(3000); } }