Read tile pauses while auto walking

master
Mohammad Shoaib 2022-05-16 21:07:08 +05:30
parent fcd6c8ecb3
commit f85192178f
3 changed files with 23 additions and 5 deletions

View File

@ -34,15 +34,31 @@ namespace stardew_access.Features
}
/// <summary>
/// Pauses the read tile for the provided time.
/// Pauses the feature for the provided time.
/// </summary>
/// <param name="time">The amount of time we want to pause the execution (in ms).<br/>Default is 2500 (2.5s).</param>
public void pause(int time = 2500)
public void pauseUntil(int time = 2500)
{
this.shouldPause = true;
Task.Delay(time).ContinueWith(_ => { this.shouldPause = false; });
}
/// <summary>
/// Pauses the feature
/// </summary>
public void pause()
{
this.shouldPause = true;
}
/// <summary>
/// Resumes the feature
/// </summary>
public void resume()
{
this.shouldPause = false;
}
public void run(bool manuallyTriggered = false, bool playersPosition = false)
{
try

View File

@ -148,6 +148,7 @@ namespace stardew_access.Features
Game1.player.controller = controller;
this.isAutoWalking = true;
this.finalTile = this.GetViewingTile();
MainClass.ReadTileFeature.pause();
MainClass.ScreenReader.Say($"Moving to {this.finalTile.X}x {this.finalTile.Y}y", true);
}
else
@ -165,6 +166,7 @@ namespace stardew_access.Features
this.finalTile = Vector2.Zero;
this.isAutoWalking = false;
Game1.player.controller = null;
MainClass.ReadTileFeature.resume();
if (wasForced)
MainClass.ScreenReader.Say("Stopped moving", true);
}

View File

@ -32,7 +32,7 @@ namespace stardew_access.Features
{
MainClass.ScreenReader.Say(toSpeak, true);
// Pause the read tile feature to prevent interruption in warning message
MainClass.ReadTileFeature.pause();
MainClass.ReadTileFeature.pauseUntil();
}
prevHour = hours;
@ -50,7 +50,7 @@ namespace stardew_access.Features
{
MainClass.ScreenReader.Say(toSpeak, true);
// Pause the read tile feature to prevent interruption in warning message
MainClass.ReadTileFeature.pause();
MainClass.ReadTileFeature.pauseUntil();
}
prevStamina = stamina;
@ -68,7 +68,7 @@ namespace stardew_access.Features
{
MainClass.ScreenReader.Say(toSpeak, true);
// Pause the read tile feature to prevent interruption in warning message
MainClass.ReadTileFeature.pause();
MainClass.ReadTileFeature.pauseUntil();
}
prevHealth = health;