private void PaintBuff(BuffPaintInfo info, float x, float y, float w, float h, IBrush brush) { if (Opacity == 0) { return; } //Draw backbround bar BackgroundBrush.Opacity = Opacity; BackgroundBrush.DrawRectangle(x, y, w, h); //Draw cooldown Bar brush.Opacity = Opacity; brush.DrawRectangle(x, y, (float)(w * info.TimeLeft / (info.TimeLeft + info.Elapsed)), h); //Draw time left number if (ShowTimeLeftNumbers) { var text = ""; if (info.TimeLeft > 1) { text = info.TimeLeft.ToString("F0", CultureInfo.InvariantCulture); } else { text = info.TimeLeft.ToString("F1", CultureInfo.InvariantCulture); } var layout = TimeLeftFont.GetTextLayout(text); TimeLeftFont.Opacity = Opacity; TimeLeftFont.DrawText(layout, x + (w - (float)Math.Ceiling(layout.Metrics.Width)) / 2.0f, y + (h - layout.Metrics.Height) / 2); } }
} //end PaintTopInGame public void AfterCollect() { if (!Hud.Game.IsInGame) { return; } var toRemove = Snapshots.Where(pair => !Hud.Game.Players.Any(p => p.HeroId == pair.Key)).Select(pair => pair.Key).ToList(); foreach (var key in toRemove) { Snapshots.Remove(key); } foreach (IPlayer player in Hud.Game.Players.Where(p => p.HasValidActor && p.SnoArea == Hud.Game.Me.SnoArea && p.CoordinateKnown)) { ProcRuleCalculator.CalculatePaintInfo(player); //check for procs if (ProcRuleCalculator.PaintInfoList.Count > 0) //proc detected { BuffPaintInfo info = ProcRuleCalculator.PaintInfoList[0]; int finishtick = Hud.Game.CurrentGameTick + (int)(info.TimeLeft * 60d); int starttick = Hud.Game.CurrentGameTick - (int)(info.Elapsed * 60d); double duration = info.TimeLeft + info.Elapsed; bool play = false; ProcInfo snapshot; if (!Snapshots.TryGetValue(player.HeroId, out snapshot)) { play = true; snapshot = new ProcInfo() { PlayerName = player.BattleTagAbovePortrait, HeroId = player.HeroId, PlayerClass = player.HeroClassDefinition.HeroClass, StartTick = starttick, FinishTick = finishtick, //Hud.Game.CurrentRealTimeMilliseconds + (long)(info.TimeLeft*1000), //long endtime Duration = duration, Texture = info.Texture, SoundPlayedTick = Hud.Game.CurrentGameTick }; Snapshots.Add(player.HeroId, snapshot); } else if (Math.Abs(finishtick - snapshot.FinishTick) > 2) //different end time //is the old record expired? //if (snapshot.FinishTick < Hud.Game.CurrentGameTick) { { if (starttick > snapshot.SoundPlayedTick) { play = true; snapshot.SoundPlayedTick = Hud.Game.CurrentGameTick; } snapshot.StartTick = starttick; snapshot.FinishTick = finishtick; snapshot.Duration = duration; snapshot.Count += 1; snapshot.Texture = info.Texture; //if (snapshot.PlayerName != player.BattleTagAbovePortrait) { //that is a desync, need to resync...would this ever happen? //} Snapshots[player.HeroId] = snapshot; } if (play && PlaySounds) { ThreadPool.QueueUserWorkItem(state => { try { if (player.IsMe) { if (SoundYou != null) { SoundYou.Play(); } else { Hud.Sound.Speak(SayYouHaveProcced); } } else { Hud.Sound.Speak(player.BattleTagAbovePortrait + SayHasProcced); } } catch (Exception) {} }); } } else { //no proc detected, but double check that the proc is not supposed to still be running (there may be an issue with proc buffs in that they momentarily register as inactive) ProcInfo snapshot; if (Snapshots.TryGetValue(player.HeroId, out snapshot)) { double timeLeft = (double)(snapshot.FinishTick - Hud.Game.CurrentGameTick) / 60d; IQuest riftQuest = Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == Hud.Sno.SnoQuests.GreaterNephalemRift_382695.Sno); if (timeLeft < 0 || //expired snapshot timeLeft > snapshot.Duration || //this happens when data lingers between games (riftQuest != null && (snapshot.FinishTick - (int)(snapshot.Duration * 60)) < riftQuest.CreatedOn) || //if the proc started before the GR was opened player.IsDeadSafeCheck) //player.HeadStone != null { Snapshots[player.HeroId].FinishTick = 0; } } } } }