From 88e56419c9c504da2293a7662ed876f26c27ace2 Mon Sep 17 00:00:00 2001 From: shoaib11120 Date: Mon, 17 Jan 2022 15:44:31 +0530 Subject: [PATCH] Made radar loop and testing path finder --- stardew-access/Game/Radar.cs | 19 ++++++++----------- stardew-access/ModEntry.cs | 30 ++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/stardew-access/Game/Radar.cs b/stardew-access/Game/Radar.cs index 29b907a..ea6d418 100644 --- a/stardew-access/Game/Radar.cs +++ b/stardew-access/Game/Radar.cs @@ -11,9 +11,11 @@ namespace stardew_access.Game private List closed; private List furnitures; public List exclusions; + public bool isRunning; public Radar() { + isRunning = false; closed = new List(); furnitures = new List(); exclusions = new List(); @@ -32,18 +34,18 @@ namespace stardew_access.Game exclusions.Add("flooring"); } - public void run() + public async void run() { - Stopwatch sw = new Stopwatch(); - sw.Start(); + isRunning = true; Vector2 currPosition = Game1.player.getTileLocation(); int limit = 5; closed.Clear(); furnitures.Clear(); findTile(currPosition, currPosition, limit); - sw.Stop(); - MainClass.monitor.Log($"Time taken:{sw.ElapsedMilliseconds}ms", StardewModdingAPI.LogLevel.Debug); + + await Task.Delay(3000); + isRunning = false; } public void findTile(Vector2 position, Vector2 center, int limit) @@ -78,7 +80,7 @@ namespace stardew_access.Game string? obj = ReadTile.getObjectNameAtTile((int)position.X, (int)position.Y); StardewValley.Object @object = Game1.currentLocation.getObjectAtTile((int)position.X, (int)position.Y); - if (@object is Furniture) + if (@object is Furniture && !exclusions.Contains("furniture")) { if (!furnitures.Contains(@object as Furniture)) { @@ -149,11 +151,6 @@ namespace stardew_access.Game Game1.currentLocation.localSoundAt("sa_poi", position); MainClass.monitor.Log($"LEAF:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug); } - else if(!exclusions.Contains(terrain.ToLower())) - { - Game1.currentLocation.localSoundAt("sa_poi", position); - MainClass.monitor.Log($"TERRAIN:{tr}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug); - } } } } diff --git a/stardew-access/ModEntry.cs b/stardew-access/ModEntry.cs index f65a959..4a6d6ab 100644 --- a/stardew-access/ModEntry.cs +++ b/stardew-access/ModEntry.cs @@ -17,11 +17,11 @@ namespace stardew_access public class MainClass : Mod { private Harmony? harmony; - private static bool readTile = true, snapMouse = true, isNarratingHudMessage = false; + private static bool readTile = true, snapMouse = true, isNarratingHudMessage = false, radar = false; public static IMonitor? monitor; AutoHotkeyEngine ahk; public static string hudMessageQueryKey = ""; - public static Radar radar; + public static Radar radarFeature; /********* ** Public methods @@ -55,7 +55,7 @@ namespace stardew_access harmony = new Harmony(ModManifest.UniqueID); // Init harmony - radar = new Radar(); + radarFeature = new Radar(); #endregion @@ -236,6 +236,20 @@ namespace stardew_access monitor.Log("Snap Mouse is " + (snapMouse ? "on" : "off"), LogLevel.Info); }); + helper.ConsoleCommands.Add("radar", "Toggle radar feature", (string arg1, string[] arg2) => + { + radar = !radar; + + monitor.Log("Radar " + (snapMouse ? "on" : "off"), LogLevel.Info); + }); + + helper.ConsoleCommands.Add("r_in", "Include an object to radar", (string arg1, string[] arg2) => + { + radar = !radar; + + monitor.Log("Radar " + (snapMouse ? "on" : "off"), LogLevel.Info); + }); + helper.ConsoleCommands.Add("ref_sr", "Refresh screen reader", (string arg1, string[] arg2) => { ScreenReader.initializeScreenReader(); @@ -272,7 +286,7 @@ namespace stardew_access collidingCueDef.instanceLimit = 1; collidingCueDef.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest; SoundEffect collidingAudio; - string collidingFilePath = Path.Combine(Path.Combine(this.Helper.DirectoryPath), "sounds/colliding.ogg"); + string collidingFilePath = Path.Combine(Path.Combine(this.Helper.DirectoryPath), "sounds/colliding.wav"); using (FileStream stream = new(collidingFilePath, FileMode.Open)) { collidingAudio = SoundEffect.FromStream(stream); @@ -284,7 +298,7 @@ namespace stardew_access CueDefinition poiCueDef = new CueDefinition(); poiCueDef.name = "sa_poi"; SoundEffect poiAudio; - string poiFilePath = Path.Combine(Path.Combine(this.Helper.DirectoryPath), "sounds/sound1.ogg"); + string poiFilePath = Path.Combine(Path.Combine(this.Helper.DirectoryPath), "sounds/sound1.wav"); using (FileStream stream = new(poiFilePath, FileMode.Open)) { poiAudio = SoundEffect.FromStream(stream); @@ -321,6 +335,9 @@ namespace stardew_access if(!ReadTile.isReadingTile && readTile) ReadTile.run(); + if(!radarFeature.isRunning && radar) + radarFeature.run(); + if (!isNarratingHudMessage) { narrateHudMessages(); @@ -369,7 +386,8 @@ namespace stardew_access // Manual read tile if (Equals(e.Button, SButton.B)) { - radar.run(); + Game1.player.controller = new PathFindController(Game1.player, Game1.currentLocation, new Point(49,13), 2); + monitor.Log($"{Game1.player.controller.pathToEndPoint==null}", LogLevel.Debug); // true if path not found } }