Added other things to the radar

master
shoaib11120 2022-01-19 12:26:13 +05:30
parent 88e56419c9
commit 6c8eddd08b
3 changed files with 129 additions and 82 deletions

View File

@ -10,6 +10,7 @@ namespace stardew_access.Game
{ {
private List<Vector2> closed; private List<Vector2> closed;
private List<Furniture> furnitures; private List<Furniture> furnitures;
private List<NPC> npcs;
public List<string> exclusions; public List<string> exclusions;
public bool isRunning; public bool isRunning;
@ -18,6 +19,7 @@ namespace stardew_access.Game
isRunning = false; isRunning = false;
closed = new List<Vector2>(); closed = new List<Vector2>();
furnitures = new List<Furniture>(); furnitures = new List<Furniture>();
npcs = new List<NPC>();
exclusions = new List<string>(); exclusions = new List<string>();
exclusions.Add("stone"); exclusions.Add("stone");
@ -32,6 +34,8 @@ namespace stardew_access.Game
exclusions.Add("grass"); exclusions.Add("grass");
exclusions.Add("tree"); exclusions.Add("tree");
exclusions.Add("flooring"); exclusions.Add("flooring");
exclusions.Add("water");
exclusions.Add("door");
} }
public async void run() public async void run()
@ -42,6 +46,7 @@ namespace stardew_access.Game
closed.Clear(); closed.Clear();
furnitures.Clear(); furnitures.Clear();
npcs.Clear();
findTile(currPosition, currPosition, limit); findTile(currPosition, currPosition, limit);
await Task.Delay(3000); await Task.Delay(3000);
@ -60,10 +65,10 @@ namespace stardew_access.Game
closed.Add(position); closed.Add(position);
checkTile(position); checkTile(position);
Vector2 northPosition = new Vector2(position.X, position.Y-1); Vector2 northPosition = new(position.X, position.Y-1);
Vector2 eastPosition = new Vector2(position.X+1, position.Y); Vector2 eastPosition = new(position.X+1, position.Y);
Vector2 westPosition = new Vector2(position.X-1, position.Y); Vector2 westPosition = new(position.X-1, position.Y);
Vector2 southPosition = new Vector2(position.X, position.Y+1); Vector2 southPosition = new(position.X, position.Y+1);
findTile(northPosition, center, limit); findTile(northPosition, center, limit);
findTile(eastPosition, center, limit); findTile(eastPosition, center, limit);
@ -75,84 +80,120 @@ namespace stardew_access.Game
{ {
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict; Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y)) // Check for npcs
if (Game1.currentLocation.isCharacterAtTile(position) != null && !exclusions.Contains("npc"))
{ {
string? obj = ReadTile.getObjectNameAtTile((int)position.X, (int)position.Y); NPC npc = Game1.currentLocation.isCharacterAtTile(position);
StardewValley.Object @object = Game1.currentLocation.getObjectAtTile((int)position.X, (int)position.Y); if (!npcs.Contains(npc))
if (@object is Furniture && !exclusions.Contains("furniture"))
{ {
if (!furnitures.Contains(@object as Furniture)) playSoundAt(position, npc.displayName);
{
furnitures.Add(@object as Furniture);
Game1.currentLocation.localSoundAt("sa_poi", position);
MainClass.monitor.Log($"FUR:{@object.DisplayName}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
}
}
else if (!exclusions.Contains(obj.ToLower()))
{
Game1.currentLocation.localSoundAt("sa_poi", position);
MainClass.monitor.Log($"OBJ:{obj}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
} }
// Check for water
else if (Game1.currentLocation.isWaterTile((int)position.X, (int)position.Y) && !exclusions.Contains("water"))
{
playSoundAt(position, null);
}
// Check for objects
else if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y))
{
string? objectName = ReadTile.getObjectNameAtTile((int)position.X, (int)position.Y);
StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)position.X, (int)position.Y);
if (objectName != null)
{
if (obj is Furniture && !exclusions.Contains("furniture"))
{
if (!furnitures.Contains(obj as Furniture))
{
furnitures.Add(obj as Furniture);
playSoundAt(position, objectName);
}
}
else
{
playSoundAt(position, objectName);
}
}
}
// Check for terrain features
else if (terrainFeature.ContainsKey(position)) else if (terrainFeature.ContainsKey(position))
{ {
Netcode.NetRef<TerrainFeature> tr = terrainFeature[position]; Netcode.NetRef<TerrainFeature> tr = terrainFeature[position];
string? terrain = ReadTile.getTerrainFeatureAtTile(tr); string? terrain = ReadTile.getTerrainFeatureAtTile(tr).ToLower();
if (tr != null) if (terrain != null)
{ {
if(tr.Get() is HoeDirt && !exclusions.Contains("crop")) if(tr.Get() is HoeDirt && !exclusions.Contains("crop"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"CROP:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if(tr.Get() is GiantCrop && !exclusions.Contains("giant crop")) else if(tr.Get() is GiantCrop && !exclusions.Contains("giant crop"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"BUSH:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Bush && !exclusions.Contains("bush")) else if (tr.Get() is Bush && !exclusions.Contains("bush"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"BUSH:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is CosmeticPlant && !exclusions.Contains("cosmetic plant")) else if (tr.Get() is CosmeticPlant && !exclusions.Contains("cosmetic plant"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"COSMETIC_PLANT:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Flooring && !exclusions.Contains("flooring")) else if (tr.Get() is Flooring && !exclusions.Contains("flooring"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"FLOORING:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is FruitTree && !exclusions.Contains("fruit tree")) else if (tr.Get() is FruitTree && !exclusions.Contains("fruit tree"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"FRUTI_TREE:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Grass && !exclusions.Contains("grass")) else if (tr.Get() is Grass && !exclusions.Contains("grass"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"GRASS:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Tree && !exclusions.Contains("tree")) else if (tr.Get() is Tree && !exclusions.Contains("tree"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"TREE:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Quartz && !exclusions.Contains("quartz")) else if (tr.Get() is Quartz && !exclusions.Contains("quartz"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"QUARTZ:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
else if (tr.Get() is Leaf && !exclusions.Contains("leaf")) else if (tr.Get() is Leaf && !exclusions.Contains("leaf"))
{ {
Game1.currentLocation.localSoundAt("sa_poi", position); playSoundAt(position, terrain);
MainClass.monitor.Log($"LEAF:{terrain}\tX:{position.X}\tY:{position.Y}", StardewModdingAPI.LogLevel.Debug);
} }
} }
} }
// Check for Mine ladders
else if (ReadTile.isMineLadderAtTile((int)position.X, (int)position.Y) && !exclusions.Contains("ladder"))
{
playSoundAt(position, null);
}
// Check for doors
else if (ReadTile.isDoorAtTile((int)position.X, (int)position.Y) && !exclusions.Contains("door"))
{
playSoundAt(position, null);
}
// Check for buildings on maps
else if (ReadTile.getBuildingAtTile((int)position.X, (int)position.Y) != null)
{
playSoundAt(position, ReadTile.getBuildingAtTile((int)position.X, (int)position.Y));
}
// Check for resource clumps
else if (ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y) != null)
{
playSoundAt(position, ReadTile.getResourceClumpAtTile((int)position.X, (int)position.Y));
}
}
public void playSoundAt(Vector2 position, String? searchQuery)
{
if (searchQuery == null || !exclusions.Contains(searchQuery))
{
MainClass.monitor.Log($"{searchQuery}:X={position.X} Y={position.Y}", StardewModdingAPI.LogLevel.Debug);
Game1.currentLocation.localSoundAt("sa_poi", position);
}
} }
} }
} }

