public void CheckTileAndPlaySound(Vector2 position) { try { if (Game1.currentLocation.isObjectAtTile((int)position.X, (int)position.Y)) { (string?name, CATEGORY category)objDetails = TileInfo.getObjectAtTile((int)position.X, (int)position.Y); string? objectName = objDetails.name; CATEGORY category = objDetails.category; StardewValley.Object obj = Game1.currentLocation.getObjectAtTile((int)position.X, (int)position.Y); if (objectName != null) { objectName = objectName.ToLower().Trim(); if (obj is Furniture) { if (!furnitures.Contains((Furniture)obj)) { furnitures.Add((Furniture)obj); PlaySoundAt(position, objectName, category); } } else { PlaySoundAt(position, objectName, category); } } } else { (string?name, CATEGORY? category)tileDetail = TileInfo.getNameWithCategoryAtTile(position); if (tileDetail.name != null) { if (tileDetail.category == null) { tileDetail.category = CATEGORY.Others; } PlaySoundAt(position, tileDetail.name, tileDetail.category); } } } catch (Exception e) { MainClass.ErrorLog($"{e.Message}\n{e.StackTrace}\n{e.Source}"); } }
public (string?name, CATEGORY category) getStaticTileInfoAtWithCategory(int x, int y) { if (data == null) { return(null, CATEGORY.Others); } foreach (var location in data) { if (!Game1.currentLocation.Name.ToLower().Equals(location.Key)) { continue; } if (location.Value != null) { foreach (var tile in ((JObject)location.Value)) { if (tile.Value == null) { continue; } JToken?tileXArray = tile.Value["x"]; JToken?tileYArray = tile.Value["y"]; JToken?tileType = tile.Value["type"]; if (tileXArray == null || tileYArray == null || tileType == null) { continue; } bool isXPresent = false; bool isYPresent = false; foreach (var item in tileXArray) { if (short.Parse(item.ToString()) == x) { isXPresent = true; break; } } foreach (var item in tileYArray) { if (short.Parse(item.ToString()) == y) { isYPresent = true; break; } } if (isXPresent && isYPresent) { return(tile.Key, CATEGORY.FromString(tileType.ToString())); } } } } return(null, CATEGORY.Others); }
public static string GetSoundName(CATEGORY category, string post) { string soundName = $"_{post}"; if (!MainClass.Config.RadarStereoSound) { soundName = $"_mono{soundName}"; } if (category == CATEGORY.Farmers) // Villagers and farmers { soundName = $"npc{soundName}"; } else if (category == CATEGORY.FarmAnimals) // Farm Animals { soundName = $"npc{soundName}"; } else if (category == CATEGORY.NPCs) // Other npcs, also includes enemies { soundName = $"npc{soundName}"; } else if (category == CATEGORY.WaterTiles) // Water tiles { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Furnitures) // Furnitures { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Others) // Other Objects { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Crops) // Crops { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Trees) // Trees { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Buildings) // Buildings { soundName = $"obj{soundName}"; } else if (category == CATEGORY.MineItems) // Mine items { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Chests) // Chests { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Debris) // Grass and debris { soundName = $"obj{soundName}"; } else if (category == CATEGORY.Flooring) // Flooring { soundName = $"obj{soundName}"; } else // Default { soundName = $"obj{soundName}"; } return(soundName); }
public void PlaySoundAt(Vector2 position, string searchQuery, CATEGORY category) { #region Check whether to skip the object or not // Skip if player is directly looking at the tile if (CurrentPlayer.FacingTile.Equals(position)) { return; } if (!radarFocus) { if ((exclusions.Contains(category.ToString().ToLower().Trim()) || exclusions.Contains(searchQuery.ToLower().Trim()))) { return; } // Check if a word in searchQuery matches the one in exclusions list string[] sqArr = searchQuery.ToLower().Trim().Split(" "); for (int j = 0; j < sqArr.Length; j++) { if (exclusions.Contains(sqArr[j])) { return; } } } else { if (focus.Count >= 0) { bool found = false; // Check if a word in searchQuery matches the one in focus list string[] sqArr = searchQuery.ToLower().Trim().Split(" "); for (int j = 0; j < sqArr.Length; j++) { if (focus.Contains(sqArr[j])) { found = true; break; } } // This condition has to be after the for loop if (!found && !(focus.Contains(category.ToString().ToLower().Trim()) || focus.Contains(searchQuery.ToLower().Trim()))) { return; } } else { return; } } #endregion if (MainClass.radarDebug) { MainClass.ErrorLog($"{radarFocus}\tObject:{searchQuery.ToLower().Trim()}\tPosition: X={position.X} Y={position.Y}"); } int px = (int)Game1.player.getTileX(); // Player's X postion int py = (int)Game1.player.getTileY(); // Player's Y postion int ox = (int)position.X; // Object's X postion int oy = (int)position.Y; // Object's Y postion int dx = ox - px; // Distance of object's X position int dy = oy - py; // Distance of object's Y position if (dy < 0 && (Math.Abs(dy) >= Math.Abs(dx))) // Object is at top { Game1.currentLocation.localSoundAt(GetSoundName(category, "top"), position); } else if (dx > 0 && (Math.Abs(dx) >= Math.Abs(dy))) // Object is at right { Game1.currentLocation.localSoundAt(GetSoundName(category, "right"), position); } else if (dx < 0 && (Math.Abs(dx) > Math.Abs(dy))) // Object is at left { Game1.currentLocation.localSoundAt(GetSoundName(category, "left"), position); } else if (dy > 0 && (Math.Abs(dy) > Math.Abs(dx))) // Object is at bottom { Game1.currentLocation.localSoundAt(GetSoundName(category, "bottom"), position); } }