Added range and delay customization to radar feature

master
shoaib11120 2022-01-22 12:31:38 +05:30
parent aca9888a80
commit eb61d2d109
2 changed files with 79 additions and 8 deletions

View File

@ -50,6 +50,73 @@ namespace stardew_access
MainClass.monitor.Log("Focus mode is " + (focus? "on" : "off"), LogLevel.Info); 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 #region Exclusions
helper.ConsoleCommands.Add("readd", "Add an object key to the exclusions list of radar feature.", (string commmand, string[] args) => 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
} }
} }
} }

View File

@ -47,9 +47,13 @@ namespace stardew_access.Game
public List<string> focus; public List<string> focus;
public bool isRunning; public bool isRunning;
public bool radarFocus = false; public bool radarFocus = false;
public int delay, range;
public Radar() public Radar()
{ {
delay = 3000;
range = 5;
isRunning = false; isRunning = false;
closed = new List<Vector2>(); closed = new List<Vector2>();
furnitures = new List<Furniture>(); furnitures = new List<Furniture>();
@ -91,17 +95,16 @@ namespace stardew_access.Game
isRunning = true; isRunning = true;
Vector2 currPosition = Game1.player.getTileLocation(); Vector2 currPosition = Game1.player.getTileLocation();
int limit = 5;
closed.Clear(); closed.Clear();
furnitures.Clear(); furnitures.Clear();
npcs.Clear(); npcs.Clear();
FindTile(currPosition, currPosition, limit); FindTile(currPosition, currPosition, range);
if(MainClass.radarDebug) if(MainClass.radarDebug)
MainClass.monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug); MainClass.monitor.Log($"\nRead Tile stopped\n\n", StardewModdingAPI.LogLevel.Debug);
await Task.Delay(3000); await Task.Delay(delay);
isRunning = false; isRunning = false;
} }
@ -155,7 +158,7 @@ namespace stardew_access.Game
// Check for water // Check for water
else if (Game1.currentLocation.isWaterTile((int)position.X, (int)position.Y)) else if (Game1.currentLocation.isWaterTile((int)position.X, (int)position.Y))
{ {
PlaySoundAt(position, null, CATEGORY.WaterTiles); PlaySoundAt(position, "water", CATEGORY.WaterTiles);
} }
// Check for objects // Check for objects
else if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y)) 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()))) if (!radarFocus && (exclusions.Contains(category.ToString()) || exclusions.Contains(searchQuery.ToLower().Trim())))
return; return;
if (radarFocus && (!focus.Contains(category.ToString())) && !focus.Contains(searchQuery.ToLower().Trim())) if (radarFocus && !(focus.Contains(category.ToString())) || focus.Contains(searchQuery.ToLower().Trim()))
return; return;
if (MainClass.radarDebug) if (MainClass.radarDebug)
@ -323,15 +326,15 @@ namespace stardew_access.Game
{ {
string soundName = $"_{post}"; string soundName = $"_{post}";
if(MainClass.radarStereoSound) if(!MainClass.radarStereoSound)
soundName = $"_mono{soundName}"; soundName = $"_mono{soundName}";
if(category == CATEGORY.Farmers) // Villagers and farmers if(category == CATEGORY.Farmers) // Villagers and farmers
soundName = $"npc{soundName}"; soundName = $"npc{soundName}";
if (category == CATEGORY.FarmAnimals) // Farm Animals else if (category == CATEGORY.FarmAnimals) // Farm Animals
soundName = $"npc{soundName}"; soundName = $"npc{soundName}";
else if(category == CATEGORY.NPCs) // Other npcs, also includes enemies else if(category == CATEGORY.NPCs) // Other npcs, also includes enemies
soundName = $"obj{soundName}"; soundName = $"npc{soundName}";
else if(category == CATEGORY.WaterTiles) // Water tiles else if(category == CATEGORY.WaterTiles) // Water tiles
soundName = $"obj{soundName}"; soundName = $"obj{soundName}";
else if(category == CATEGORY.Furnitures) // Furnitures else if(category == CATEGORY.Furnitures) // Furnitures