Player stops auto walking if WASD is pressed
parent
c8b274347e
commit
cb49832b5a
|
@ -20,9 +20,10 @@ namespace stardew_access.Features
|
||||||
private Vector2 relativeOffsetLockPosition = Vector2.Zero;
|
private Vector2 relativeOffsetLockPosition = Vector2.Zero;
|
||||||
private Boolean relativeOffsetLock = false;
|
private Boolean relativeOffsetLock = false;
|
||||||
private Vector2 prevPlayerPosition = Vector2.Zero, prevFacing = Vector2.Zero;
|
private Vector2 prevPlayerPosition = Vector2.Zero, prevFacing = Vector2.Zero;
|
||||||
private Boolean isAutoWalking = false;
|
|
||||||
private Vector2 finalTile = Vector2.Zero;
|
private Vector2 finalTile = Vector2.Zero;
|
||||||
|
|
||||||
|
public Boolean isAutoWalking = false;
|
||||||
|
|
||||||
private Vector2 PlayerFacingVector
|
private Vector2 PlayerFacingVector
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -132,6 +133,12 @@ namespace stardew_access.Features
|
||||||
this.cursorMoveInput(new Vector2(-Game1.tileSize, 0));
|
this.cursorMoveInput(new Vector2(-Game1.tileSize, 0));
|
||||||
}
|
}
|
||||||
else if (MainClass.Config.AutoWalkToTile.JustPressed() && StardewModdingAPI.Context.IsPlayerFree)
|
else if (MainClass.Config.AutoWalkToTile.JustPressed() && StardewModdingAPI.Context.IsPlayerFree)
|
||||||
|
{
|
||||||
|
this.startAutoWalking();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startAutoWalking()
|
||||||
{
|
{
|
||||||
PathFindController controller = new PathFindController(Game1.player, Game1.currentLocation, this.GetViewingTile().ToPoint(), Game1.player.FacingDirection);
|
PathFindController controller = new PathFindController(Game1.player, Game1.currentLocation, this.GetViewingTile().ToPoint(), Game1.player.FacingDirection);
|
||||||
controller.allowPlayerPathingInEvent = true;
|
controller.allowPlayerPathingInEvent = true;
|
||||||
|
@ -147,6 +154,18 @@ namespace stardew_access.Features
|
||||||
MainClass.ScreenReader.Say($"Cannot move to {this.finalTile.X}x {this.finalTile.Y}y", true);
|
MainClass.ScreenReader.Say($"Cannot move to {this.finalTile.X}x {this.finalTile.Y}y", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stop the auto walk controller and reset variables
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wasForced">Narrates a message if set to true.</param>
|
||||||
|
public void stopAutoWalking(bool wasForced = false)
|
||||||
|
{
|
||||||
|
this.finalTile = Vector2.Zero;
|
||||||
|
this.isAutoWalking = false;
|
||||||
|
Game1.player.controller = null;
|
||||||
|
if (wasForced)
|
||||||
|
MainClass.ScreenReader.Say("Stopped moving", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cursorMoveInput(Vector2 delta, Boolean precise = false)
|
private void cursorMoveInput(Vector2 delta, Boolean precise = false)
|
||||||
|
@ -219,11 +238,13 @@ namespace stardew_access.Features
|
||||||
if (MainClass.Config.SnapMouse)
|
if (MainClass.Config.SnapMouse)
|
||||||
this.SnapMouseToPlayer();
|
this.SnapMouseToPlayer();
|
||||||
|
|
||||||
if (this.isAutoWalking && this.finalTile != Vector2.Zero && this.finalTile == CurrentPlayer.Position)
|
if (this.isAutoWalking)
|
||||||
|
{
|
||||||
|
if (this.finalTile != Vector2.Zero && this.finalTile == CurrentPlayer.Position)
|
||||||
{
|
{
|
||||||
MainClass.ScreenReader.Say("Reached destination", true);
|
MainClass.ScreenReader.Say("Reached destination", true);
|
||||||
this.finalTile = Vector2.Zero;
|
this.stopAutoWalking();
|
||||||
this.isAutoWalking = false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,6 +226,16 @@ namespace stardew_access
|
||||||
if (!Context.IsPlayerFree)
|
if (!Context.IsPlayerFree)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Stops the auto walk controller if any movement key(WASD) is pressed
|
||||||
|
if (TileViewerFeature.isAutoWalking &&
|
||||||
|
(e.Button.Equals(SButtonExtensions.ToSButton(Game1.options.moveUpButton[0]))
|
||||||
|
|| e.Button.Equals(SButtonExtensions.ToSButton(Game1.options.moveDownButton[0]))
|
||||||
|
|| e.Button.Equals(SButtonExtensions.ToSButton(Game1.options.moveLeftButton[0]))
|
||||||
|
|| e.Button.Equals(SButtonExtensions.ToSButton(Game1.options.moveRightButton[0]))))
|
||||||
|
{
|
||||||
|
TileViewerFeature.stopAutoWalking(wasForced: true);
|
||||||
|
}
|
||||||
|
|
||||||
// Narrate Current Location
|
// Narrate Current Location
|
||||||
if (Config.LocationKey.JustPressed())
|
if (Config.LocationKey.JustPressed())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue