Added range and delay customization to radar feature
This commit is contained in:
		| @@ -50,6 +50,73 @@ namespace stardew_access | ||||
|                 MainClass.monitor.Log("Focus mode is " + (focus? "on" : "off"), LogLevel.Info); | ||||
|             }); | ||||
|  | ||||
|             helper.ConsoleCommands.Add("rdelay", "Set the delay of radar feature in milliseconds.", (string commmand, string[] args) => | ||||
|             { | ||||
|                 string? delayInString = null; | ||||
|  | ||||
|                 if(args.Length > 0) | ||||
|                 { | ||||
|                     delayInString = args[0]; | ||||
|  | ||||
|                     int delay; | ||||
|  | ||||
|                     bool isParsable = int.TryParse(delayInString, out delay); | ||||
|  | ||||
|                     if (isParsable) | ||||
|                     { | ||||
|                         MainClass.radarFeature.delay = delay; | ||||
|                         if(delay>=1000) | ||||
|                             MainClass.monitor.Log($"Delay set to {MainClass.radarFeature.delay} milliseconds.", LogLevel.Info); | ||||
|                         else | ||||
|                             MainClass.monitor.Log($"Delay should be atleast 1 second or 1000 millisecond long.", LogLevel.Info); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         MainClass.monitor.Log("Invalid delay amount, it can only be in numeric form.", LogLevel.Info); | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     MainClass.monitor.Log("Enter the delay amount (in milliseconds)!", LogLevel.Info); | ||||
|                 } | ||||
|  | ||||
|             }); | ||||
|  | ||||
|             helper.ConsoleCommands.Add("rrange", "Set the delay of radar feature in milliseconds.", (string commmand, string[] args) => | ||||
|             { | ||||
|                 string? rangeInString = null; | ||||
|  | ||||
|                 if (args.Length > 0) | ||||
|                 { | ||||
|                     rangeInString = args[0]; | ||||
|  | ||||
|                     int range; | ||||
|  | ||||
|                     bool isParsable = int.TryParse(rangeInString, out range); | ||||
|  | ||||
|                     if (isParsable) | ||||
|                     { | ||||
|                         MainClass.radarFeature.range = range; | ||||
|                         if (range >= 2 && range<=10) | ||||
|                             MainClass.monitor.Log($"Range set to {MainClass.radarFeature.range}.", LogLevel.Info); | ||||
|                         else | ||||
|                             MainClass.monitor.Log($"Range should be atleast 2 and maximum 10.", LogLevel.Info); | ||||
|                     } | ||||
|                     else | ||||
|                     { | ||||
|                         MainClass.monitor.Log("Invalid range amount, it can only be in numeric form.", LogLevel.Info); | ||||
|                     } | ||||
|  | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     MainClass.monitor.Log("Enter the range amount!", LogLevel.Info); | ||||
|                 } | ||||
|  | ||||
|             }); | ||||
|  | ||||
|  | ||||
|             #region Exclusions | ||||
|             helper.ConsoleCommands.Add("readd", "Add an object key to the exclusions list of radar feature.", (string commmand, string[] args) => | ||||
|                 { | ||||
| @@ -191,3 +258,4 @@ namespace stardew_access | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -47,9 +47,13 @@ namespace stardew_access.Game | ||||
|         public List<string> focus; | ||||
|         public bool isRunning; | ||||
|         public bool radarFocus = false; | ||||
|         public int delay, range; | ||||
|  | ||||
|         public Radar() | ||||
|         { | ||||
|             delay = 3000; | ||||
|             range = 5; | ||||
|  | ||||
|             isRunning = false; | ||||
|             closed = new List<Vector2>(); | ||||
|             furnitures = new List<Furniture>(); | ||||
| @@ -91,17 +95,16 @@ namespace stardew_access.Game | ||||
|  | ||||
|             isRunning = true; | ||||
|             Vector2 currPosition = Game1.player.getTileLocation(); | ||||
|             int limit = 5; | ||||
|  | ||||
|             closed.Clear(); | ||||
|             furnitures.Clear(); | ||||
|             npcs.Clear(); | ||||
|             FindTile(currPosition, currPosition, limit); | ||||
|             FindTile(currPosition, currPosition, range); | ||||
|  | ||||
|             if(MainClass.radarDebug) | ||||
|                 MainClass.monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug); | ||||
|  | ||||
|             await Task.Delay(3000); | ||||
|             await Task.Delay(delay); | ||||
|             isRunning = false; | ||||
|         } | ||||
|  | ||||
| @@ -155,7 +158,7 @@ namespace stardew_access.Game | ||||
|                 // Check for water | ||||
|                 else if (Game1.currentLocation.isWaterTile((int)position.X, (int)position.Y)) | ||||
|                 { | ||||
|                     PlaySoundAt(position, null, CATEGORY.WaterTiles); | ||||
|                     PlaySoundAt(position, "water", CATEGORY.WaterTiles); | ||||
|                 } | ||||
|                 // Check for objects | ||||
|                 else if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y)) | ||||
| @@ -285,7 +288,7 @@ namespace stardew_access.Game | ||||
|             if (!radarFocus && (exclusions.Contains(category.ToString()) || exclusions.Contains(searchQuery.ToLower().Trim()))) | ||||
|                 return; | ||||
|  | ||||
|             if (radarFocus && (!focus.Contains(category.ToString())) && !focus.Contains(searchQuery.ToLower().Trim())) | ||||
|             if (radarFocus && !(focus.Contains(category.ToString())) || focus.Contains(searchQuery.ToLower().Trim())) | ||||
|                 return; | ||||
|  | ||||
|             if (MainClass.radarDebug) | ||||
| @@ -323,15 +326,15 @@ namespace stardew_access.Game | ||||
|         { | ||||
|             string soundName = $"_{post}"; | ||||
|  | ||||
|             if(MainClass.radarStereoSound) | ||||
|             if(!MainClass.radarStereoSound) | ||||
|                 soundName = $"_mono{soundName}"; | ||||
|  | ||||
|             if(category == CATEGORY.Farmers) // Villagers and farmers | ||||
|                 soundName = $"npc{soundName}"; | ||||
|             if (category == CATEGORY.FarmAnimals) // Farm Animals | ||||
|             else if (category == CATEGORY.FarmAnimals) // Farm Animals | ||||
|                 soundName = $"npc{soundName}"; | ||||
|             else if(category == CATEGORY.NPCs) // Other npcs, also includes enemies | ||||
|                 soundName = $"obj{soundName}"; | ||||
|                 soundName = $"npc{soundName}"; | ||||
|             else if(category == CATEGORY.WaterTiles) // Water tiles | ||||
|                 soundName = $"obj{soundName}"; | ||||
|             else if(category == CATEGORY.Furnitures) // Furnitures | ||||
|   | ||||
		Reference in New Issue
	
	Block a user