View File

@ -74,44 +74,9 @@ namespace stardew_access.Game
{ {
toSpeak = "Ladder"; toSpeak = "Ladder";
} }
else else if(getBuildingAtTile(x, y) != null)
{ {
try toSpeak = getBuildingAtTile(x, y);
{
int index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
/* Add More
MainClass.monitor.Log(index.ToString(), LogLevel.Debug);
*/
switch (index)
{
case 1955:
case 41:
toSpeak = "Mail Box";
break;
case 173:
toSpeak = "Fridge";
break;
case 169:
case 170:
case 171:
case 172:
toSpeak = "Kitchen";
break;
case 1003:
toSpeak = "Street lamp";
break;
case 78:
toSpeak = "Trash bin";
break;
case 617:
toSpeak = "Daily quest";
break;
case 616:
toSpeak = "Calender";
break;
}
}
catch (Exception) {}
} }
#endregion #endregion
@ -136,6 +101,48 @@ namespace stardew_access.Game
isReadingTile = false; isReadingTile = false;
} }
public static string? getBuildingAtTile(int x, int y)
{
string? toReturn = null;
int? index = Game1.currentLocation.Map.GetLayer("Buildings").Tiles[x, y].TileIndex;
/* Add More
MainClass.monitor.Log(index.ToString(), LogLevel.Debug);
*/
if (index != null)
{
switch (index)
{
case 1955:
case 41:
toReturn = "Mail Box";
break;
case 173:
toReturn = "Fridge";
break;
case 169:
case 170:
case 171:
case 172:
toReturn = "Kitchen";
break;
case 1003:
toReturn = "Street lamp";
break;
case 78:
toReturn = "Trash bin";
break;
case 617:
toReturn = "Daily quest";
break;
case 616:
toReturn = "Calender";
break;
}
}
return toReturn;
}
public static string getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain) public static string getTerrainFeatureAtTile(Netcode.NetRef<TerrainFeature> terrain)
{ {
string? toReturn = null; string? toReturn = null;

View File

@ -383,12 +383,11 @@ namespace stardew_access
ReadTile.run(manuallyTriggered: true); ReadTile.run(manuallyTriggered: true);
} }
// Manual read tile /*if (Equals(e.Button, SButton.B))
if (Equals(e.Button, SButton.B))
{ {
Game1.player.controller = new PathFindController(Game1.player, Game1.currentLocation, new Point(49,13), 2); 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 monitor.Log($"{Game1.player.controller.pathToEndPoint==null}", LogLevel.Debug); // true if path not found
} }*/
} }
private void SnapMouseToPlayer() private void SnapMouseToPlayer()