Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorIsBlue committed Aug 13, 2024
1 parent 99919a9 commit 3454e98
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 22 deletions.
37 changes: 21 additions & 16 deletions Aimmy2/AILogic/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class AIManager : IDisposable
private Thread? _aiLoopThread;
private bool _isAiLoopRunning;

//fps - copilot, rolling average calculation
//fps - copilot, rolling average calculation
private const int MAXSAMPLES = 100;
private double[] frameTimes = new double[MAXSAMPLES];
private int frameTimeIndex = 0;
Expand All @@ -67,7 +67,7 @@ internal class AIManager : IDisposable

private int PrevY = 0;

// private int IndependentMousePress = 0;
// private int IndependentMousePress = 0;

private int iterationCount = 0;
private long totalTime = 0;
Expand Down Expand Up @@ -131,7 +131,7 @@ private void InitializeDirect3D()

// Get DXGI output
using var dxgiDevice = _device.QueryInterface<IDXGIDevice>();
using var adapter = dxgiDevice.GetAdapter();
using var adapter = dxgiDevice.GetAdapter();
if (adapter.EnumOutputs(0, out var outputTemp) != Result.Ok)
{
throw new InvalidOperationException("Failed to enumerate outputs.");
Expand Down Expand Up @@ -178,8 +178,9 @@ private async Task LoadModelAsync(SessionOptions sessionOptions, string modelPat
try
{
if (useCUDA) { sessionOptions.AppendExecutionProvider_CUDA(0); } // Using GPU 0, task manager will tell you which GPU is being used in the "Performance" tab
else {
sessionOptions.AppendExecutionProvider_Tensorrt();
else
{
sessionOptions.AppendExecutionProvider_Tensorrt();
await Application.Current.Dispatcher.BeginInvoke(new Action(() => new NoticeBar("Starting model with tensorrt...", 2000)));
}

Expand Down Expand Up @@ -253,7 +254,7 @@ private async void AiLoop()
if (Dictionary.toggleState["Show FPS"])
{
double frameTime = stopwatch.Elapsed.TotalSeconds;
UpdateFps(frameTime);
UpdateFps(frameTime);
if (frameTimeIndex % 10 == 0)
{
Application.Current.Dispatcher.Invoke(() =>
Expand All @@ -267,13 +268,16 @@ private async void AiLoop()

UpdateFOV();

if (iterationCount == 1000 && Dictionary.toggleState["Debug Mode"])
if (iterationCount == 1000)
{
double averageTime = totalTime / 1000.0;
Debug.WriteLine($"Average loop iteration time: {averageTime} ms");
MessageBox.Show($"Average loop iteration time: {averageTime} ms", "Share this iteration time on our discord!");
totalTime = 0;
iterationCount = 0;
if (Dictionary.toggleState["Debug Mode"])
{
double averageTime = totalTime / 1000.0;
Debug.WriteLine($"Average loop iteration time: {averageTime} ms");
MessageBox.Show($"Average loop iteration time: {averageTime} ms", "Share this iteration time on our discord!");
totalTime = 0;
iterationCount = 0;
}
}

if (ShouldProcess())
Expand Down Expand Up @@ -474,7 +478,7 @@ private void HandleAim(Prediction closestPrediction)

private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction closestPrediction, int detectedX, int detectedY)
{
var predictionMethod = Dictionary.dropdownState["Prediction Method"];
var predictionMethod = Dictionary.dropdownState["Prediction Method"];
DateTime currentTime = DateTime.UtcNow;

switch (predictionMethod)
Expand Down Expand Up @@ -702,7 +706,7 @@ private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction clo

_deviceContext.CopySubresourceRegion(_desktopImage, 0, 0, 0, 0, screenTexture, 0, box);

if(_desktopImage == null) return null;
if (_desktopImage == null) return null;
var dataBox = _deviceContext.Map(_desktopImage, 0, MapMode.Read, Vortice.Direct3D11.MapFlags.None);

if (_screenCaptureBitmap == null) return null;
Expand Down Expand Up @@ -753,13 +757,14 @@ private void HandlePredictions(KalmanPrediction kalmanPrediction, Prediction clo
// }

// _graphics?.CopyFromScreen(detectionBox.Left, detectionBox.Top, 0, 0, detectionBox.Size, CopyPixelOperation.SourceCopy);

// return _screenCaptureBitmap;
//}

private void SaveFrame(Bitmap frame, Prediction? DoLabel = null)
{
if (!Dictionary.toggleState["Collect Data While Playing"] || Dictionary.toggleState["Constant AI Tracking"]) return;
if (!Dictionary.toggleState["Collect Data While Playing"]) return;
if (Dictionary.toggleState["Constant AI Tracking"]) return;
if ((DateTime.Now - lastSavedTime).TotalMilliseconds < 500) return;

lastSavedTime = DateTime.Now;
Expand Down
4 changes: 2 additions & 2 deletions Aimmy2/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
FillRule="NonZero" />
</Path.Data>
</Path>
<Label Content="Aimmy"
<Label Content="Aimmy CUDA"
HorizontalAlignment="Left"
Margin="45,0,0,0"
VerticalAlignment="Center"
Expand Down Expand Up @@ -511,7 +511,7 @@
FontSize="15" />
<Label x:Name="AboutDesc"
Foreground="White"
Content="v2.1.5"
Content="v2.1.7"
FontFamily="{StaticResource Atkinson Hyperlegible}"
VerticalContentAlignment="Center"
Padding="0,0,0,0"
Expand Down
14 changes: 11 additions & 3 deletions Aimmy2/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,17 @@ private void LoadAntiRecoilConfig(string path = "bin\\anti_recoil_configs\\Defau

private void OpenFolderB_Click(object sender, RoutedEventArgs e)
{
if (sender is Button clickedButton)
if (sender is Button clickedButton && clickedButton.Tag != null)
{
Process.Start("explorer.exe", Directory.GetCurrentDirectory() + "bin\\" + clickedButton.Tag.ToString());
string folderPath = Path.Combine(Directory.GetCurrentDirectory(), "bin", clickedButton.Tag.ToString());
if (Directory.Exists(folderPath))
{
Process.Start("explorer.exe", folderPath);
}
else
{
MessageBox.Show($"The folder '{folderPath}' does not exist.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}

Expand Down Expand Up @@ -1195,7 +1203,7 @@ private static void ShowHideDPWindow()
private async void CheckForUpdates_Click(object sender, RoutedEventArgs e)
{
UpdateManager updateManager = new UpdateManager();
await updateManager.CheckForUpdate("v2.2.0");
await updateManager.CheckForUpdate("v2.1.7");
updateManager.Dispose();
}

Expand Down
2 changes: 1 addition & 1 deletion Aimmy2/Other/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public UpdateManager()
public async Task CheckForUpdate(string currentVersion)
{
GithubManager githubManager = new();
var (latestVersion, latestZipUrl) = await githubManager.GetLatestReleaseInfo("Babyhamsta", "Aimmy");
var (latestVersion, latestZipUrl) = await githubManager.GetLatestReleaseInfo("TaylorIsBlue", "Aimmy-CUDA");

if (string.IsNullOrEmpty(latestVersion) || string.IsNullOrEmpty(latestZipUrl))
{
Expand Down

0 comments on commit 3454e98

Please sign in to comment.