diff --git a/Core/Models/Demo.cs b/Core/Models/Demo.cs index f5eadff7c..30f47408a 100644 --- a/Core/Models/Demo.cs +++ b/Core/Models/Demo.cs @@ -4,11 +4,9 @@ using System.Collections.ObjectModel; using System.Linq; using System; -using System.Collections.Specialized; using System.Globalization; using Core.Models.Events; using DemoInfo; -using GalaSoft.MvvmLight.Threading; namespace Core.Models { @@ -314,72 +312,72 @@ public class Demo : ObservableObject /// /// List of rounds during the match /// - private ObservableCollection _rounds; + private Collection _rounds; /// /// List of players who played during the match /// - private ObservableCollection _players; + private Collection _players; /// /// Infos on bomb planted during the match /// - private ObservableCollection _bombPlanted; + private Collection _bombPlanted; /// /// Infos on bomb defused during the match /// - private ObservableCollection _bombDefused; + private Collection _bombDefused; /// /// Infos on bomb exploded during the match /// - private ObservableCollection _bombExploded; + private Collection _bombExploded; /// /// Infos about players hurted event /// - private ObservableCollection _playersHurted; + private Collection _playersHurted; /// /// All kills during the match /// - private ObservableCollection _kills; + private Collection _kills; /// /// All shots fired during the match /// - private ObservableCollection _weaponFired; + private Collection _weaponFired; /// /// Contains data about flashbangs which had blinded players /// - private ObservableCollection _playerBlinded; + private Collection _playerBlinded; /// /// Demo's overtimes /// - private ObservableCollection _overtimes; + private Collection _overtimes; /// /// Contains all PositionPoint for overview generation /// - private ObservableCollection _positionPoints; + private Collection _positionPoints; /// /// Decoy started events data /// - private ObservableCollection _decoysStarted; + private Collection _decoysStarted; /// /// Molotov fire started events data /// - private ObservableCollection _molotovsFireStarted; + private Collection _molotovsFireStarted; /// /// Incendiary fire started events data /// - private ObservableCollection _incendiariesFireStarted; + private Collection _incendiariesFireStarted; /// /// Player with the best HS ratio @@ -401,6 +399,8 @@ public class Demo : ObservableObject /// private Weapon _mostKillingWeapon; + private Weapon _mostDamagingWeapon; + /// /// Team that started as Counter-Terrorists /// @@ -503,11 +503,7 @@ public float ServerTickrate public float Duration { get { return _duration; } - set - { - Set(() => Duration, ref _duration, value); - RaisePropertyChanged(() => DurationTime); - } + set { Set(() => Duration, ref _duration, value); } } [JsonProperty("ticks")] @@ -633,11 +629,7 @@ public Team TeamT public Team Surrender { get { return _surrender; } - set - { - Set(() => Surrender, ref _surrender, value); - RaisePropertyChanged(() => Surrender); - } + set { Set(() => Surrender, ref _surrender, value); } } [JsonProperty("team_winner", IsReference = true)] @@ -648,14 +640,14 @@ public Team Winner } [JsonProperty("rounds", IsReference = false)] - public ObservableCollection Rounds + public Collection Rounds { get { return _rounds; } set { Set(() => Rounds, ref _rounds, value); } } [JsonProperty("players", IsReference = false)] - public ObservableCollection Players + public Collection Players { get { return _players; } set { Set(() => Players, ref _players, value); } @@ -668,8 +660,15 @@ public Weapon MostKillingWeapon set { Set(() => MostKillingWeapon, ref _mostKillingWeapon, value); } } + [JsonProperty("most_damaging_weapon")] + public Weapon MostDamagingWeapon + { + get { return _mostDamagingWeapon; } + set { Set(() => MostDamagingWeapon, ref _mostDamagingWeapon, value); } + } + [JsonProperty("overtimes", IsReference = false)] - public ObservableCollection Overtimes + public Collection Overtimes { get { return _overtimes; } set { Set(() => Overtimes, ref _overtimes, value); } @@ -697,49 +696,49 @@ public Player MostEntryKillPlayer } [JsonProperty("bomb_planted", IsReference = false)] - public ObservableCollection BombPlanted + public Collection BombPlanted { get { return _bombPlanted; } set { Set(() => BombPlanted, ref _bombPlanted, value); } } [JsonProperty("bomb_defused", IsReference = false)] - public ObservableCollection BombDefused + public Collection BombDefused { get { return _bombDefused; } set { Set(() => BombDefused, ref _bombDefused, value); } } [JsonProperty("bomb_exploded", IsReference = false)] - public ObservableCollection BombExploded + public Collection BombExploded { get { return _bombExploded; } set { Set(() => BombExploded, ref _bombExploded, value); } } [JsonProperty("kills", IsReference = false)] - public ObservableCollection Kills + public Collection Kills { get { return _kills; } set { Set(() => Kills, ref _kills, value); } } [JsonProperty("weapon_fired", IsReference = false)] - public ObservableCollection WeaponFired + public Collection WeaponFired { get { return _weaponFired; } set { Set(() => WeaponFired, ref _weaponFired, value); } } [JsonProperty("player_blinded_events", IsReference = false)] - public ObservableCollection PlayerBlinded + public Collection PlayerBlinded { get { return _playerBlinded; } set { Set(() => PlayerBlinded, ref _playerBlinded, value); } } [JsonProperty("player_hurted", IsReference = false)] - public ObservableCollection PlayersHurted + public Collection PlayersHurted { get { return _playersHurted; } set { Set(() => PlayersHurted, ref _playersHurted, value); } @@ -852,28 +851,28 @@ public string WinStatus } [JsonIgnore] - public ObservableCollection PositionPoints + public Collection PositionPoints { get { return _positionPoints; } set { Set(() => PositionPoints, ref _positionPoints, value); } } [JsonProperty("decoys")] - public ObservableCollection DecoyStarted + public Collection DecoyStarted { get { return _decoysStarted; } set { Set(() => DecoyStarted, ref _decoysStarted, value); } } [JsonProperty("incendiaries")] - public ObservableCollection IncendiariesFireStarted + public Collection IncendiariesFireStarted { get { return _incendiariesFireStarted; } set { Set(() => IncendiariesFireStarted, ref _incendiariesFireStarted, value); } } [JsonProperty("molotovs")] - public ObservableCollection MolotovsFireStarted + public Collection MolotovsFireStarted { get { return _molotovsFireStarted; } set { Set(() => MolotovsFireStarted, ref _molotovsFireStarted, value); } @@ -893,29 +892,6 @@ public int DamageArmorCount set { Set(() => DamageArmorCount, ref _damageArmorCount, value); } } - [JsonIgnore] - public Weapon MostDamageWeapon - { - get - { - Dictionary weapons = new Dictionary(); - - foreach (PlayerHurtedEvent playerHurtedEvent in Rounds.SelectMany(round => round.PlayersHurted)) - { - if (!weapons.ContainsKey(playerHurtedEvent.Weapon)) - { - weapons[playerHurtedEvent.Weapon] = playerHurtedEvent.HealthDamage + playerHurtedEvent.ArmorDamage; - } - else - { - weapons[playerHurtedEvent.Weapon] += playerHurtedEvent.HealthDamage + playerHurtedEvent.ArmorDamage; - } - } - - return weapons.OrderByDescending(x => x.Value).FirstOrDefault().Key; - } - } - [JsonProperty("average_health_damage")] public double AverageHealthDamage { @@ -1067,20 +1043,20 @@ public List ChatMessageList public Demo() { - Kills = new ObservableCollection(); - Players = new ObservableCollection(); - Rounds = new ObservableCollection(); - MolotovsFireStarted = new ObservableCollection(); - IncendiariesFireStarted = new ObservableCollection(); - DecoyStarted = new ObservableCollection(); - WeaponFired = new ObservableCollection(); - PlayersHurted = new ObservableCollection(); - PositionPoints = new ObservableCollection(); - BombExploded = new ObservableCollection(); - BombPlanted = new ObservableCollection(); - BombDefused = new ObservableCollection(); - PlayerBlinded = new ObservableCollection(); - Overtimes = new ObservableCollection(); + Kills = new Collection(); + Players = new Collection(); + Rounds = new Collection(); + MolotovsFireStarted = new Collection(); + IncendiariesFireStarted = new Collection(); + DecoyStarted = new Collection(); + WeaponFired = new Collection(); + PlayersHurted = new Collection(); + PositionPoints = new Collection(); + BombExploded = new Collection(); + BombPlanted = new Collection(); + BombDefused = new Collection(); + PlayerBlinded = new Collection(); + Overtimes = new Collection(); ChatMessageList = new List(); _teamCt = new Team @@ -1093,13 +1069,6 @@ public Demo() Name = "Team 2", CurrentSide = Side.Terrorist, }; - Kills.CollectionChanged += OnKillsCollectionChanged; - BombExploded.CollectionChanged += OnBombExplodedCollectionChanged; - BombDefused.CollectionChanged += OnBombDefusedCollectionChanged; - BombPlanted.CollectionChanged += OnBombPlantedCollectionChanged; - Rounds.CollectionChanged += OnRoundsCollectionChanged; - PlayersHurted.CollectionChanged += OnPlayersHurtedCollectionChanged; - WeaponFired.CollectionChanged += OnWeaponFireCollectionChanged; } public override bool Equals(object obj) @@ -1167,6 +1136,7 @@ public Demo Copy() MostBombPlantedPlayer = MostBombPlantedPlayer, MostEntryKillPlayer = MostEntryKillPlayer, MostHeadshotPlayer = MostHeadshotPlayer, + MostDamagingWeapon = MostDamagingWeapon, MvpCount = MvpCount, Path = Path, ServerTickrate = ServerTickrate, @@ -1182,21 +1152,21 @@ public Demo Copy() WeaponFiredCount = WeaponFiredCount, Winner = Winner, WinStatus = WinStatus, - Players = new ObservableCollection(), - WeaponFired = new ObservableCollection(), - DecoyStarted = new ObservableCollection(), - BombDefused = new ObservableCollection(), - BombExploded = new ObservableCollection(), - BombPlanted = new ObservableCollection(), - MolotovsFireStarted = new ObservableCollection(), - IncendiariesFireStarted = new ObservableCollection(), + Players = new Collection(), + WeaponFired = new Collection(), + DecoyStarted = new Collection(), + BombDefused = new Collection(), + BombExploded = new Collection(), + BombPlanted = new Collection(), + MolotovsFireStarted = new Collection(), + IncendiariesFireStarted = new Collection(), ChatMessageList = new List(), - PlayersHurted = new ObservableCollection(), - Kills = new ObservableCollection(), - PlayerBlinded = new ObservableCollection(), - PositionPoints = new ObservableCollection(), - Overtimes = new ObservableCollection(), - Rounds = new ObservableCollection(), + PlayersHurted = new Collection(), + Kills = new Collection(), + PlayerBlinded = new Collection(), + PositionPoints = new Collection(), + Overtimes = new Collection(), + Rounds = new Collection(), }; foreach (Player player in Players) @@ -1415,6 +1385,7 @@ public void BackupFromDemo(Demo demo) MostEntryKillPlayer = demo.MostEntryKillPlayer; MostHeadshotPlayer = demo.MostHeadshotPlayer; MostKillingWeapon = demo.MostKillingWeapon; + MostDamagingWeapon = demo.MostDamagingWeapon; MvpCount = demo.MvpCount; OneKillCount = demo.OneKillCount; SmokeThrownCount = demo.SmokeThrownCount; @@ -1429,88 +1400,86 @@ public void BackupFromDemo(Demo demo) public void ResetStats(bool resetTeams = true) { - DispatcherHelper.CheckBeginInvokeOnUI(delegate + AssistCount = 0; + AssistPerRound = 0; + AverageEseaRws = 0; + AverageHealthDamage = 0; + AverageHltvRating = 0; + AverageHltv2Rating = 0; + BombDefusedCount = 0; + BombExplodedCount = 0; + BombPlantedCount = 0; + ClutchCount = 0; + ClutchLostCount = 0; + ClutchWonCount = 0; + CrouchKillCount = 0; + DamageArmorCount = 0; + DamageHealthCount = 0; + DeathCount = 0; + DeathPerRound = 0; + DecoyThrownCount = 0; + EntryKillCount = 0; + FlashbangThrownCount = 0; + FiveKillCount = 0; + FourKillCount = 0; + CheaterCount = 0; + HeadshotCount = 0; + HeThrownCount = 0; + HitCount = 0; + IncendiaryThrownCount = 0; + JumpKillCount = 0; + KillCount = 0; + KillPerRound = 0; + KnifeKillCount = 0; + MolotovThrownCount = 0; + MostBombPlantedPlayer = null; + MostEntryKillPlayer = null; + MostHeadshotPlayer = null; + MostKillingWeapon = null; + MostDamagingWeapon = null; + MvpCount = 0; + OneKillCount = 0; + SmokeThrownCount = 0; + Surrender = null; + TeamKillCount = 0; + ThreeKillCount = 0; + TradeKillCount = 0; + TwoKillCount = 0; + WeaponFiredCount = 0; + Winner = null; + BombDefused.Clear(); + BombExploded.Clear(); + BombPlanted.Clear(); + ChatMessageList.Clear(); + DecoyStarted.Clear(); + IncendiariesFireStarted.Clear(); + Kills.Clear(); + MolotovsFireStarted.Clear(); + Overtimes.Clear(); + PlayersHurted.Clear(); + PlayerBlinded.Clear(); + PositionPoints.Clear(); + Rounds.Clear(); + WeaponFired.Clear(); + TeamT.ResetStats(); + TeamCT.ResetStats(); + TeamCT.CurrentSide = Side.CounterTerrorist; + TeamT.CurrentSide = Side.Terrorist; + if (resetTeams) { - AssistCount = 0; - AssistPerRound = 0; - AverageEseaRws = 0; - AverageHealthDamage = 0; - AverageHltvRating = 0; - AverageHltv2Rating = 0; - BombDefusedCount = 0; - BombExplodedCount = 0; - BombPlantedCount = 0; - ClutchCount = 0; - ClutchLostCount = 0; - ClutchWonCount = 0; - CrouchKillCount = 0; - DamageArmorCount = 0; - DamageHealthCount = 0; - DeathCount = 0; - DeathPerRound = 0; - DecoyThrownCount = 0; - EntryKillCount = 0; - FlashbangThrownCount = 0; - FiveKillCount = 0; - FourKillCount = 0; - CheaterCount = 0; - HeadshotCount = 0; - HeThrownCount = 0; - HitCount = 0; - IncendiaryThrownCount = 0; - JumpKillCount = 0; - KillCount = 0; - KillPerRound = 0; - KnifeKillCount = 0; - MolotovThrownCount = 0; - MostBombPlantedPlayer = null; - MostEntryKillPlayer = null; - MostHeadshotPlayer = null; - MostKillingWeapon = null; - MvpCount = 0; - OneKillCount = 0; - SmokeThrownCount = 0; - Surrender = null; - TeamKillCount = 0; - ThreeKillCount = 0; - TradeKillCount = 0; - TwoKillCount = 0; - WeaponFiredCount = 0; - Winner = null; - BombDefused.Clear(); - BombExploded.Clear(); - BombPlanted.Clear(); - ChatMessageList.Clear(); - DecoyStarted.Clear(); - IncendiariesFireStarted.Clear(); - Kills.Clear(); - MolotovsFireStarted.Clear(); - Overtimes.Clear(); - PlayersHurted.Clear(); - PlayerBlinded.Clear(); - PositionPoints.Clear(); - Rounds.Clear(); - WeaponFired.Clear(); - TeamT.ResetStats(); - TeamCT.ResetStats(); - TeamCT.CurrentSide = Side.CounterTerrorist; - TeamT.CurrentSide = Side.Terrorist; - if (resetTeams) - { - Players.Clear(); - TeamCT.Clear(); - TeamT.Clear(); - } - else + Players.Clear(); + TeamCT.Clear(); + TeamT.Clear(); + } + else + { + foreach (Player player in Players) { - foreach (Player player in Players) - { - player.ResetStats(); - } + player.ResetStats(); } + } - RaiseScoresChanged(); - }); + RaiseScoresChanged(); } /// @@ -1532,9 +1501,7 @@ public void RaiseScoresChanged() RaisePropertyChanged(() => ScoreSecondHalfTeamT); } - #region Handler collections changed - - private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + public void ComputeStats() { KillCount = Kills.Count; DeathCount = Kills.Count; @@ -1546,31 +1513,13 @@ private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEven JumpKillCount = Kills.Count(killEvent => killEvent.KillerVelocityZ > 0); KnifeKillCount = Kills.Count(killEvent => killEvent.Weapon.Element == EquipmentElement.Knife); TeamKillCount = Players.Sum(p => p.TeamKillCount); - } - - private void OnBombExplodedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { BombExplodedCount = BombExploded.Count; - } - - private void OnBombDefusedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { BombDefusedCount = BombDefused.Count; - } - - private void OnBombPlantedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { BombPlantedCount = BombPlanted.Count; - } - - private void OnRoundsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => MostDamageWeapon); - RaisePropertyChanged(() => WinStatus); - ClutchWonCount = Players.Sum(p => p.ClutchWonCount); ClutchCount = Players.Sum(p => p.ClutchCount); ClutchLostCount = Players.Sum(p => p.ClutchLostCount); + MostDamagingWeapon = GetMostDamagingWeapon(); if (Rounds.Any()) { @@ -1579,6 +1528,7 @@ private void OnRoundsCollectionChanged(object sender, NotifyCollectionChangedEve AssistPerRound = GetAssistPerRound(); MvpCount = Players.Sum(p => p.RoundMvpCount); DeathPerRound = Math.Round((double)DeathCount / Rounds.Count, 2); + AverageHealthDamage = GetAverageHealthDamage(); } if (Players.Any()) @@ -1590,21 +1540,11 @@ private void OnRoundsCollectionChanged(object sender, NotifyCollectionChangedEve decimal totalEseaRws = Players.Sum(player => player.EseaRws); AverageEseaRws = Math.Round(totalEseaRws / Players.Count, 2); } - } - private void OnPlayersHurtedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { DamageArmorCount = PlayersHurted.Sum(h => h.ArmorDamage); DamageHealthCount = PlayersHurted.Sum(h => h.HealthDamage); HitCount = PlayersHurted.Count; - if (Rounds.Any()) - { - AverageHealthDamage = GetAverageHealthDamage(); - } - } - private void OnWeaponFireCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { WeaponFiredCount = WeaponFired.Count; FlashbangThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Flash); SmokeThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Smoke); @@ -1612,9 +1552,37 @@ private void OnWeaponFireCollectionChanged(object sender, NotifyCollectionChange DecoyThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Decoy); MolotovThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Molotov); IncendiaryThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Incendiary); + + foreach (var player in Players) + { + player.ComputeStats(); + } + + foreach (var round in Rounds) + { + round.ComputeStats(); + } } - #endregion + + private Weapon GetMostDamagingWeapon() + { + Dictionary weapons = new Dictionary(); + + foreach (PlayerHurtedEvent playerHurtedEvent in Rounds.SelectMany(round => round.PlayersHurted)) + { + if (!weapons.ContainsKey(playerHurtedEvent.Weapon)) + { + weapons[playerHurtedEvent.Weapon] = playerHurtedEvent.HealthDamage + playerHurtedEvent.ArmorDamage; + } + else + { + weapons[playerHurtedEvent.Weapon] += playerHurtedEvent.HealthDamage + playerHurtedEvent.ArmorDamage; + } + } + + return weapons.OrderByDescending(x => x.Value).FirstOrDefault().Key; + } private double GetKillPerRound() { diff --git a/Core/Models/Player.cs b/Core/Models/Player.cs index f6b6528f1..6dc256218 100644 --- a/Core/Models/Player.cs +++ b/Core/Models/Player.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.Linq; using Core.Models.Events; using Core.Models.Serialization; @@ -117,11 +116,6 @@ public class Player : ObservableObject /// private bool _isConnected = true; - /// - /// Player kills / Deaths ratio - /// - private decimal _killsDeathsRatio; - /// /// Player's current team side (change when half side is over) /// @@ -290,37 +284,37 @@ public class Player : ObservableObject /// /// Player's kills data /// - private ObservableCollection _kills; + private Collection _kills; /// /// Player's deaths data /// - private ObservableCollection _deaths; + private Collection _deaths; /// /// Player's assists data /// - private ObservableCollection _assists; + private Collection _assists; /// /// Player's entry kills data /// - private ObservableCollection _entryKills; + private Collection _entryKills; /// /// Player's entry hold kills data /// - private ObservableCollection _entryHoldKills; + private Collection _entryHoldKills; /// /// List of PlayerHurtedEvent in which the player is involved /// - private ObservableCollection _playersHurted; + private Collection _playersHurted; /// /// List of clutches that the player is concerned /// - private ObservableCollection _clutches; + private Collection _clutches; #endregion @@ -345,11 +339,7 @@ public string Name public int KillCount { get { return _killCount; } - set - { - RaisePropertyChanged(() => KillDeathRatio); - Set(() => KillCount, ref _killCount, value); - } + set { Set(() => KillCount, ref _killCount, value); } } [JsonProperty("crouch_kill_count")] @@ -384,11 +374,7 @@ public int TeamKillCount public int AssistCount { get { return _assistCount; } - set - { - Set(() => AssistCount, ref _assistCount, value); - RaisePropertyChanged(() => AssistPerRound); - } + set { Set(() => AssistCount, ref _assistCount, value); } } [JsonProperty("trade_kill_count")] @@ -430,11 +416,7 @@ public int BombExplodedCount public int DeathCount { get { return _deathCount; } - set - { - RaisePropertyChanged(() => KillDeathRatio); - Set(() => DeathCount, ref _deathCount, value); - } + set { Set(() => DeathCount, ref _deathCount, value); } } [JsonProperty("5k_count")] @@ -476,11 +458,7 @@ public int OneKillCount public int HeadshotCount { get { return _headshotCount; } - set - { - Set(() => HeadshotCount, ref _headshotCount, value); - RaisePropertyChanged(() => HeadshotPercent); - } + set { Set(() => HeadshotCount, ref _headshotCount, value); } } [JsonProperty("kd")] @@ -495,7 +473,6 @@ public decimal KillDeathRatio return 0; } - set { Set(() => KillDeathRatio, ref _killsDeathsRatio, value); } } [JsonProperty("mvp_count")] @@ -537,22 +514,14 @@ public decimal EseaRws public int ShotCount { get { return _shotCount; } - set - { - Set(() => ShotCount, ref _shotCount, value); - RaisePropertyChanged(() => Accuracy); - } + set { Set(() => ShotCount, ref _shotCount, value); } } [JsonProperty("hit_count")] public int HitCount { get { return _hitCount; } - set - { - Set(() => HitCount, ref _hitCount, value); - RaisePropertyChanged(() => Accuracy); - } + set { Set(() => HitCount, ref _hitCount, value); } } [JsonIgnore] public double Accuracy => ShotCount == 0 ? 0 : Math.Round(HitCount / (double)ShotCount * 100, 2); @@ -656,49 +625,49 @@ public Dictionary TimeDeathRounds } [JsonProperty("entry_kills")] - public ObservableCollection EntryKills + public Collection EntryKills { get { return _entryKills; } set { Set(() => EntryKills, ref _entryKills, value); } } [JsonProperty("entry_hold_kills")] - public ObservableCollection EntryHoldKills + public Collection EntryHoldKills { get { return _entryHoldKills; } set { Set(() => EntryHoldKills, ref _entryHoldKills, value); } } [JsonProperty("kills", IsReference = false)] - public ObservableCollection Kills + public Collection Kills { get { return _kills; } set { Set(() => Kills, ref _kills, value); } } [JsonProperty("deaths", IsReference = false)] - public ObservableCollection Deaths + public Collection Deaths { get { return _deaths; } set { Set(() => Deaths, ref _deaths, value); } } [JsonProperty("assits", IsReference = false)] - public ObservableCollection Assists + public Collection Assists { get { return _assists; } set { Set(() => Assists, ref _assists, value); } } [JsonProperty("players_hurted")] - public ObservableCollection PlayersHurted + public Collection PlayersHurted { get { return _playersHurted; } set { Set(() => PlayersHurted, ref _playersHurted, value); } } [JsonProperty("clutches")] - public ObservableCollection Clutches + public Collection Clutches { get { return _clutches; } set { Set(() => Clutches, ref _clutches, value); } @@ -1081,83 +1050,25 @@ public override int GetHashCode() public Player() { - EntryKills = new ObservableCollection(); - EntryHoldKills = new ObservableCollection(); - PlayersHurted = new ObservableCollection(); - Clutches = new ObservableCollection(); - Kills = new ObservableCollection(); - Deaths = new ObservableCollection(); - Assists = new ObservableCollection(); - Kills.CollectionChanged += OnKillsCollectionChanged; - Deaths.CollectionChanged += OnDeathsCollectionChanged; - Assists.CollectionChanged += OnAssistsCollectionChanged; - EntryKills.CollectionChanged += OnEntryKillsCollectionChanged; - EntryHoldKills.CollectionChanged += OnEntryHoldKillsCollectionChanged; - PlayersHurted.CollectionChanged += OnPlayersHurtedCollectionChanged; - Clutches.CollectionChanged += OnClutchesCollectionChanged; + EntryKills = new Collection(); + EntryHoldKills = new Collection(); + PlayersHurted = new Collection(); + Clutches = new Collection(); + Kills = new Collection(); + Deaths = new Collection(); + Assists = new Collection(); Side = Side.None; } - private void OnAssistsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - AssistCount = Assists.Count; - } - - private void OnDeathsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - DeathCount = Deaths.Count + SuicideCount; - RaisePropertyChanged(() => AverageTimeDeath); - } - - private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + public void ComputeStats() { TeamKillCount = Kills.Count(k => k.KilledSide == k.KillerSide); KillCount = Kills.Count(k => k.KilledSide != k.KillerSide) - TeamKillCount - SuicideCount; HeadshotCount = Kills.Count(k => k.KilledSide != k.KillerSide && k.IsHeadshot); CrouchKillCount = Kills.Count(k => k.KilledSide != k.KillerSide && k.IsKillerCrouching); JumpKillCount = Kills.Count(k => k.KilledSide != k.KillerSide && k.KillerVelocityZ > 0); - } - - private void OnPlayersHurtedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => TotalDamageHealthCount); - RaisePropertyChanged(() => TotalDamageArmorCount); - RaisePropertyChanged(() => AverageHealthDamage); - } - - private void OnEntryKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => EntryKillWonCount); - RaisePropertyChanged(() => EntryKillLossCount); - RaisePropertyChanged(() => RatioEntryKill); - } - - private void OnEntryHoldKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => EntryHoldKillWonCount); - RaisePropertyChanged(() => EntryHoldKillLossCount); - RaisePropertyChanged(() => RatioEntryHoldKill); - } - - private void OnClutchesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => ClutchCount); - RaisePropertyChanged(() => ClutchLostCount); - RaisePropertyChanged(() => Clutch1V1Count); - RaisePropertyChanged(() => Clutch1V2Count); - RaisePropertyChanged(() => Clutch1V3Count); - RaisePropertyChanged(() => Clutch1V4Count); - RaisePropertyChanged(() => Clutch1V5Count); - RaisePropertyChanged(() => Clutch1V1WonCount); - RaisePropertyChanged(() => Clutch1V2WonCount); - RaisePropertyChanged(() => Clutch1V3WonCount); - RaisePropertyChanged(() => Clutch1V4WonCount); - RaisePropertyChanged(() => Clutch1V5WonCount); - RaisePropertyChanged(() => Clutch1V1LossCount); - RaisePropertyChanged(() => Clutch1V2LossCount); - RaisePropertyChanged(() => Clutch1V3LossCount); - RaisePropertyChanged(() => Clutch1V4LossCount); - RaisePropertyChanged(() => Clutch1V5LossCount); + AssistCount = Assists.Count; + DeathCount = Deaths.Count + SuicideCount; } public void ResetStats() @@ -1253,7 +1164,6 @@ public Player Clone() IsOverwatchBanned = IsOverwatchBanned, IsVacBanned = IsVacBanned, JumpKillCount = JumpKillCount, - KillDeathRatio = KillDeathRatio, MolotovThrownCount = MolotovThrownCount, RankNumberNew = RankNumberNew, RankNumberOld = RankNumberOld, @@ -1269,14 +1179,14 @@ public Player Clone() TradeDeathCount = TradeDeathCount, TradeKillCount = TradeKillCount, WinCount = WinCount, - PlayersHurted = new ObservableCollection(), - Kills = new ObservableCollection(), - Assists = new ObservableCollection(), - Deaths = new ObservableCollection(), - EntryHoldKills = new ObservableCollection(), + PlayersHurted = new Collection(), + Kills = new Collection(), + Assists = new Collection(), + Deaths = new Collection(), + EntryHoldKills = new Collection(), RoundsMoneyEarned = new Dictionary(), - Clutches = new ObservableCollection(), - EntryKills = new ObservableCollection(), + Clutches = new Collection(), + EntryKills = new Collection(), EquipementValueRounds = new Dictionary(), StartMoneyRounds = new Dictionary(), }; diff --git a/Core/Models/Round.cs b/Core/Models/Round.cs index 05d56c4f5..ef6e21934 100644 --- a/Core/Models/Round.cs +++ b/Core/Models/Round.cs @@ -2,7 +2,6 @@ using GalaSoft.MvvmLight; using Newtonsoft.Json; using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.Linq; using Core.Models.Events; using Core.Models.Serialization; @@ -291,32 +290,32 @@ public class Round : ObservableObject /// /// Kills done during the round /// - private ObservableCollection _kills; + private Collection _kills; /// /// Infos about flashbangs exploded events /// - private ObservableCollection _flashbangsExploded; + private Collection _flashbangsExploded; /// /// Infos about HE Grenades that exploded during the round /// - private ObservableCollection _explosiveGrenadesExploded; + private Collection _explosiveGrenadesExploded; /// /// Infos about smokes poped during the round /// - private ObservableCollection _smokeStarted; + private Collection _smokeStarted; /// /// Infos on players damages made during the round /// - private ObservableCollection _playerHurted; + private Collection _playerHurted; /// /// Infos about shoots done during the round /// - private ObservableCollection _weaponFired; + private Collection _weaponFired; #endregion @@ -366,7 +365,7 @@ public RoundEndReason EndReason } [JsonProperty("kills", IsReference = false)] - public ObservableCollection Kills + public Collection Kills { get { return _kills; } set { Set(() => Kills, ref _kills, value); } @@ -613,14 +612,14 @@ public int IncendiaryThrownCount } [JsonProperty("players_hurted", IsReference = false)] - public ObservableCollection PlayersHurted + public Collection PlayersHurted { get { return _playerHurted; } set { Set(() => PlayersHurted, ref _playerHurted, value); } } [JsonProperty("weapon_fired", IsReference = false)] - public ObservableCollection WeaponFired + public Collection WeaponFired { get { return _weaponFired; } set { Set(() => WeaponFired, ref _weaponFired, value); } @@ -655,21 +654,21 @@ public double AverageHealthDamagePerPlayer } [JsonProperty("flashbangs_exploded")] - public ObservableCollection FlashbangsExploded + public Collection FlashbangsExploded { get { return _flashbangsExploded; } set { Set(() => FlashbangsExploded, ref _flashbangsExploded, value); } } [JsonProperty("smokes_started")] - public ObservableCollection SmokeStarted + public Collection SmokeStarted { get { return _smokeStarted; } set { Set(() => SmokeStarted, ref _smokeStarted, value); } } [JsonProperty("he_exploded")] - public ObservableCollection ExplosiveGrenadesExploded + public Collection ExplosiveGrenadesExploded { get { return _explosiveGrenadesExploded; } set { Set(() => ExplosiveGrenadesExploded, ref _explosiveGrenadesExploded, value); } @@ -679,16 +678,12 @@ public ObservableCollection ExplosiveGrenadesExplode public Round() { - PlayersHurted = new ObservableCollection(); - WeaponFired = new ObservableCollection(); - ExplosiveGrenadesExploded = new ObservableCollection(); - SmokeStarted = new ObservableCollection(); - FlashbangsExploded = new ObservableCollection(); - Kills = new ObservableCollection(); - - Kills.CollectionChanged += OnKillsCollectionChanged; - PlayersHurted.CollectionChanged += OnPlayersHurtedCollectionChanged; - WeaponFired.CollectionChanged += OnWeaponFiredCollectionChanged; + PlayersHurted = new Collection(); + WeaponFired = new Collection(); + ExplosiveGrenadesExploded = new Collection(); + SmokeStarted = new Collection(); + FlashbangsExploded = new Collection(); + Kills = new Collection(); } public override bool Equals(object obj) @@ -751,12 +746,12 @@ public Round Clone() Type = Type, WinnerName = WinnerName, WinnerSide = WinnerSide, - PlayersHurted = new ObservableCollection(), - Kills = new ObservableCollection(), - WeaponFired = new ObservableCollection(), - ExplosiveGrenadesExploded = new ObservableCollection(), - FlashbangsExploded = new ObservableCollection(), - SmokeStarted = new ObservableCollection(), + PlayersHurted = new Collection(), + Kills = new Collection(), + WeaponFired = new Collection(), + ExplosiveGrenadesExploded = new Collection(), + FlashbangsExploded = new Collection(), + SmokeStarted = new Collection(), }; foreach (PlayerHurtedEvent e in PlayersHurted) @@ -835,9 +830,7 @@ public void Reset(int tick) WeaponFired.Clear(); } - #region Handler collections changed - - private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) + public void ComputeStats() { KillCount = Kills.Count; JumpKillCount = Kills.Count(killEvent => killEvent.KillerVelocityZ > 0); @@ -856,19 +849,11 @@ private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEven ThreeKillCount = kills.Count(k => k.KillCount == 3); FourKillCount = kills.Count(k => k.KillCount == 4); FiveKillCount = kills.Count(k => k.KillCount == 5); - } - - private void OnPlayersHurtedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { DamageHealthCount = PlayersHurted.Where(playerHurtedEvent => playerHurtedEvent.AttackerSteamId != 0) .Sum(playerHurtedEvent => playerHurtedEvent.HealthDamage); DamageArmorCount = PlayersHurted.Where(playerHurtedEvent => playerHurtedEvent.AttackerSteamId != 0) .Sum(playerHurtedEvent => playerHurtedEvent.ArmorDamage); AverageHealthDamagePerPlayer = GetAverageHealthDamagePerPlayer(); - } - - private void OnWeaponFiredCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { IncendiaryThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Incendiary); MolotovThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Molotov); DecoyThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Decoy); @@ -877,8 +862,6 @@ private void OnWeaponFiredCollectionChanged(object sender, NotifyCollectionChang FlashbangThrownCount = WeaponFired.Count(w => w.Weapon.Element == EquipmentElement.Flash); } - #endregion - private double GetAverageHealthDamagePerPlayer() { double total = PlayersHurted.Aggregate(0, (current, playerHurtedEvent) => diff --git a/Core/Models/Team.cs b/Core/Models/Team.cs index 71e9ea1c7..ed859506c 100644 --- a/Core/Models/Team.cs +++ b/Core/Models/Team.cs @@ -1,6 +1,5 @@ using System; using System.Collections.ObjectModel; -using System.Collections.Specialized; using System.Linq; using GalaSoft.MvvmLight; using Newtonsoft.Json; @@ -52,7 +51,7 @@ public int ScoreSecondHalf } [JsonProperty("team_players", IsReference = false)] - public ObservableCollection Players { get; set; } + public Collection Players { get; set; } [JsonIgnore] public Side CurrentSide { get; set; } @@ -231,8 +230,7 @@ public override int GetHashCode() public Team() { - Players = new ObservableCollection(); - Players.CollectionChanged += OnPlayersCollectionChanged; + Players = new Collection(); } public void Clear() @@ -291,7 +289,7 @@ public Team Clone() WinRoundCtCount = WinRoundCtCount, WinRoundTCount = WinRoundTCount, WinSemiEcoRoundCount = WinSemiEcoRoundCount, - Players = new ObservableCollection(), + Players = new Collection(), }; foreach (Player player in Players) @@ -326,60 +324,5 @@ public void BackupFromTeam(Team team) WinRoundTCount = team.WinRoundTCount; WinSemiEcoRoundCount = team.WinSemiEcoRoundCount; } - - #region Collections events - - private void OnPlayersCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - if (Players.Any()) - { - foreach (var player in Players) - { - if (player != null) - { - player.Kills.CollectionChanged += OnKillsCollectionChanged; - player.Deaths.CollectionChanged += OnDeathsCollectionChanged; - player.Assists.CollectionChanged += OnAssistsCollectionChanged; - player.EntryKills.CollectionChanged += OnEntryKillsCollectionChanged; - player.EntryHoldKills.CollectionChanged += OnEntryHoldKillsCollectionChanged; - } - } - } - } - - private void OnDeathsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => DeathCount); - } - - private void OnAssistsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => AssistCount); - } - - private void OnKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => KillCount); - RaisePropertyChanged(() => JumpKillCount); - RaisePropertyChanged(() => CrouchKillCount); - } - - private void OnEntryKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => EntryKillCount); - RaisePropertyChanged(() => EntryKillWonCount); - RaisePropertyChanged(() => EntryKillLossCount); - RaisePropertyChanged(() => RatioEntryKill); - } - - private void OnEntryHoldKillsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - RaisePropertyChanged(() => EntryHoldKillCount); - RaisePropertyChanged(() => EntryHoldKillWonCount); - RaisePropertyChanged(() => EntryHoldKillLossCount); - RaisePropertyChanged(() => RatioEntryHoldKill); - } - - #endregion } } diff --git a/Manager/ViewModel/Demos/DemoMovieViewModel.cs b/Manager/ViewModel/Demos/DemoMovieViewModel.cs index 31978a1b5..8fa287463 100644 --- a/Manager/ViewModel/Demos/DemoMovieViewModel.cs +++ b/Manager/ViewModel/Demos/DemoMovieViewModel.cs @@ -15,7 +15,6 @@ using Core.Models.Source; using GalaSoft.MvvmLight.CommandWpf; using MahApps.Metro.Controls.Dialogs; -using Manager.Internals; using Manager.Models.DemoMovie; using Manager.Properties; using Manager.Services; @@ -1537,7 +1536,7 @@ private void OnVirtualDubStarted() private void InitConfiguration() { - OutputFileName = Path.GetFileNameWithoutExtension(Demo.Name); + OutputFileName = Demo.NameWithoutExtension; FrameRate = Settings.Default.MovieFramerate; AutoCloseGame = Settings.Default.MovieAutoCloseGame; Fullscreen = Settings.Default.MovieFullscreen; diff --git a/Manager/Views/Demos/DemoDetailsView.xaml b/Manager/Views/Demos/DemoDetailsView.xaml index f55c7a7fd..4f42542c7 100644 --- a/Manager/Views/Demos/DemoDetailsView.xaml +++ b/Manager/Views/Demos/DemoDetailsView.xaml @@ -483,7 +483,7 @@ Margin="5 0 0 0"> - diff --git a/Services/Concrete/Analyzer/CevoAnalyzer.cs b/Services/Concrete/Analyzer/CevoAnalyzer.cs index 8ed59cede..2f014141f 100644 --- a/Services/Concrete/Analyzer/CevoAnalyzer.cs +++ b/Services/Concrete/Analyzer/CevoAnalyzer.cs @@ -2,7 +2,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Core.Models; using DemoInfo; using Player = Core.Models.Player; @@ -81,7 +80,7 @@ protected sealed override void RegisterEvents() protected void HandleWinPanelMatch(object sender, WinPanelMatchEventArgs e) { // Add the last round (round_officially_ended isn't raised at the end) - Application.Current.Dispatcher.Invoke(delegate { Demo.Rounds.Add(CurrentRound); }); + Demo.Rounds.Add(CurrentRound); ProcessPlayersRating(); } @@ -165,7 +164,7 @@ protected void HandleRoundFinal(object sender, RoundFinalEventArgs e) UpdateKillsCount(); UpdatePlayerScore(); - Application.Current.Dispatcher.Invoke(delegate { Demo.Rounds.Add(CurrentRound); }); + Demo.Rounds.Add(CurrentRound); // End of a half if (IsLastRoundHalf) @@ -183,7 +182,7 @@ protected void HandleRoundFinal(object sender, RoundFinalEventArgs e) // Add the current overtime only if it's not the first if (CurrentOvertime.Number != 0) { - Application.Current.Dispatcher.Invoke(delegate { Demo.Overtimes.Add(CurrentOvertime); }); + Demo.Overtimes.Add(CurrentOvertime); IsHalfMatch = true; } else @@ -219,31 +218,28 @@ private void AddTeams() Side = player.Team.ToSide(), }; - Application.Current.Dispatcher.Invoke(delegate + if (!Demo.Players.Contains(pl)) { - if (!Demo.Players.Contains(pl)) - { - Demo.Players.Add(pl); - } + Demo.Players.Add(pl); + } - if (pl.Side == Side.CounterTerrorist) + if (pl.Side == Side.CounterTerrorist) + { + pl.TeamName = Demo.TeamCT.Name; + if (!Demo.TeamCT.Players.Contains(pl)) { - pl.TeamName = Demo.TeamCT.Name; - if (!Demo.TeamCT.Players.Contains(pl)) - { - Demo.TeamCT.Players.Add(pl); - } + Demo.TeamCT.Players.Add(pl); } + } - if (pl.Side == Side.Terrorist) + if (pl.Side == Side.Terrorist) + { + pl.TeamName = Demo.TeamT.Name; + if (!Demo.TeamT.Players.Contains(pl)) { - pl.TeamName = Demo.TeamT.Name; - if (!Demo.TeamT.Players.Contains(pl)) - { - Demo.TeamT.Players.Add(pl); - } + Demo.TeamT.Players.Add(pl); } - }); + } } } } diff --git a/Services/Concrete/Analyzer/DemoAnalyzer.cs b/Services/Concrete/Analyzer/DemoAnalyzer.cs index a5edc7df6..274ba1310 100644 --- a/Services/Concrete/Analyzer/DemoAnalyzer.cs +++ b/Services/Concrete/Analyzer/DemoAnalyzer.cs @@ -7,7 +7,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Core.Models; using Core.Models.Events; using Core.Models.protobuf; @@ -366,7 +365,7 @@ protected void HandleTickDone(object sender, TickDoneEventArgs e) RoundNumber = CurrentRound.Number, Duration = player.FlashDuration - pl.FlashDurationTemp, }; - Application.Current.Dispatcher.Invoke(() => Demo.PlayerBlinded.Add(playerBlindedEvent)); + Demo.PlayerBlinded.Add(playerBlindedEvent); } } } @@ -405,7 +404,7 @@ protected void HandleTickDone(object sender, TickDoneEventArgs e) PlayerSteamId = player.SteamID, PlayerHasBomb = player.Weapons.FirstOrDefault(w => w.Weapon == EquipmentElement.Bomb) != null, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } } @@ -561,16 +560,13 @@ protected void HandlePlayerKilled(object sender, PlayerKilledEventArgs e) { killEvent.AssisterSteamId = assister.SteamId; killEvent.AssisterName = assister.Name; - Application.Current.Dispatcher.Invoke(() => assister.Assists.Add(killEvent)); + assister.Assists.Add(killEvent); } - Application.Current.Dispatcher.Invoke(delegate - { - Demo.Kills.Add(killEvent); - CurrentRound.Kills.Add(killEvent); - killer?.Kills.Add(killEvent); - killed.Deaths.Add(killEvent); - }); + Demo.Kills.Add(killEvent); + CurrentRound.Kills.Add(killEvent); + killer?.Kills.Add(killEvent); + killed.Deaths.Add(killEvent); if (AnalyzePlayersPosition) { @@ -584,7 +580,7 @@ protected void HandlePlayerKilled(object sender, PlayerKilledEventArgs e) Event = killEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -610,39 +606,36 @@ protected void HandleRoundEnd(object sender, RoundEndedEventArgs e) Demo.Surrender = IsHalfMatch ? Demo.TeamCT : Demo.TeamT; } - Application.Current.Dispatcher.Invoke(delegate + // update round won status for entry kills / hold kills + if (e.Winner.ToSide() == CurrentRound.EntryKillEvent?.KillerSide) { - // update round won status for entry kills / hold kills - if (e.Winner.ToSide() == CurrentRound.EntryKillEvent?.KillerSide) - { - CurrentRound.EntryKillEvent.HasWonRound = true; - } + CurrentRound.EntryKillEvent.HasWonRound = true; + } - if (e.Winner.ToSide() == CurrentRound.EntryHoldKillEvent?.KillerSide) - { - CurrentRound.EntryHoldKillEvent.HasWonRound = true; - } + if (e.Winner.ToSide() == CurrentRound.EntryHoldKillEvent?.KillerSide) + { + CurrentRound.EntryHoldKillEvent.HasWonRound = true; + } - List playerWithEntryKill = Demo.Players.Where(p => p.HasEntryKill).ToList(); - foreach (Player player in playerWithEntryKill) + List playerWithEntryKill = Demo.Players.Where(p => p.HasEntryKill).ToList(); + foreach (Player player in playerWithEntryKill) + { + if (player.Side == e.Winner.ToSide()) { - if (player.Side == e.Winner.ToSide()) - { - player.EntryKills.Last().HasWonRound = true; - } + player.EntryKills.Last().HasWonRound = true; } + } - List playerWithEntryHoldKill = Demo.Players.Where(p => p.HasEntryHoldKill).ToList(); - foreach (Player player in playerWithEntryHoldKill) + List playerWithEntryHoldKill = Demo.Players.Where(p => p.HasEntryHoldKill).ToList(); + foreach (Player player in playerWithEntryHoldKill) + { + if (player.Side == e.Winner.ToSide()) { - if (player.Side == e.Winner.ToSide()) - { - player.EntryHoldKills.Last().HasWonRound = true; - } + player.EntryHoldKills.Last().HasWonRound = true; } + } - ComputeEseaRws(); - }); + ComputeEseaRws(); } /// @@ -687,7 +680,7 @@ protected void HandleRoundOfficiallyEnd(object sender, RoundOfficiallyEndedEvent if (!IsLastRoundHalf || !IsRoundEndOccured) { - Application.Current.Dispatcher.Invoke(() => Demo.Rounds.Add(CurrentRound)); + Demo.Rounds.Add(CurrentRound); } if (!IsOvertime && IsLastRoundHalf) @@ -747,7 +740,7 @@ protected void HandleBombPlanted(object sender, BombEventArgs e) Demo.BombPlantedCount++; CurrentRound.BombPlantedCount++; - Application.Current.Dispatcher.Invoke(() => Demo.BombPlanted.Add(bombPlantedEvent)); + Demo.BombPlanted.Add(bombPlantedEvent); CurrentRound.BombPlanted = bombPlantedEvent; if (AnalyzePlayersPosition && e.Player.SteamID != 0) @@ -762,7 +755,7 @@ protected void HandleBombPlanted(object sender, BombEventArgs e) Event = bombPlantedEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -791,7 +784,7 @@ protected void HandleBombDefused(object sender, BombEventArgs e) Demo.BombDefusedCount++; CurrentRound.BombDefusedCount++; - Application.Current.Dispatcher.Invoke(() => Demo.BombDefused.Add(bombDefusedEvent)); + Demo.BombDefused.Add(bombDefusedEvent); CurrentRound.BombDefused = bombDefusedEvent; if (AnalyzePlayersPosition && bombDefusedEvent.DefuserSteamId != 0) @@ -806,7 +799,7 @@ protected void HandleBombDefused(object sender, BombEventArgs e) Event = bombDefusedEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -832,7 +825,7 @@ protected void HandleBombExploded(object sender, BombEventArgs e) Demo.BombExplodedCount++; CurrentRound.BombExplodedCount++; - Application.Current.Dispatcher.Invoke(() => Demo.BombExploded.Add(bombExplodedEvent)); + Demo.BombExploded.Add(bombExplodedEvent); CurrentRound.BombExploded = bombExplodedEvent; if (AnalyzePlayersPosition && planter != null) @@ -847,7 +840,7 @@ protected void HandleBombExploded(object sender, BombEventArgs e) Event = bombExplodedEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -948,7 +941,7 @@ protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e) if (e.Weapon.Class == EquipmentClass.Grenade) { - Application.Current.Dispatcher.Invoke(() => CurrentRound.WeaponFired.Add(shoot)); + CurrentRound.WeaponFired.Add(shoot); } switch (e.Weapon.Weapon) @@ -976,7 +969,7 @@ protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e) break; } - Application.Current.Dispatcher.Invoke(() => Demo.WeaponFired.Add(shoot)); + Demo.WeaponFired.Add(shoot); if (e.Shooter.SteamID == 0) { @@ -1008,7 +1001,7 @@ protected void HandleWeaponFired(object sender, WeaponFiredEventArgs e) Event = shoot, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); break; } } @@ -1065,7 +1058,7 @@ protected void HandleFireNadeStarted(object sender, FireEventArgs e) Event = molotovEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1074,11 +1067,11 @@ protected void HandleFireNadeStarted(object sender, FireEventArgs e) EquipmentElement lastNadeType = LastNadeTypeThrown.Dequeue(); if (lastNadeType == EquipmentElement.Molotov) { - Application.Current.Dispatcher.Invoke(() => Demo.MolotovsFireStarted.Add(molotovEvent)); + Demo.MolotovsFireStarted.Add(molotovEvent); } else { - Application.Current.Dispatcher.Invoke(() => Demo.IncendiariesFireStarted.Add(molotovEvent)); + Demo.IncendiariesFireStarted.Add(molotovEvent); } } @@ -1136,7 +1129,7 @@ protected void HandleFireNadeEnded(object sender, FireEventArgs e) Event = molotovEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } break; @@ -1163,7 +1156,7 @@ protected void HandleExplosiveNadeExploded(object sender, GrenadeEventArgs e) }, }; - Application.Current.Dispatcher.Invoke(() => CurrentRound.ExplosiveGrenadesExploded.Add(explosiveEvent)); + CurrentRound.ExplosiveGrenadesExploded.Add(explosiveEvent); if (AnalyzePlayersPosition && thrower != null) { @@ -1177,7 +1170,7 @@ protected void HandleExplosiveNadeExploded(object sender, GrenadeEventArgs e) Event = explosiveEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1231,7 +1224,7 @@ protected void HandleFlashNadeExploded(object sender, FlashEventArgs e) } } - Application.Current.Dispatcher.Invoke(() => CurrentRound.FlashbangsExploded.Add(flashbangEvent)); + CurrentRound.FlashbangsExploded.Add(flashbangEvent); if (AnalyzePlayersPosition && thrower != null) { @@ -1245,7 +1238,7 @@ protected void HandleFlashNadeExploded(object sender, FlashEventArgs e) RoundNumber = CurrentRound.Number, Event = flashbangEvent, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1270,7 +1263,7 @@ protected void HandleSmokeNadeStarted(object sender, SmokeEventArgs e) }, }; - Application.Current.Dispatcher.Invoke(() => CurrentRound.SmokeStarted.Add(smokeEvent)); + CurrentRound.SmokeStarted.Add(smokeEvent); if (AnalyzePlayersPosition && thrower != null) { @@ -1284,7 +1277,7 @@ protected void HandleSmokeNadeStarted(object sender, SmokeEventArgs e) Event = smokeEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1315,7 +1308,7 @@ protected void HandleSmokeNadeEnded(object sender, SmokeEventArgs e) Event = smokeEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1339,7 +1332,7 @@ protected void HandleDecoyNadeStarted(object sender, DecoyEventArgs e) Y = e.Position.Y, }, }; - Application.Current.Dispatcher.Invoke(() => Demo.DecoyStarted.Add(decoyStartedEvent)); + Demo.DecoyStarted.Add(decoyStartedEvent); if (AnalyzePlayersPosition && thrower != null) { @@ -1353,7 +1346,7 @@ protected void HandleDecoyNadeStarted(object sender, DecoyEventArgs e) Event = decoyStartedEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1383,7 +1376,7 @@ protected void HandleDecoyNadeEnded(object sender, DecoyEventArgs e) Event = decoyEndedEvent, RoundNumber = CurrentRound.Number, }; - Application.Current.Dispatcher.Invoke(() => Demo.PositionPoints.Add(positionPoint)); + Demo.PositionPoints.Add(positionPoint); } } @@ -1450,13 +1443,10 @@ protected void HandlePlayerHurted(object sender, PlayerHurtEventArgs e) AttackerY = e.Attacker?.Position.Y ?? 0, }; - Application.Current.Dispatcher.Invoke(delegate - { - Demo.PlayersHurted.Add(playerHurtedEvent); - attacker?.PlayersHurted.Add(playerHurtedEvent); - hurted.PlayersHurted.Add(playerHurtedEvent); - CurrentRound.PlayersHurted.Add(playerHurtedEvent); - }); + Demo.PlayersHurted.Add(playerHurtedEvent); + attacker?.PlayersHurted.Add(playerHurtedEvent); + hurted.PlayersHurted.Add(playerHurtedEvent); + CurrentRound.PlayersHurted.Add(playerHurtedEvent); } /// @@ -1499,15 +1489,15 @@ protected void HandlePlayerTeam(object sender, PlayerTeamEventArgs e) Name = e.Swapped.Name, Side = e.NewTeam.ToSide(), }; - Application.Current.Dispatcher.Invoke(() => Demo.Players.Add(newPlayer)); + Demo.Players.Add(newPlayer); if (e.NewTeam.ToSide() == Side.CounterTerrorist) { - Application.Current.Dispatcher.Invoke(() => Demo.TeamCT.Players.Add(newPlayer)); + Demo.TeamCT.Players.Add(newPlayer); newPlayer.TeamName = Demo.TeamCT.Name; } else { - Application.Current.Dispatcher.Invoke(() => Demo.TeamT.Players.Add(newPlayer)); + Demo.TeamT.Players.Add(newPlayer); newPlayer.TeamName = Demo.TeamT.Name; } @@ -1738,13 +1728,10 @@ protected void ProcessClutches() _playerInClutch1 = Demo.Players.FirstOrDefault(p => p.SteamId == pl.SteamID && p.IsAlive); if (_playerInClutch1 != null) { - Application.Current.Dispatcher.Invoke(delegate + _playerInClutch1.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) { - _playerInClutch1.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) - { - RoundNumber = CurrentRound.Number, - OpponentCount = counterTerroristAliveCount, - }); + RoundNumber = CurrentRound.Number, + OpponentCount = counterTerroristAliveCount, }); return; } @@ -1762,13 +1749,10 @@ protected void ProcessClutches() _playerInClutch1 = Demo.Players.FirstOrDefault(p => p.SteamId == pl.SteamID && p.IsAlive); if (_playerInClutch1 != null) { - Application.Current.Dispatcher.Invoke(delegate + _playerInClutch1.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) { - _playerInClutch1.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) - { - RoundNumber = CurrentRound.Number, - OpponentCount = terroristAliveCount, - }); + RoundNumber = CurrentRound.Number, + OpponentCount = terroristAliveCount, }); return; } @@ -1796,13 +1780,10 @@ protected void ProcessClutches() return; } - Application.Current.Dispatcher.Invoke(delegate + _playerInClutch2.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) { - _playerInClutch2.Clutches.Add(new ClutchEvent(Parser.IngameTick, Parser.CurrentTime) - { - RoundNumber = CurrentRound.Number, - OpponentCount = 1, - }); + RoundNumber = CurrentRound.Number, + OpponentCount = 1, }); } } @@ -1986,57 +1967,54 @@ protected void ProcessOpenAndEntryKills(KillEvent killEvent) return; } - Application.Current.Dispatcher.Invoke(delegate + if (killEvent.KillerSide == Side.Terrorist) { - if (killEvent.KillerSide == Side.Terrorist) + // This is an entry kill + killer.HasEntryKill = true; + killed.HasEntryKill = true; + EntryKillEvent entryKillEvent = new EntryKillEvent(Parser.IngameTick, Parser.CurrentTime) { - // This is an entry kill - killer.HasEntryKill = true; - killed.HasEntryKill = true; - EntryKillEvent entryKillEvent = new EntryKillEvent(Parser.IngameTick, Parser.CurrentTime) - { - RoundNumber = CurrentRound.Number, - KilledSteamId = killed.SteamId, - KilledName = killed.Name, - KilledSide = killEvent.KilledSide, - KillerSteamId = killer.SteamId, - KillerName = killer.Name, - KillerSide = killEvent.KillerSide, - Weapon = killEvent.Weapon, - }; - CurrentRound.EntryKillEvent = entryKillEvent; - EntryKillEvent killerEvent = CurrentRound.EntryKillEvent.Clone(); - killerEvent.HasWon = true; - killer.EntryKills.Add(killerEvent); - EntryKillEvent killedEvent = CurrentRound.EntryKillEvent.Clone(); - killedEvent.HasWon = false; - killed.EntryKills.Add(killedEvent); - } - else + RoundNumber = CurrentRound.Number, + KilledSteamId = killed.SteamId, + KilledName = killed.Name, + KilledSide = killEvent.KilledSide, + KillerSteamId = killer.SteamId, + KillerName = killer.Name, + KillerSide = killEvent.KillerSide, + Weapon = killEvent.Weapon, + }; + CurrentRound.EntryKillEvent = entryKillEvent; + EntryKillEvent killerEvent = CurrentRound.EntryKillEvent.Clone(); + killerEvent.HasWon = true; + killer.EntryKills.Add(killerEvent); + EntryKillEvent killedEvent = CurrentRound.EntryKillEvent.Clone(); + killedEvent.HasWon = false; + killed.EntryKills.Add(killedEvent); + } + else + { + // CT done the kill , it's an entry hold kill + killer.HasEntryHoldKill = true; + killed.HasEntryHoldKill = true; + EntryHoldKillEvent entryHoldKillEvent = new EntryHoldKillEvent(Parser.IngameTick, Parser.CurrentTime) { - // CT done the kill , it's an entry hold kill - killer.HasEntryHoldKill = true; - killed.HasEntryHoldKill = true; - EntryHoldKillEvent entryHoldKillEvent = new EntryHoldKillEvent(Parser.IngameTick, Parser.CurrentTime) - { - RoundNumber = CurrentRound.Number, - KilledSteamId = killed.SteamId, - KilledName = killed.Name, - KilledSide = killEvent.KilledSide, - KillerSteamId = killer.SteamId, - KillerName = killer.Name, - KillerSide = killEvent.KillerSide, - Weapon = killEvent.Weapon, - }; - CurrentRound.EntryHoldKillEvent = entryHoldKillEvent; - EntryHoldKillEvent killerEvent = CurrentRound.EntryHoldKillEvent.Clone(); - killerEvent.HasWon = true; - killer.EntryHoldKills.Add(killerEvent); - EntryHoldKillEvent killedEvent = CurrentRound.EntryHoldKillEvent.Clone(); - killedEvent.HasWon = false; - killed.EntryHoldKills.Add(killedEvent); - } - }); + RoundNumber = CurrentRound.Number, + KilledSteamId = killed.SteamId, + KilledName = killed.Name, + KilledSide = killEvent.KilledSide, + KillerSteamId = killer.SteamId, + KillerName = killer.Name, + KillerSide = killEvent.KillerSide, + Weapon = killEvent.Weapon, + }; + CurrentRound.EntryHoldKillEvent = entryHoldKillEvent; + EntryHoldKillEvent killerEvent = CurrentRound.EntryHoldKillEvent.Clone(); + killerEvent.HasWon = true; + killer.EntryHoldKills.Add(killerEvent); + EntryHoldKillEvent killedEvent = CurrentRound.EntryHoldKillEvent.Clone(); + killedEvent.HasWon = false; + killed.EntryHoldKills.Add(killedEvent); + } IsFirstKillOccured = true; } @@ -2449,13 +2427,13 @@ protected void ProcessAnalyzeEnded() if (Demo.Rounds.Count < Demo.ScoreTeamCt + Demo.ScoreTeamT) { UpdateKillsCount(); - Application.Current.Dispatcher.Invoke(() => Demo.Rounds.Add(CurrentRound)); + Demo.Rounds.Add(CurrentRound); } // Add last overtime if there was an overtime at the end if (IsOvertime) { - Application.Current.Dispatcher.Invoke(() => Demo.Overtimes.Add(CurrentOvertime)); + Demo.Overtimes.Add(CurrentOvertime); } // Scores are reset on ESEA demos when the match is over @@ -2487,6 +2465,8 @@ protected void ProcessAnalyzeEnded() } } + Demo.ComputeStats(); + ClearQueues(); DemoBackup = null; } @@ -2515,11 +2495,8 @@ protected Team GetTeamBySide(Side side) /// protected void BackupToLastRound() { - Application.Current.Dispatcher.Invoke(delegate - { - CurrentRound.Reset(Parser.IngameTick); - Demo.BackupFromDemo(DemoBackup); - }); + CurrentRound.Reset(Parser.IngameTick); + Demo.BackupFromDemo(DemoBackup); IsFreezetime = true; IsRoundEndOccured = false; IsFirstShotOccured = false; diff --git a/Services/Concrete/Analyzer/EbotAnalyzer.cs b/Services/Concrete/Analyzer/EbotAnalyzer.cs index aa43c2035..5eb3e619e 100644 --- a/Services/Concrete/Analyzer/EbotAnalyzer.cs +++ b/Services/Concrete/Analyzer/EbotAnalyzer.cs @@ -4,7 +4,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Core.Models; using DemoInfo; using Player = Core.Models.Player; @@ -119,7 +118,7 @@ public override async Task AnalyzeDemoAsync(CancellationToken token, Actio // if the number of rounds played is equals to the double of MR, the OT is over if (MrOvertime * 2 == RoundCountOvertime) { - Application.Current.Dispatcher.Invoke(() => Demo.Overtimes.Add(CurrentOvertime)); + Demo.Overtimes.Add(CurrentOvertime); CreateNewOvertime(); RoundCountOvertime = 0; } @@ -275,13 +274,10 @@ protected void HandleWinPanelMatch(object sender, WinPanelMatchEventArgs e) UpdatePlayerScore(); } - Application.Current.Dispatcher.Invoke(delegate + if (!IsOvertime || !_isFaceit) { - if (!IsOvertime || !_isFaceit) - { - Demo.Rounds.Add(CurrentRound); - } - }); + Demo.Rounds.Add(CurrentRound); + } IsMatchStarted = false; } @@ -354,7 +350,7 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) if (IsLastRoundHalf) { - Application.Current.Dispatcher.Invoke(() => Demo.Rounds.Add(CurrentRound)); + Demo.Rounds.Add(CurrentRound); } } @@ -364,21 +360,18 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) if (!_isTeamsInitialized) { - Application.Current.Dispatcher.Invoke(delegate + if (Demo.Players.Count < 10) { - if (Demo.Players.Count < 10) - { - InitMatch(); - } + InitMatch(); + } - Demo.Rounds.Clear(); - CreateNewRound(); - // since some demos are already started we can't use the freezetime event - if (CurrentRound.Number == 1) - { - IsFreezetime = false; - } - }); + Demo.Rounds.Clear(); + CreateNewRound(); + // since some demos are already started we can't use the freezetime event + if (CurrentRound.Number == 1) + { + IsFreezetime = false; + } } base.HandleTickDone(sender, e); @@ -456,24 +449,24 @@ protected void UpdatePlayers() { if (teamT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => teamT.Players.Remove(pl)); + teamT.Players.Remove(pl); } if (!teamCt.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => teamCt.Players.Add(pl)); + teamCt.Players.Add(pl); } } else if (player.Team == DemoInfo.Team.Terrorist) { if (teamCt.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => teamCt.Players.Remove(pl)); + teamCt.Players.Remove(pl); } if (!teamT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => teamT.Players.Add(pl)); + teamT.Players.Add(pl); } } } @@ -486,7 +479,7 @@ protected void UpdatePlayers() Name = player.Name, Side = player.Team.ToSide(), }; - Application.Current.Dispatcher.Invoke(() => Demo.Players.Add(pl)); + Demo.Players.Add(pl); if (player.Team == DemoInfo.Team.CounterTerrorist) { @@ -494,17 +487,14 @@ protected void UpdatePlayers() // Check swap if (Demo.TeamT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(delegate - { - Demo.TeamCT.Players.Add(Demo.TeamT.Players.First(p => p.Equals(pl))); - Demo.TeamT.Players.Remove(pl); - }); + Demo.TeamCT.Players.Add(Demo.TeamT.Players.First(p => p.Equals(pl))); + Demo.TeamT.Players.Remove(pl); } else { if (!Demo.TeamCT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => Demo.TeamCT.Players.Add(pl)); + Demo.TeamCT.Players.Add(pl); } } } @@ -514,17 +504,14 @@ protected void UpdatePlayers() // Check swap if (Demo.TeamCT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(delegate - { - Demo.TeamT.Players.Add(Demo.TeamCT.Players.First(p => p.Equals(pl))); - Demo.TeamCT.Players.Remove(pl); - }); + Demo.TeamT.Players.Add(Demo.TeamCT.Players.First(p => p.Equals(pl))); + Demo.TeamCT.Players.Remove(pl); } else { if (!Demo.TeamT.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(() => Demo.TeamT.Players.Add(pl)); + Demo.TeamT.Players.Add(pl); } } } diff --git a/Services/Concrete/Analyzer/EseaAnalyzer.cs b/Services/Concrete/Analyzer/EseaAnalyzer.cs index 70b77d6b3..f5a17c717 100644 --- a/Services/Concrete/Analyzer/EseaAnalyzer.cs +++ b/Services/Concrete/Analyzer/EseaAnalyzer.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Core.Models; using DemoInfo; using Player = Core.Models.Player; @@ -200,7 +199,7 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) // if the number of rounds played during OT == 2x MR OT detected, the OT is over if (MrOvertime * 2 == RoundCountOvertime) { - Application.Current.Dispatcher.Invoke(() => Demo.Overtimes.Add(CurrentOvertime)); + Demo.Overtimes.Add(CurrentOvertime); CreateNewOvertime(); RoundCountOvertime = 0; } @@ -232,56 +231,53 @@ private void InitPlayers() { if (player.SteamID != 0) { - Application.Current.Dispatcher.Invoke(delegate + Player pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); + if (pl == null) { - Player pl = Demo.Players.FirstOrDefault(p => p.SteamId == player.SteamID); - if (pl == null) + pl = new Player { - pl = new Player - { - SteamId = player.SteamID, - Name = player.Name, - Side = player.Team.ToSide(), - }; - Demo.Players.Add(pl); - } + SteamId = player.SteamID, + Name = player.Name, + Side = player.Team.ToSide(), + }; + Demo.Players.Add(pl); + } - if (pl.Side == Side.CounterTerrorist) + if (pl.Side == Side.CounterTerrorist) + { + pl.TeamName = Demo.TeamCT.Name; + // Check swap + if (Demo.TeamT.Players.Contains(pl)) { - pl.TeamName = Demo.TeamCT.Name; - // Check swap - if (Demo.TeamT.Players.Contains(pl)) - { - Demo.TeamCT.Players.Add(Demo.TeamT.Players.First(p => p.Equals(pl))); - Demo.TeamT.Players.Remove(pl); - } - else + Demo.TeamCT.Players.Add(Demo.TeamT.Players.First(p => p.Equals(pl))); + Demo.TeamT.Players.Remove(pl); + } + else + { + if (!Demo.TeamCT.Players.Contains(pl)) { - if (!Demo.TeamCT.Players.Contains(pl)) - { - Demo.TeamCT.Players.Add(pl); - } + Demo.TeamCT.Players.Add(pl); } } + } - if (pl.Side == Side.Terrorist) + if (pl.Side == Side.Terrorist) + { + pl.TeamName = Demo.TeamT.Name; + // Check swap + if (Demo.TeamCT.Players.Contains(pl)) { - pl.TeamName = Demo.TeamT.Name; - // Check swap - if (Demo.TeamCT.Players.Contains(pl)) - { - Demo.TeamT.Players.Add(Demo.TeamCT.Players.First(p => p.Equals(pl))); - Demo.TeamCT.Players.Remove(pl); - } - else + Demo.TeamT.Players.Add(Demo.TeamCT.Players.First(p => p.Equals(pl))); + Demo.TeamCT.Players.Remove(pl); + } + else + { + if (!Demo.TeamT.Players.Contains(pl)) { - if (!Demo.TeamT.Players.Contains(pl)) - { - Demo.TeamT.Players.Add(pl); - } + Demo.TeamT.Players.Add(pl); } } - }); + } } } } diff --git a/Services/Concrete/Analyzer/ValveAnalyzer.cs b/Services/Concrete/Analyzer/ValveAnalyzer.cs index 5203c0dbc..cd8685817 100644 --- a/Services/Concrete/Analyzer/ValveAnalyzer.cs +++ b/Services/Concrete/Analyzer/ValveAnalyzer.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using System.Windows; using Core.Models; using Core.Models.Events; using DemoInfo; @@ -168,11 +167,8 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) Name = player.Name, Side = player.Team.ToSide(), }; - Application.Current.Dispatcher.Invoke(delegate - { - Demo.Players.Add(pl); - pl.TeamName = pl.Side == Side.CounterTerrorist ? Demo.TeamCT.Name : Demo.TeamT.Name; - }); + Demo.Players.Add(pl); + pl.TeamName = pl.Side == Side.CounterTerrorist ? Demo.TeamCT.Name : Demo.TeamT.Name; } } } @@ -192,7 +188,7 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) if (IsLastRoundHalf) { SwapTeams(); - Application.Current.Dispatcher.Invoke(() => Demo.Rounds.Add(CurrentRound)); + Demo.Rounds.Add(CurrentRound); } if (IsOvertime && IsLastRoundHalf) @@ -215,7 +211,7 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) _isRoundFinal = false; if (IsOvertime) { - Application.Current.Dispatcher.Invoke(() => Demo.Overtimes.Add(CurrentOvertime)); + Demo.Overtimes.Add(CurrentOvertime); IsHalfMatch = !IsHalfMatch; } else @@ -431,11 +427,11 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) { if (Demo.TeamCT.Players.Count > Demo.TeamT.Players.Count) { - Application.Current.Dispatcher.Invoke(() => Demo.TeamT.Players.Add(player)); + Demo.TeamT.Players.Add(player); } else { - Application.Current.Dispatcher.Invoke(() => Demo.TeamCT.Players.Add(player)); + Demo.TeamCT.Players.Add(player); } } } @@ -446,7 +442,7 @@ protected override void HandleRoundStart(object sender, RoundStartedEventArgs e) private void StartMatch() { - Application.Current.Dispatcher.Invoke(() => Demo.Rounds.Clear()); + Demo.Rounds.Clear(); IsMatchStarted = true; if (!string.IsNullOrWhiteSpace(Parser.CTClanName)) @@ -476,21 +472,18 @@ private void StartMatch() }; if (!Demo.Players.Contains(pl)) { - Application.Current.Dispatcher.Invoke(delegate + Demo.Players.Add(pl); + if (pl.Side == Side.CounterTerrorist && !Demo.TeamCT.Players.Contains(pl)) { - Demo.Players.Add(pl); - if (pl.Side == Side.CounterTerrorist && !Demo.TeamCT.Players.Contains(pl)) - { - Demo.TeamCT.Players.Add(pl); - pl.TeamName = Demo.TeamCT.Name; - } - - if (pl.Side == Side.Terrorist && !Demo.TeamT.Players.Contains(pl)) - { - Demo.TeamT.Players.Add(pl); - pl.TeamName = Demo.TeamT.Name; - } - }); + Demo.TeamCT.Players.Add(pl); + pl.TeamName = Demo.TeamCT.Name; + } + + if (pl.Side == Side.Terrorist && !Demo.TeamT.Players.Contains(pl)) + { + Demo.TeamT.Players.Add(pl); + pl.TeamName = Demo.TeamT.Name; + } } } } diff --git a/Services/Design/DemosDesignService.cs b/Services/Design/DemosDesignService.cs index 83246cc12..e07d70424 100644 --- a/Services/Design/DemosDesignService.cs +++ b/Services/Design/DemosDesignService.cs @@ -97,7 +97,6 @@ public Task AnalyzeDemo(Demo demo, CancellationToken token, Action