-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
51 lines (40 loc) · 1.34 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using CSGO_GSI.Models;
using CSGO_GSI.Services;
short lastFlash = 0;
DateTime startTime = DateTime.Now;
List<short> flashTicks = new List<short>(5 * 128);
using var gameStateListener = new GameStateListener();
gameStateListener.GameEvent += OnClientTick;
gameStateListener.Start();
void OnClientTick(GameStateResponse obj, string body)
{
var flashed = obj.Player.State.Flashed;
if (flashed > 0 && lastFlash == 0)
{
flashTicks.Clear();
flashTicks.Add(flashed);
startTime = DateTime.Now;
}
if (flashed > 0)
{
flashTicks.Add(flashed);
}
if (flashed == 0 && lastFlash > 0)
{
// on end
var time = DateTime.Now - startTime;
var max = flashTicks.Max();
var maxTicks = flashTicks.Count(x => x == max);
var frameTime = time.TotalMilliseconds / flashTicks.Count;
var maxTime = TimeSpan.FromMilliseconds(maxTicks * frameTime);
var avg = flashTicks.Average(x => x);
var avgTicks = flashTicks.Count(x => x >= avg);
var avgTime = TimeSpan.FromMilliseconds(avgTicks * frameTime);
Console.WriteLine($"Total Flash Duration: {time.TotalSeconds:F2} Seconds\n" +
$"Peak Flash Strength: {max / 255.0 * 100.0:F2}%\n" +
$"Time At Peak Flash: {maxTime.TotalSeconds:F2} Seconds\n" +
$"Average Flash Strength: {avg / 255.0 * 100.0:F2}%\n" +
$"Time At Or Above Average Flash: {avgTime.TotalSeconds:F2} Seconds\n");
}
lastFlash = flashed;
}